* doc/sdccman.lyx: fixed webdocs bug #2071421: error in the manual
[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 -\\/-lib-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 -c\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 -compile-only
10201 \begin_inset LatexCommand index
10202 name "-\\/-compile-only"
10203
10204 \end_inset
10205
10206
10207 \begin_inset LatexCommand index
10208 name "-c -\\/-compile-only"
10209
10210 \end_inset
10211
10212
10213 \series default
10214  will compile and assemble the source, but will not call the linkage editor.
10215 \end_layout
10216
10217 \begin_layout List
10218 \labelwidthstring 00.00.0000
10219
10220 \series bold
10221 -
10222 \series default
10223
10224 \begin_inset ERT
10225 status collapsed
10226
10227 \begin_layout Standard
10228
10229
10230 \backslash
10231 /
10232 \end_layout
10233
10234 \end_inset
10235
10236
10237 \series bold
10238 -c1mode
10239 \begin_inset LatexCommand index
10240 name "-\\/-c1mode"
10241
10242 \end_inset
10243
10244
10245 \series default
10246  reads the preprocessed source from standard input and compiles it.
10247  The file name for the assembler output must be specified using the -o option.
10248 \end_layout
10249
10250 \begin_layout List
10251 \labelwidthstring 00.00.0000
10252
10253 \series bold
10254 -E
10255 \begin_inset LatexCommand index
10256 name "-E"
10257
10258 \end_inset
10259
10260
10261 \series default
10262  Run only the C preprocessor.
10263  Preprocess all the C source files specified and output the results to standard
10264  output.
10265 \end_layout
10266
10267 \begin_layout List
10268 \labelwidthstring 00.00.0000
10269
10270 \series bold
10271 -o\InsetSpace ~
10272 <path/file>
10273 \begin_inset LatexCommand index
10274 name "-o <path/file>"
10275
10276 \end_inset
10277
10278
10279 \series default
10280  The output path where everything will be placed or the file name used for
10281  all generated output files.
10282  If the parameter is a path, it must have a trailing slash (or backslash
10283  for the Windows binaries) to be recognized as a path.
10284  Note for Windows users: if the path contains spaces, it should be surrounded
10285  by quotes.
10286  The trailing backslash should be doubled in order to prevent escaping the
10287  final quote, for example: 
10288 \emph on
10289 -o 
10290 \begin_inset Quotes sld
10291 \end_inset
10292
10293 F:
10294 \backslash
10295 Projects
10296 \backslash
10297 test3
10298 \backslash
10299 output 1
10300 \backslash
10301
10302 \backslash
10303
10304 \begin_inset Quotes srd
10305 \end_inset
10306
10307
10308 \emph default
10309  or put after the final quote, for example: 
10310 \emph on
10311 -o 
10312 \begin_inset Quotes sld
10313 \end_inset
10314
10315 F:
10316 \backslash
10317 Projects
10318 \backslash
10319 test3
10320 \backslash
10321 output 1
10322 \begin_inset Quotes srd
10323 \end_inset
10324
10325
10326 \backslash
10327
10328 \emph default
10329 .
10330  The path using slashes for directory delimiters can be used too, for example:
10331  
10332 \emph on
10333 -o 
10334 \begin_inset Quotes sld
10335 \end_inset
10336
10337 F:/Projects/test3/output 1/
10338 \begin_inset Quotes srd
10339 \end_inset
10340
10341
10342 \emph default
10343 .
10344 \end_layout
10345
10346 \begin_layout List
10347 \labelwidthstring 00.00.0000
10348
10349 \series bold
10350 -
10351 \begin_inset ERT
10352 status collapsed
10353
10354 \begin_layout Standard
10355
10356
10357 \backslash
10358 /
10359 \end_layout
10360
10361 \end_inset
10362
10363 -stack-auto
10364 \begin_inset LatexCommand index
10365 name "-\\/-stack-auto"
10366
10367 \end_inset
10368
10369
10370 \series default
10371 \size large
10372  
10373 \size default
10374 All functions in the source file will be compiled as 
10375 \emph on
10376 reentrant
10377 \emph default
10378
10379 \begin_inset LatexCommand index
10380 name "reentrant"
10381
10382 \end_inset
10383
10384 , i.e.
10385  the parameters and local variables will be allocated on the stack
10386 \begin_inset LatexCommand index
10387 name "stack"
10388
10389 \end_inset
10390
10391 .
10392  See section 
10393 \begin_inset LatexCommand ref
10394 reference "sec:Parameters-and-Local-Variables"
10395
10396 \end_inset
10397
10398  Parameters and Local Variables for more details.
10399  If this option is used all source files in the project should be compiled
10400  with this option.
10401  It automatically implies -
10402 \series bold
10403
10404 \begin_inset ERT
10405 status open
10406
10407 \begin_layout Standard
10408
10409
10410 \backslash
10411 /
10412 \end_layout
10413
10414 \end_inset
10415
10416
10417 \series default
10418 -int-long-reent and -
10419 \series bold
10420
10421 \begin_inset ERT
10422 status open
10423
10424 \begin_layout Standard
10425
10426
10427 \backslash
10428 /
10429 \end_layout
10430
10431 \end_inset
10432
10433
10434 \series default
10435 -float-reent.
10436  
10437 \end_layout
10438
10439 \begin_layout List
10440 \labelwidthstring 00.00.0000
10441
10442 \series bold
10443 -
10444 \begin_inset ERT
10445 status collapsed
10446
10447 \begin_layout Standard
10448
10449
10450 \backslash
10451 /
10452 \end_layout
10453
10454 \end_inset
10455
10456 -callee-saves
10457 \begin_inset LatexCommand index
10458 name "-\\/-callee-saves"
10459
10460 \end_inset
10461
10462  
10463 \begin_inset LatexCommand label
10464 name "lyx:--callee-saves-function1[,function2][,function3]..."
10465
10466 \end_inset
10467
10468 function1[,function2][,function3]....
10469
10470 \series default
10471  The compiler by default uses a caller saves convention for register saving
10472  across function calls, however this can cause unnecessary register pushing
10473  and popping when calling small functions from larger functions.
10474  This option can be used to switch the register saving convention for the
10475  function names specified.
10476  The compiler will not save registers when calling these functions, no extra
10477  code will be generated at the entry and exit (function prologue
10478 \series bold
10479
10480 \begin_inset LatexCommand index
10481 name "function prologue"
10482
10483 \end_inset
10484
10485
10486 \series default
10487  and epilogue
10488 \series bold
10489
10490 \begin_inset LatexCommand index
10491 name "function epilogue"
10492
10493 \end_inset
10494
10495
10496 \series default
10497 ) for these functions to save and restore the registers used by these functions,
10498  this can SUBSTANTIALLY reduce code and improve run time performance of
10499  the generated code.
10500  In the future the compiler (with inter procedural analysis) will be able
10501  to determine the appropriate scheme to use for each function call.
10502  DO NOT use this option for built-in functions such as _mulint..., if this
10503  option is used for a library function the appropriate library function
10504  needs to be recompiled with the same option.
10505  If the project consists of multiple source files then all the source file
10506  should be compiled with the same -
10507 \begin_inset ERT
10508 status collapsed
10509
10510 \begin_layout Standard
10511
10512
10513 \backslash
10514 /
10515 \end_layout
10516
10517 \end_inset
10518
10519 -callee-saves option string.
10520  Also see #pragma\InsetSpace ~
10521 callee_saves 
10522 \begin_inset LatexCommand index
10523 name "\\#pragma callee\\_saves"
10524
10525 \end_inset
10526
10527  
10528 \begin_inset LatexCommand vpageref
10529 reference "ite:callee_saves-function1[,function2[,function3...]]--"
10530
10531 \end_inset
10532
10533 .
10534 \end_layout
10535
10536 \begin_layout List
10537 \labelwidthstring 00.00.0000
10538
10539 \series bold
10540 -
10541 \begin_inset ERT
10542 status collapsed
10543
10544 \begin_layout Standard
10545
10546
10547 \backslash
10548 /
10549 \end_layout
10550
10551 \end_inset
10552
10553 -all-callee-saves
10554 \begin_inset LatexCommand index
10555 name "-\\/-all-callee-saves"
10556
10557 \end_inset
10558
10559
10560 \series default
10561  Function of -
10562 \begin_inset ERT
10563 status collapsed
10564
10565 \begin_layout Standard
10566
10567
10568 \backslash
10569 /
10570 \end_layout
10571
10572 \end_inset
10573
10574 -callee-saves will be applied to all functions by default.
10575 \end_layout
10576
10577 \begin_layout List
10578 \labelwidthstring 00.00.0000
10579
10580 \series bold
10581 -
10582 \begin_inset ERT
10583 status collapsed
10584
10585 \begin_layout Standard
10586
10587
10588 \backslash
10589 /
10590 \end_layout
10591
10592 \end_inset
10593
10594 -debug
10595 \begin_inset LatexCommand index
10596 name "-\\/-debug"
10597
10598 \end_inset
10599
10600  
10601 \series default
10602 When this option is used the compiler will generate debug information.
10603  The debug information collected in a file with .cdb extension can be used
10604  with the SDCDB.
10605  For more information see documentation for SDCDB.
10606  Another file with no extension contains debug information in AOMF or AOMF51
10607 \begin_inset LatexCommand index
10608 name "AOMF, AOMF51"
10609
10610 \end_inset
10611
10612  format which is commonly used by third party tools.
10613 \end_layout
10614
10615 \begin_layout List
10616 \labelwidthstring 00.00.0000
10617
10618 \series bold
10619 -S
10620 \begin_inset LatexCommand index
10621 name "-S"
10622
10623 \end_inset
10624
10625
10626 \series default
10627 \size large
10628  
10629 \size default
10630 Stop after the stage of compilation proper; do not assemble.
10631  The output is an assembler code file for the input file specified.
10632 \end_layout
10633
10634 \begin_layout List
10635 \labelwidthstring 00.00.0000
10636
10637 \series bold
10638 -
10639 \begin_inset ERT
10640 status collapsed
10641
10642 \begin_layout Standard
10643
10644
10645 \backslash
10646 /
10647 \end_layout
10648
10649 \end_inset
10650
10651 -int-long-reent
10652 \begin_inset LatexCommand index
10653 name "-\\/-int-long-reent"
10654
10655 \end_inset
10656
10657
10658 \series default
10659  Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
10660  Note by default these libraries are compiled as non-reentrant.
10661  See section Installation for more details.
10662 \end_layout
10663
10664 \begin_layout List
10665 \labelwidthstring 00.00.0000
10666
10667 \series bold
10668 -
10669 \begin_inset ERT
10670 status collapsed
10671
10672 \begin_layout Standard
10673
10674
10675 \backslash
10676 /
10677 \end_layout
10678
10679 \end_inset
10680
10681 -cyclomatic
10682 \begin_inset LatexCommand index
10683 name "-\\/-cyclomatic"
10684
10685 \end_inset
10686
10687  
10688 \series default
10689 This option will cause the compiler to generate an information message for
10690  each function in the source file.
10691  The message contains some 
10692 \emph on
10693 important
10694 \emph default
10695  information about the function.
10696  The number of edges and nodes the compiler detected in the control flow
10697  graph of the function, and most importantly the 
10698 \emph on
10699 cyclomatic complexity
10700 \begin_inset LatexCommand index
10701 name "Cyclomatic complexity"
10702
10703 \end_inset
10704
10705
10706 \emph default
10707  see section on Cyclomatic Complexity for more details.
10708 \end_layout
10709
10710 \begin_layout List
10711 \labelwidthstring 00.00.0000
10712
10713 \series bold
10714 -
10715 \begin_inset ERT
10716 status collapsed
10717
10718 \begin_layout Standard
10719
10720
10721 \backslash
10722 /
10723 \end_layout
10724
10725 \end_inset
10726
10727 -float-reent
10728 \begin_inset LatexCommand index
10729 name "-\\/-float-reent"
10730
10731 \end_inset
10732
10733
10734 \series default
10735  Floating point library is compiled as reentrant
10736 \begin_inset LatexCommand index
10737 name "reentrant"
10738
10739 \end_inset
10740
10741 .
10742  See section Installation 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 -funsigned-char
10763 \begin_inset LatexCommand index
10764 name "-\\/-funsigned-char"
10765
10766 \end_inset
10767
10768
10769 \series default
10770  The default signedness for every type is 
10771 \family typewriter
10772 signed
10773 \family default
10774 .
10775  In some embedded environments the default signedness of 
10776 \family typewriter
10777 char
10778 \family default
10779  is 
10780 \family typewriter
10781 unsigned
10782 \family default
10783 .
10784  To set the signess for characters to unsigned, use the option -
10785 \series bold
10786
10787 \begin_inset ERT
10788 status open
10789
10790 \begin_layout Standard
10791
10792
10793 \backslash
10794 /
10795 \end_layout
10796
10797 \end_inset
10798
10799
10800 \series default
10801 -funsigned-char.
10802  If this option is set and no signedness keyword (unsigned/signed) is given,
10803  a char will be signed.
10804  All other types are unaffected.
10805 \end_layout
10806
10807 \begin_layout List
10808 \labelwidthstring 00.00.0000
10809
10810 \series bold
10811 -
10812 \begin_inset ERT
10813 status collapsed
10814
10815 \begin_layout Standard
10816
10817
10818 \backslash
10819 /
10820 \end_layout
10821
10822 \end_inset
10823
10824 -main-return
10825 \begin_inset LatexCommand index
10826 name "-\\/-main-return"
10827
10828 \end_inset
10829
10830
10831 \series default
10832  This option can be used if the code generated is called by a monitor program
10833  or if the main routine includes an endless loop.
10834  This option results in slightly smaller code and saves two bytes of stack
10835  space.
10836  The return from the 'main'
10837 \begin_inset LatexCommand index
10838 name "main return"
10839
10840 \end_inset
10841
10842  function will return to the function calling main.
10843  The default setting is to lock up i.e.
10844  generate a '
10845 \family typewriter
10846 sjmp .
10847 \family default
10848 '.
10849 \end_layout
10850
10851 \begin_layout List
10852 \labelwidthstring 00.00.0000
10853
10854 \series bold
10855 -
10856 \begin_inset ERT
10857 status collapsed
10858
10859 \begin_layout Standard
10860
10861
10862 \backslash
10863 /
10864 \end_layout
10865
10866 \end_inset
10867
10868 -nostdinc
10869 \begin_inset LatexCommand index
10870 name "-\\/-nostdinc"
10871
10872 \end_inset
10873
10874
10875 \series default
10876  This will prevent the compiler from passing on the default include path
10877  to the preprocessor.
10878 \end_layout
10879
10880 \begin_layout List
10881 \labelwidthstring 00.00.0000
10882
10883 \series bold
10884 -
10885 \begin_inset ERT
10886 status collapsed
10887
10888 \begin_layout Standard
10889
10890
10891 \backslash
10892 /
10893 \end_layout
10894
10895 \end_inset
10896
10897 -nostdlib
10898 \begin_inset LatexCommand index
10899 name "-\\/-nostdlib"
10900
10901 \end_inset
10902
10903
10904 \series default
10905  This will prevent the compiler from passing on the default library
10906 \begin_inset LatexCommand index
10907 name "Libraries"
10908
10909 \end_inset
10910
10911  path to the linker.
10912 \end_layout
10913
10914 \begin_layout List
10915 \labelwidthstring 00.00.0000
10916
10917 \series bold
10918 -
10919 \begin_inset ERT
10920 status collapsed
10921
10922 \begin_layout Standard
10923
10924
10925 \backslash
10926 /
10927 \end_layout
10928
10929 \end_inset
10930
10931 -verbose
10932 \begin_inset LatexCommand index
10933 name "-\\/-verbose"
10934
10935 \end_inset
10936
10937
10938 \series default
10939  Shows the various actions the compiler is performing.
10940 \end_layout
10941
10942 \begin_layout List
10943 \labelwidthstring 00.00.0000
10944
10945 \series bold
10946 -V
10947 \begin_inset LatexCommand index
10948 name "-V"
10949
10950 \end_inset
10951
10952
10953 \series default
10954  Shows the actual commands the compiler is executing.
10955 \end_layout
10956
10957 \begin_layout List
10958 \labelwidthstring 00.00.0000
10959
10960 \series bold
10961 -
10962 \begin_inset ERT
10963 status collapsed
10964
10965 \begin_layout Standard
10966
10967
10968 \backslash
10969 /
10970 \end_layout
10971
10972 \end_inset
10973
10974 -no-c-code-in-asm
10975 \begin_inset LatexCommand index
10976 name "-\\/-no-c-code-in-asm"
10977
10978 \end_inset
10979
10980
10981 \series default
10982  Hides your ugly and inefficient c-code from the asm file, so you can always
10983  blame the compiler :)
10984 \end_layout
10985
10986 \begin_layout List
10987 \labelwidthstring 00.00.0000
10988
10989 \series bold
10990 -
10991 \begin_inset ERT
10992 status collapsed
10993
10994 \begin_layout Standard
10995
10996
10997 \backslash
10998 /
10999 \end_layout
11000
11001 \end_inset
11002
11003 -fverbose-asm
11004 \begin_inset LatexCommand index
11005 name "-\\/-no-gen-comments"
11006
11007 \end_inset
11008
11009
11010 \series default
11011  Include code generator and peep-hole comments in the generated asm files.
11012 \end_layout
11013
11014 \begin_layout List
11015 \labelwidthstring 00.00.0000
11016
11017 \series bold
11018 -
11019 \begin_inset ERT
11020 status collapsed
11021
11022 \begin_layout Standard
11023
11024
11025 \backslash
11026 /
11027 \end_layout
11028
11029 \end_inset
11030
11031 -no-peep-comments
11032 \begin_inset LatexCommand index
11033 name "-\\/-no-peep-comments"
11034
11035 \end_inset
11036
11037
11038 \series default
11039  Don't include peep-hole comments in the generated asm files even if -
11040 \series bold
11041
11042 \begin_inset ERT
11043 status open
11044
11045 \begin_layout Standard
11046
11047
11048 \backslash
11049 /
11050 \end_layout
11051
11052 \end_inset
11053
11054
11055 \series default
11056 -fverbose-asm option is specified.
11057 \end_layout
11058
11059 \begin_layout List
11060 \labelwidthstring 00.00.0000
11061
11062 \series bold
11063 -
11064 \begin_inset ERT
11065 status collapsed
11066
11067 \begin_layout Standard
11068
11069
11070 \backslash
11071 /
11072 \end_layout
11073
11074 \end_inset
11075
11076 -i-code-in-asm
11077 \begin_inset LatexCommand index
11078 name "-\\/-i-code-in-asm"
11079
11080 \end_inset
11081
11082
11083 \series default
11084  Include i-codes in the asm file.
11085  Sounds like noise but is most helpful for debugging the compiler itself.
11086 \end_layout
11087
11088 \begin_layout List
11089 \labelwidthstring 00.00.0000
11090
11091 \series bold
11092 -
11093 \begin_inset ERT
11094 status collapsed
11095
11096 \begin_layout Standard
11097
11098
11099 \backslash
11100 /
11101 \end_layout
11102
11103 \end_inset
11104
11105 -less-pedantic
11106 \begin_inset LatexCommand index
11107 name "pedantic"
11108
11109 \end_inset
11110
11111
11112 \begin_inset LatexCommand index
11113 name "-\\/-less-pedantic"
11114
11115 \end_inset
11116
11117
11118 \series default
11119
11120 \begin_inset LatexCommand label
11121 name "lyx:--less-pedantic"
11122
11123 \end_inset
11124
11125  Disable some of the more pedantic warnings
11126 \begin_inset LatexCommand index
11127 name "Warnings"
11128
11129 \end_inset
11130
11131 .
11132  For more details, see the less_pedantic pragma 
11133 \begin_inset LatexCommand vpageref
11134 reference "ite:less_pedantic"
11135
11136 \end_inset
11137
11138 .
11139 \end_layout
11140
11141 \begin_layout List
11142 \labelwidthstring 00.00.0000
11143
11144 \series bold
11145 -
11146 \begin_inset ERT
11147 status collapsed
11148
11149 \begin_layout Standard
11150
11151
11152 \backslash
11153 /
11154 \end_layout
11155
11156 \end_inset
11157
11158 -disable-warning\InsetSpace ~
11159 <nnnn>
11160 \begin_inset LatexCommand index
11161 name "-\\/-disable-warning"
11162
11163 \end_inset
11164
11165
11166 \series default
11167  Disable specific warning with number <nnnn>.
11168 \end_layout
11169
11170 \begin_layout List
11171 \labelwidthstring 00.00.0000
11172
11173 \series bold
11174 -
11175 \begin_inset ERT
11176 status collapsed
11177
11178 \begin_layout Standard
11179
11180
11181 \backslash
11182 /
11183 \end_layout
11184
11185 \end_inset
11186
11187 -Werror
11188 \begin_inset LatexCommand index
11189 name "-\\/-Werror"
11190
11191 \end_inset
11192
11193
11194 \series default
11195  Treat all warnings as errors.
11196 \end_layout
11197
11198 \begin_layout List
11199 \labelwidthstring 00.00.0000
11200
11201 \series bold
11202 -
11203 \begin_inset ERT
11204 status collapsed
11205
11206 \begin_layout Standard
11207
11208
11209 \backslash
11210 /
11211 \end_layout
11212
11213 \end_inset
11214
11215 -print-search-dirs
11216 \begin_inset LatexCommand index
11217 name "-\\/-print-search-dirs"
11218
11219 \end_inset
11220
11221
11222 \series default
11223  Display the directories in the compiler's search path
11224 \end_layout
11225
11226 \begin_layout List
11227 \labelwidthstring 00.00.0000
11228
11229 \series bold
11230 -
11231 \begin_inset ERT
11232 status collapsed
11233
11234 \begin_layout Standard
11235
11236
11237 \backslash
11238 /
11239 \end_layout
11240
11241 \end_inset
11242
11243 -vc
11244 \begin_inset LatexCommand index
11245 name "-\\/-vc"
11246
11247 \end_inset
11248
11249
11250 \series default
11251  Display errors and warnings using MSVC style, so you can use SDCC with
11252  the visual studio IDE
11253 \begin_inset LatexCommand index
11254 name "IDE"
11255
11256 \end_inset
11257
11258 .
11259  With SDCC both offering a GCC-like (the default) and a MSVC-like
11260 \begin_inset LatexCommand index
11261 name "MSVC output style"
11262
11263 \end_inset
11264
11265  output style, integration into most programming editors should be straightforwa
11266 rd.
11267 \end_layout
11268
11269 \begin_layout List
11270 \labelwidthstring 00.00.0000
11271
11272 \series bold
11273 -
11274 \begin_inset ERT
11275 status collapsed
11276
11277 \begin_layout Standard
11278
11279
11280 \backslash
11281 /
11282 \end_layout
11283
11284 \end_inset
11285
11286 -use-stdout
11287 \begin_inset LatexCommand index
11288 name "-\\/-use-stdout"
11289
11290 \end_inset
11291
11292
11293 \series default
11294  Send errors and warnings to stdout instead of stderr.
11295 \end_layout
11296
11297 \begin_layout List
11298 \labelwidthstring 00.00.0000
11299
11300 \series bold
11301 -Wa\InsetSpace ~
11302 asmOption[,asmOption]
11303 \series default
11304
11305 \begin_inset LatexCommand index
11306 name "-Wa asmOption[,asmOption]"
11307
11308 \end_inset
11309
11310 ...
11311  Pass the asmOption to the assembler
11312 \begin_inset LatexCommand index
11313 name "Options assembler"
11314
11315 \end_inset
11316
11317
11318 \begin_inset LatexCommand index
11319 name "Assembler options"
11320
11321 \end_inset
11322
11323 .
11324  See file sdcc/as/doc/asxhtm.html for assembler options.cd
11325 \end_layout
11326
11327 \begin_layout List
11328 \labelwidthstring 00.00.0000
11329
11330 \series bold
11331 -
11332 \begin_inset ERT
11333 status collapsed
11334
11335 \begin_layout Standard
11336
11337
11338 \backslash
11339 /
11340 \end_layout
11341
11342 \end_inset
11343
11344 -std-sdcc89
11345 \begin_inset LatexCommand index
11346 name "-\\/-std-sdcc89"
11347
11348 \end_inset
11349
11350
11351 \series default
11352  Generally follow the C89 standard, but allow SDCC features that conflict
11353  with the standard (default).
11354 \end_layout
11355
11356 \begin_layout List
11357 \labelwidthstring 00.00.0000
11358
11359 \series bold
11360 -
11361 \begin_inset ERT
11362 status collapsed
11363
11364 \begin_layout Standard
11365
11366
11367 \backslash
11368 /
11369 \end_layout
11370
11371 \end_inset
11372
11373 -std-c89
11374 \begin_inset LatexCommand index
11375 name "-\\/-std-c89"
11376
11377 \end_inset
11378
11379
11380 \series default
11381  Follow the C89 standard and disable SDCC features that conflict with the
11382  standard.
11383 \end_layout
11384
11385 \begin_layout List
11386 \labelwidthstring 00.00.0000
11387
11388 \series bold
11389 -
11390 \begin_inset ERT
11391 status collapsed
11392
11393 \begin_layout Standard
11394
11395
11396 \backslash
11397 /
11398 \end_layout
11399
11400 \end_inset
11401
11402 -std-sdcc99
11403 \begin_inset LatexCommand index
11404 name "-\\/-std-sdcc99"
11405
11406 \end_inset
11407
11408
11409 \series default
11410  Generally follow the C99 standard, but allow SDCC features that conflict
11411  with the standard (incomplete support).
11412 \end_layout
11413
11414 \begin_layout List
11415 \labelwidthstring 00.00.0000
11416
11417 \series bold
11418 -
11419 \begin_inset ERT
11420 status collapsed
11421
11422 \begin_layout Standard
11423
11424
11425 \backslash
11426 /
11427 \end_layout
11428
11429 \end_inset
11430
11431 -std-c99
11432 \begin_inset LatexCommand index
11433 name "-\\/-std-sdcc99"
11434
11435 \end_inset
11436
11437
11438 \series default
11439  Follow the C99 standard and disable SDCC features that conflict with the
11440  standard (incomplete support).
11441 \end_layout
11442
11443 \begin_layout List
11444 \labelwidthstring 00.00.0000
11445
11446 \series bold
11447 -
11448 \begin_inset ERT
11449 status collapsed
11450
11451 \begin_layout Standard
11452
11453
11454 \backslash
11455 /
11456 \end_layout
11457
11458 \end_inset
11459
11460 -codeseg
11461 \series default
11462
11463 \begin_inset LatexCommand index
11464 name "-\\/-codeseg <Value>"
11465
11466 \end_inset
11467
11468
11469 \begin_inset LatexCommand label
11470 name "lyx:-codeseg"
11471
11472 \end_inset
11473
11474 \InsetSpace ~
11475 <Name> The name to be used for the code
11476 \begin_inset LatexCommand index
11477 name "code"
11478
11479 \end_inset
11480
11481  segment, default CSEG.
11482  This is useful if you need to tell the compiler to put the code in a special
11483  segment so you can later on tell the linker to put this segment in a special
11484  place in memory.
11485  Can be used for instance when using bank switching to put the code in a
11486  bank.
11487 \end_layout
11488
11489 \begin_layout List
11490 \labelwidthstring 00.00.0000
11491
11492 \series bold
11493 -
11494 \begin_inset ERT
11495 status collapsed
11496
11497 \begin_layout Standard
11498
11499
11500 \backslash
11501 /
11502 \end_layout
11503
11504 \end_inset
11505
11506 -constseg
11507 \series default
11508
11509 \begin_inset LatexCommand index
11510 name "-\\/-constseg <Value>"
11511
11512 \end_inset
11513
11514 \InsetSpace ~
11515 <Name> The name to be used for the const
11516 \begin_inset LatexCommand index
11517 name "const"
11518
11519 \end_inset
11520
11521  segment, default CONST.
11522  This is useful if you need to tell the compiler to put the const data in
11523  a special segment so you can later on tell the linker to put this segment
11524  in a special place in memory.
11525  Can be used for instance when using bank switching to put the const data
11526  in a bank.
11527 \end_layout
11528
11529 \begin_layout List
11530 \labelwidthstring 00.00.0000
11531
11532 \series bold
11533 -
11534 \begin_inset ERT
11535 status collapsed
11536
11537 \begin_layout Standard
11538
11539
11540 \backslash
11541 /
11542 \end_layout
11543
11544 \end_inset
11545
11546 -fdollars-in-identifiers
11547 \begin_inset LatexCommand index
11548 name "-\\/-fdollars-in-identifiers"
11549
11550 \end_inset
11551
11552
11553 \series default
11554  Permit '$' as an identifier character.
11555 \end_layout
11556
11557 \begin_layout List
11558 \labelwidthstring 00.00.0000
11559
11560 \series bold
11561 -
11562 \begin_inset ERT
11563 status collapsed
11564
11565 \begin_layout Standard
11566
11567
11568 \backslash
11569 /
11570 \end_layout
11571
11572 \end_inset
11573
11574 -more-pedantic
11575 \series default
11576
11577 \begin_inset LatexCommand index
11578 name "-\\/-more-pedantic"
11579
11580 \end_inset
11581
11582
11583 \begin_inset LatexCommand index
11584 name "pedantic"
11585
11586 \end_inset
11587
11588  Actually this is 
11589 \series bold
11590 \emph on
11591 not
11592 \series default
11593 \emph default
11594  a SDCC compiler option but if you want 
11595 \emph on
11596 more
11597 \emph default
11598  warnings you can use a separate tool dedicated to syntax checking like
11599  splint
11600 \begin_inset LatexCommand label
11601 name "lyx:more-pedantic-SPLINT"
11602
11603 \end_inset
11604
11605
11606 \begin_inset LatexCommand index
11607 name "lint (syntax checking tool)"
11608
11609 \end_inset
11610
11611  
11612 \begin_inset LatexCommand url
11613 target "http://www.splint.org"
11614
11615 \end_inset
11616
11617 .
11618  To make your source files parseable by splint you will have to include
11619  
11620 \family sans
11621 lint.h
11622 \family default
11623
11624 \begin_inset LatexCommand index
11625 name "splint (syntax checking tool)"
11626
11627 \end_inset
11628
11629  in your source file and add brackets around extended keywords (like 
11630 \family sans
11631
11632 \begin_inset Quotes sld
11633 \end_inset
11634
11635 __at\InsetSpace ~
11636
11637 \series bold
11638 (
11639 \series default
11640 0xab
11641 \series bold
11642 )
11643 \series default
11644
11645 \begin_inset Quotes srd
11646 \end_inset
11647
11648
11649 \family default
11650  and 
11651 \family sans
11652
11653 \begin_inset Quotes sld
11654 \end_inset
11655
11656 __interrupt\InsetSpace ~
11657 (2)
11658 \begin_inset Quotes srd
11659 \end_inset
11660
11661
11662 \family default
11663 ).
11664  
11665 \newline
11666 Splint has an excellent on line manual at 
11667 \begin_inset LatexCommand url
11668 target "http://www.splint.org/manual/"
11669
11670 \end_inset
11671
11672  and it's capabilities go beyond pure syntax checking.
11673  You'll need to tell splint the location of SDCC's include files so a typical
11674  command line could look like this: 
11675 \newline
11676
11677 \family sans
11678 splint\InsetSpace ~
11679 -I\InsetSpace ~
11680 /usr/local/share/sdcc/include/mcs51/\InsetSpace ~
11681 \InsetSpace ~
11682 myprogram.c
11683 \end_layout
11684
11685 \begin_layout List
11686 \labelwidthstring 00.00.0000
11687
11688 \series bold
11689 -
11690 \begin_inset ERT
11691 status collapsed
11692
11693 \begin_layout Standard
11694
11695
11696 \backslash
11697 /
11698 \end_layout
11699
11700 \end_inset
11701
11702 -short-is-8bits
11703 \series default
11704
11705 \begin_inset LatexCommand index
11706 name "-\\/-short-is-8bits"
11707
11708 \end_inset
11709
11710
11711 \begin_inset LatexCommand label
11712 name "lyx:--short-is-8bits"
11713
11714 \end_inset
11715
11716  Treat short as 8-bit (for backward compatibility with older versions of
11717  compiler - see section 
11718 \begin_inset LatexCommand ref
11719 reference "sec:Compatibility-with-previous"
11720
11721 \end_inset
11722
11723 )
11724 \end_layout
11725
11726 \begin_layout Standard
11727 \begin_inset VSpace bigskip
11728 \end_inset
11729
11730
11731 \end_layout
11732
11733 \begin_layout Subsection
11734 Intermediate Dump Options
11735 \begin_inset LatexCommand label
11736 name "sub:Intermediate-Dump-Options"
11737
11738 \end_inset
11739
11740
11741 \begin_inset LatexCommand index
11742 name "Options intermediate dump"
11743
11744 \end_inset
11745
11746
11747 \begin_inset LatexCommand index
11748 name "Intermediate dump options"
11749
11750 \end_inset
11751
11752
11753 \end_layout
11754
11755 \begin_layout Standard
11756 The following options are provided for the purpose of retargetting and debugging
11757  the compiler.
11758  They provide a means to dump the intermediate code (iCode
11759 \begin_inset LatexCommand index
11760 name "iCode"
11761
11762 \end_inset
11763
11764 ) generated by the compiler in human readable form at various stages of
11765  the compilation process.
11766  More on iCodes see chapter 
11767 \begin_inset LatexCommand ref
11768 reference "sub:The-anatomy-of"
11769
11770 \end_inset
11771
11772  
11773 \begin_inset Quotes srd
11774 \end_inset
11775
11776 The anatomy of the compiler
11777 \begin_inset Quotes srd
11778 \end_inset
11779
11780 .
11781 \end_layout
11782
11783 \begin_layout List
11784 \labelwidthstring 00.00.0000
11785
11786 \series bold
11787 -
11788 \begin_inset ERT
11789 status collapsed
11790
11791 \begin_layout Standard
11792
11793
11794 \backslash
11795 /
11796 \end_layout
11797
11798 \end_inset
11799
11800 -dumpraw
11801 \begin_inset LatexCommand index
11802 name "-\\/-dumpraw"
11803
11804 \end_inset
11805
11806
11807 \series default
11808  This option will cause the compiler to dump the intermediate code into
11809  a file of named 
11810 \emph on
11811 <source filename>.dumpraw
11812 \emph default
11813  just after the intermediate code has been generated for a function, i.e.
11814  before any optimizations are done.
11815  The basic blocks
11816 \begin_inset LatexCommand index
11817 name "Basic blocks"
11818
11819 \end_inset
11820
11821  at this stage ordered in the depth first number, so they may not be in
11822  sequence of execution.
11823 \end_layout
11824
11825 \begin_layout List
11826 \labelwidthstring 00.00.0000
11827
11828 \series bold
11829 -
11830 \begin_inset ERT
11831 status collapsed
11832
11833 \begin_layout Standard
11834
11835
11836 \backslash
11837 /
11838 \end_layout
11839
11840 \end_inset
11841
11842 -dumpgcse
11843 \begin_inset LatexCommand index
11844 name "-\\/-dumpgcse"
11845
11846 \end_inset
11847
11848
11849 \series default
11850  Will create a dump of iCodes, after global subexpression elimination
11851 \begin_inset LatexCommand index
11852 name "Global subexpression elimination"
11853
11854 \end_inset
11855
11856 , into a file named 
11857 \emph on
11858 <source filename>.dumpgcse.
11859 \end_layout
11860
11861 \begin_layout List
11862 \labelwidthstring 00.00.0000
11863
11864 \series bold
11865 -
11866 \begin_inset ERT
11867 status collapsed
11868
11869 \begin_layout Standard
11870
11871
11872 \backslash
11873 /
11874 \end_layout
11875
11876 \end_inset
11877
11878 -dumpdeadcode
11879 \begin_inset LatexCommand index
11880 name "-\\/-dumpdeadcode"
11881
11882 \end_inset
11883
11884
11885 \series default
11886  Will create a dump of iCodes, after deadcode elimination
11887 \begin_inset LatexCommand index
11888 name "Dead-code elimination"
11889
11890 \end_inset
11891
11892 , into a file named 
11893 \emph on
11894 <source filename>.dumpdeadcode.
11895 \end_layout
11896
11897 \begin_layout List
11898 \labelwidthstring 00.00.0000
11899
11900 \series bold
11901 -
11902 \begin_inset ERT
11903 status collapsed
11904
11905 \begin_layout Standard
11906
11907
11908 \backslash
11909 /
11910 \end_layout
11911
11912 \end_inset
11913
11914 -dumploop
11915 \begin_inset LatexCommand index
11916 name "-\\/-dumploop"
11917
11918 \end_inset
11919
11920
11921 \series default
11922 \size large
11923  
11924 \size default
11925 Will create a dump of iCodes, after loop optimizations
11926 \begin_inset LatexCommand index
11927 name "Loop optimization"
11928
11929 \end_inset
11930
11931 , into a file named 
11932 \emph on
11933 <source filename>.dumploop.
11934 \end_layout
11935
11936 \begin_layout List
11937 \labelwidthstring 00.00.0000
11938
11939 \series bold
11940 -
11941 \begin_inset ERT
11942 status collapsed
11943
11944 \begin_layout Standard
11945
11946
11947 \backslash
11948 /
11949 \end_layout
11950
11951 \end_inset
11952
11953 -dumprange
11954 \begin_inset LatexCommand index
11955 name "-\\/-dumprange"
11956
11957 \end_inset
11958
11959
11960 \series default
11961 \size large
11962  
11963 \size default
11964 Will create a dump of iCodes, after live range analysis
11965 \begin_inset LatexCommand index
11966 name "Live range analysis"
11967
11968 \end_inset
11969
11970 , into a file named 
11971 \emph on
11972 <source filename>.dumprange.
11973 \end_layout
11974
11975 \begin_layout List
11976 \labelwidthstring 00.00.0000
11977
11978 \series bold
11979 -
11980 \begin_inset ERT
11981 status collapsed
11982
11983 \begin_layout Standard
11984
11985
11986 \backslash
11987 /
11988 \end_layout
11989
11990 \end_inset
11991
11992 -dumlrange
11993 \begin_inset LatexCommand index
11994 name "-\\/-dumlrange"
11995
11996 \end_inset
11997
11998
11999 \series default
12000  Will dump the life ranges
12001 \begin_inset LatexCommand index
12002 name "Live range analysis"
12003
12004 \end_inset
12005
12006  for all symbols.
12007 \end_layout
12008
12009 \begin_layout List
12010 \labelwidthstring 00.00.0000
12011
12012 \series bold
12013 -
12014 \begin_inset ERT
12015 status collapsed
12016
12017 \begin_layout Standard
12018
12019
12020 \backslash
12021 /
12022 \end_layout
12023
12024 \end_inset
12025
12026 -dumpregassign
12027 \begin_inset LatexCommand index
12028 name "-\\/-dumpregassign"
12029
12030 \end_inset
12031
12032  
12033 \series default
12034 Will create a dump of iCodes, after register assignment
12035 \begin_inset LatexCommand index
12036 name "Register assignment"
12037
12038 \end_inset
12039
12040 , into a file named 
12041 \emph on
12042 <source filename>.dumprassgn.
12043 \end_layout
12044
12045 \begin_layout List
12046 \labelwidthstring 00.00.0000
12047
12048 \series bold
12049 -
12050 \begin_inset ERT
12051 status collapsed
12052
12053 \begin_layout Standard
12054
12055
12056 \backslash
12057 /
12058 \end_layout
12059
12060 \end_inset
12061
12062 -dumplrange
12063 \begin_inset LatexCommand index
12064 name "-\\/-dumplrange"
12065
12066 \end_inset
12067
12068
12069 \series default
12070  Will create a dump of the live ranges of iTemp's
12071 \end_layout
12072
12073 \begin_layout List
12074 \labelwidthstring 00.00.0000
12075
12076 \series bold
12077 -
12078 \begin_inset ERT
12079 status collapsed
12080
12081 \begin_layout Standard
12082
12083
12084 \backslash
12085 /
12086 \end_layout
12087
12088 \end_inset
12089
12090 -dumpall
12091 \begin_inset LatexCommand index
12092 name "-\\/-dumpall"
12093
12094 \end_inset
12095
12096
12097 \size large
12098  
12099 \series default
12100 \size default
12101 Will cause all the above mentioned dumps to be created.
12102 \end_layout
12103
12104 \begin_layout Standard
12105 \begin_inset VSpace bigskip
12106 \end_inset
12107
12108
12109 \end_layout
12110
12111 \begin_layout Subsection
12112 Redirecting output on Windows Shells
12113 \end_layout
12114
12115 \begin_layout Standard
12116 By default SDCC writes its error messages to 
12117 \begin_inset Quotes sld
12118 \end_inset
12119
12120 standard error
12121 \begin_inset Quotes srd
12122 \end_inset
12123
12124 .
12125  To force all messages to 
12126 \begin_inset Quotes sld
12127 \end_inset
12128
12129 standard output
12130 \begin_inset Quotes srd
12131 \end_inset
12132
12133  use 
12134 \series bold
12135 -
12136 \series default
12137 \emph on
12138
12139 \begin_inset ERT
12140 status collapsed
12141
12142 \begin_layout Standard
12143
12144
12145 \backslash
12146 /
12147 \end_layout
12148
12149 \end_inset
12150
12151
12152 \series bold
12153 \emph default
12154 -
12155 \series default
12156 use-stdout
12157 \begin_inset LatexCommand index
12158 name "-\\/-use-stdout"
12159
12160 \end_inset
12161
12162 .
12163  Additionally, if you happen to have visual studio installed in your windows
12164  machine, you can use it to compile your sources using a custom build and
12165  the SDCC -
12166 \emph on
12167
12168 \begin_inset ERT
12169 status collapsed
12170
12171 \begin_layout Standard
12172
12173
12174 \backslash
12175 /
12176 \end_layout
12177
12178 \end_inset
12179
12180
12181 \emph default
12182 -vc
12183 \begin_inset LatexCommand index
12184 name "-\\/-vc"
12185
12186 \end_inset
12187
12188  option.
12189  Something like this should work:
12190 \newline
12191
12192 \newline
12193
12194 \series bold
12195 c:
12196 \backslash
12197 sdcc
12198 \backslash
12199 bin
12200 \backslash
12201 sdcc.exe -
12202 \series default
12203 \emph on
12204
12205 \begin_inset ERT
12206 status collapsed
12207
12208 \begin_layout Standard
12209
12210
12211 \backslash
12212 /
12213 \end_layout
12214
12215 \end_inset
12216
12217
12218 \series bold
12219 \emph default
12220 -vc -
12221 \series default
12222 \emph on
12223
12224 \begin_inset ERT
12225 status collapsed
12226
12227 \begin_layout Standard
12228
12229
12230 \backslash
12231 /
12232 \end_layout
12233
12234 \end_inset
12235
12236
12237 \series bold
12238 \emph default
12239 -model-large -c $(InputPath)
12240 \series default
12241
12242 \begin_inset VSpace bigskip
12243 \end_inset
12244
12245
12246 \end_layout
12247
12248 \begin_layout Section
12249 Environment variables
12250 \begin_inset LatexCommand index
12251 name "Environment variables"
12252
12253 \end_inset
12254
12255
12256 \end_layout
12257
12258 \begin_layout Standard
12259 SDCC recognizes the following environment variables:
12260 \end_layout
12261
12262 \begin_layout List
12263 \labelwidthstring 00.00.0000
12264
12265 \series bold
12266 SDCC_LEAVE_SIGNALS
12267 \begin_inset LatexCommand index
12268 name "SDCC\\_LEAVE\\_SIGNALS"
12269
12270 \end_inset
12271
12272
12273 \series default
12274  SDCC installs a signal handler
12275 \begin_inset LatexCommand index
12276 name "signal handler"
12277
12278 \end_inset
12279
12280  to be able to delete temporary files after an user break (^C) or an exception.
12281  If this environment variable is set, SDCC won't install the signal handler
12282  in order to be able to debug SDCC.
12283 \end_layout
12284
12285 \begin_layout List
12286 \labelwidthstring 00.00.0000
12287
12288 \series bold
12289 TMP,\InsetSpace ~
12290 TEMP,\InsetSpace ~
12291 TMPDIR
12292 \begin_inset LatexCommand index
12293 name "TMP, TEMP, TMPDIR"
12294
12295 \end_inset
12296
12297
12298 \series default
12299  Path, where temporary files will be created.
12300  The order of the variables is the search order.
12301  In a standard *nix environment these variables are not set, and there's
12302  no need to set them.
12303  On Windows it's recommended to set one of them.
12304 \end_layout
12305
12306 \begin_layout List
12307 \labelwidthstring 00.00.0000
12308
12309 \series bold
12310 SDCC_HOME
12311 \begin_inset LatexCommand index
12312 name "SDCC\\_HOME"
12313
12314 \end_inset
12315
12316
12317 \series default
12318  Path, see section 
12319 \begin_inset LatexCommand ref
12320 reference "sub:Install-paths"
12321
12322 \end_inset
12323
12324 \InsetSpace ~
12325
12326 \begin_inset Quotes sld
12327 \end_inset
12328
12329  Install Paths
12330 \begin_inset Quotes srd
12331 \end_inset
12332
12333 .
12334 \end_layout
12335
12336 \begin_layout List
12337 \labelwidthstring 00.00.0000
12338
12339 \series bold
12340 SDCC_INCLUDE
12341 \begin_inset LatexCommand index
12342 name "SDCC\\_INCLUDE"
12343
12344 \end_inset
12345
12346
12347 \series default
12348  Path, see section 
12349 \begin_inset LatexCommand ref
12350 reference "sub:Search-Paths"
12351
12352 \end_inset
12353
12354 \InsetSpace ~
12355
12356 \begin_inset Quotes sld
12357 \end_inset
12358
12359 Search Paths
12360 \begin_inset Quotes srd
12361 \end_inset
12362
12363 .
12364 \end_layout
12365
12366 \begin_layout List
12367 \labelwidthstring 00.00.0000
12368
12369 \series bold
12370 SDCC_LIB
12371 \begin_inset LatexCommand index
12372 name "SDCC\\_LIB"
12373
12374 \end_inset
12375
12376
12377 \series default
12378  Path, see section 
12379 \begin_inset LatexCommand ref
12380 reference "sub:Search-Paths"
12381
12382 \end_inset
12383
12384 \InsetSpace ~
12385
12386 \begin_inset Quotes sld
12387 \end_inset
12388
12389 Search Paths
12390 \begin_inset Quotes srd
12391 \end_inset
12392
12393 ..
12394 \end_layout
12395
12396 \begin_layout Standard
12397 There are some more environment variables recognized by SDCC, but these
12398  are solely used for debugging purposes.
12399  They can change or disappear very quickly, and will never be documented.
12400 \begin_inset VSpace bigskip
12401 \end_inset
12402
12403
12404 \end_layout
12405
12406 \begin_layout Section
12407 Storage Class Language Extensions
12408 \end_layout
12409
12410 \begin_layout Subsection
12411 MCS51/DS390 Storage Class
12412 \begin_inset LatexCommand index
12413 name "Storage class"
12414
12415 \end_inset
12416
12417  Language Extensions
12418 \end_layout
12419
12420 \begin_layout Standard
12421 In addition to the ANSI storage classes SDCC allows the following MCS51
12422  specific storage classes:
12423 \end_layout
12424
12425 \begin_layout Subsubsection
12426 data
12427 \begin_inset LatexCommand index
12428 name "data (mcs51, ds390 storage class)"
12429
12430 \end_inset
12431
12432
12433 \begin_inset LatexCommand index
12434 name "\\_\\_data (mcs51, ds390 storage class)"
12435
12436 \end_inset
12437
12438  / near
12439 \begin_inset LatexCommand index
12440 name "near (storage class)"
12441
12442 \end_inset
12443
12444
12445 \begin_inset LatexCommand index
12446 name "\\_\\_near (storage class)"
12447
12448 \end_inset
12449
12450
12451 \end_layout
12452
12453 \begin_layout Standard
12454 This is the 
12455 \series bold
12456 default
12457 \series default
12458  storage class for the Small Memory model (
12459 \emph on
12460 data
12461 \emph default
12462  and 
12463 \emph on
12464 near
12465 \emph default
12466  or the more ANSI-C compliant forms 
12467 \emph on
12468 __data
12469 \emph default
12470  and 
12471 \emph on
12472 __near
12473 \emph default
12474  can be used synonymously).
12475  Variables declared with this storage class will be allocated in the directly
12476  addressable portion of the internal RAM of a 8051, e.g.:
12477 \end_layout
12478
12479 \begin_layout Verse
12480
12481 \family typewriter
12482 __data unsigned char test_data;
12483 \end_layout
12484
12485 \begin_layout Standard
12486 Writing 0x01 to this variable generates the assembly code:
12487 \end_layout
12488
12489 \begin_layout Verse
12490
12491 \family typewriter
12492 75*00 01\InsetSpace ~
12493 \InsetSpace ~
12494 \InsetSpace ~
12495 mov\InsetSpace ~
12496 \InsetSpace ~
12497 _test_data,#0x01
12498 \end_layout
12499
12500 \begin_layout Subsubsection
12501 xdata
12502 \begin_inset LatexCommand index
12503 name "xdata (mcs51, ds390 storage class)"
12504
12505 \end_inset
12506
12507
12508 \begin_inset LatexCommand index
12509 name "\\_\\_xdata (mcs51, ds390 storage class)"
12510
12511 \end_inset
12512
12513  / far
12514 \begin_inset LatexCommand index
12515 name "far (storage class)"
12516
12517 \end_inset
12518
12519
12520 \begin_inset LatexCommand index
12521 name "\\_\\_far (storage class)"
12522
12523 \end_inset
12524
12525
12526 \end_layout
12527
12528 \begin_layout Standard
12529 Variables declared with this storage class will be placed in the external
12530  RAM.
12531  This is the 
12532 \series bold
12533 default
12534 \series default
12535  storage class for the Large Memory model, e.g.:
12536 \end_layout
12537
12538 \begin_layout Verse
12539
12540 \family typewriter
12541 __xdata unsigned char test_xdata;
12542 \end_layout
12543
12544 \begin_layout Standard
12545 Writing 0x01 to this variable generates the assembly code:
12546 \end_layout
12547
12548 \begin_layout Verse
12549
12550 \family typewriter
12551 90s00r00\InsetSpace ~
12552 \InsetSpace ~
12553 \InsetSpace ~
12554 mov\InsetSpace ~
12555 \InsetSpace ~
12556 dptr,#_test_xdata 
12557 \newline
12558 74\InsetSpace ~
12559 01\InsetSpace ~
12560 \InsetSpace ~
12561 \InsetSpace ~
12562 \InsetSpace ~
12563 \InsetSpace ~
12564 \InsetSpace ~
12565 mov\InsetSpace ~
12566 \InsetSpace ~
12567 a,#0x01 
12568 \newline
12569 F0\InsetSpace ~
12570 \InsetSpace ~
12571 \InsetSpace ~
12572 \InsetSpace ~
12573 \InsetSpace ~
12574 \InsetSpace ~
12575 \InsetSpace ~
12576 \InsetSpace ~
12577 \InsetSpace ~
12578 movx\InsetSpace ~
12579 @dptr,a 
12580 \end_layout
12581
12582 \begin_layout Subsubsection
12583 idata
12584 \begin_inset LatexCommand index
12585 name "idata (mcs51, ds390 storage class)"
12586
12587 \end_inset
12588
12589
12590 \begin_inset LatexCommand index
12591 name "\\_\\_idata (mcs51, ds390 storage class)"
12592
12593 \end_inset
12594
12595
12596 \end_layout
12597
12598 \begin_layout Standard
12599 Variables declared with this storage class will be allocated into the indirectly
12600  addressable portion of the internal ram of a 8051, e.g.:
12601 \end_layout
12602
12603 \begin_layout Verse
12604
12605 \family typewriter
12606 __idata unsigned char test_idata;
12607 \end_layout
12608
12609 \begin_layout Standard
12610 Writing 0x01 to this variable generates the assembly code:
12611 \end_layout
12612
12613 \begin_layout Verse
12614
12615 \family typewriter
12616 78r00\InsetSpace ~
12617 \InsetSpace ~
12618 \InsetSpace ~
12619 \InsetSpace ~
12620 \InsetSpace ~
12621 \InsetSpace ~
12622 \InsetSpace ~
12623 mov\InsetSpace ~
12624 \InsetSpace ~
12625 r0,#_test_idata
12626 \newline
12627 76\InsetSpace ~
12628 01\InsetSpace ~
12629 \InsetSpace ~
12630 \InsetSpace ~
12631 \InsetSpace ~
12632 \InsetSpace ~
12633 \InsetSpace ~
12634 \InsetSpace ~
12635 mov\InsetSpace ~
12636 \InsetSpace ~
12637 @r0,#0x01
12638 \end_layout
12639
12640 \begin_layout Standard
12641 Please note, the first 128 byte of idata physically access the same RAM
12642  as the data memory.
12643  The original 8051 had 128 byte idata memory, nowadays most devices have
12644  256 byte idata memory.
12645  The stack
12646 \begin_inset LatexCommand index
12647 name "stack"
12648
12649 \end_inset
12650
12651  is located in idata memory.
12652 \end_layout
12653
12654 \begin_layout Subsubsection
12655 pdata
12656 \begin_inset LatexCommand index
12657 name "pdata (mcs51, ds390 storage class)"
12658
12659 \end_inset
12660
12661
12662 \begin_inset LatexCommand index
12663 name "\\_\\_pdata (mcs51, ds390 storage class)"
12664
12665 \end_inset
12666
12667
12668 \end_layout
12669
12670 \begin_layout Standard
12671 Paged xdata access is just as straightforward as using the other addressing
12672  modes of a 8051.
12673  It is typically located at the start of xdata and has a maximum size of
12674  256 bytes.
12675  The following example writes 0x01 to the pdata variable.
12676  Please note, pdata access physically accesses xdata memory.
12677  The high byte of the address is determined by port P2 
12678 \begin_inset LatexCommand index
12679 name "P2 (mcs51 sfr)"
12680
12681 \end_inset
12682
12683 (or in case of some 8051 variants by a separate Special Function Register,
12684  see section 
12685 \begin_inset LatexCommand ref
12686 reference "sub:MCS51-variants"
12687
12688 \end_inset
12689
12690 ).
12691  This is the 
12692 \series bold
12693 default
12694 \series default
12695  storage class for the Medium Memory model, e.g.:
12696 \end_layout
12697
12698 \begin_layout Verse
12699
12700 \family typewriter
12701 __pdata unsigned char test_pdata;
12702 \end_layout
12703
12704 \begin_layout Standard
12705 Writing 0x01 to this variable generates the assembly code:
12706 \end_layout
12707
12708 \begin_layout Verse
12709
12710 \family typewriter
12711 78r00\InsetSpace ~
12712 \InsetSpace ~
12713 \InsetSpace ~
12714 \InsetSpace ~
12715 \InsetSpace ~
12716 \InsetSpace ~
12717 mov r0,#_test_pdata
12718 \newline
12719 74 01\InsetSpace ~
12720 \InsetSpace ~
12721 \InsetSpace ~
12722 \InsetSpace ~
12723 \InsetSpace ~
12724 \InsetSpace ~
12725 mov a,#0x01 
12726 \newline
12727 F2\InsetSpace ~
12728 \InsetSpace ~
12729 \InsetSpace ~
12730 \InsetSpace ~
12731 \InsetSpace ~
12732 \InsetSpace ~
12733 \InsetSpace ~
12734 \InsetSpace ~
12735 \InsetSpace ~
12736 movx @r0,a
12737 \end_layout
12738
12739 \begin_layout Standard
12740 If the -
12741 \begin_inset ERT
12742 status collapsed
12743
12744 \begin_layout Standard
12745
12746
12747 \backslash
12748 /
12749 \end_layout
12750
12751 \end_inset
12752
12753 -xstack
12754 \begin_inset LatexCommand index
12755 name "-\\/-xstack"
12756
12757 \end_inset
12758
12759  option is used the pdata memory area is followed by the xstack memory area
12760  and the sum of their sizes is limited to 256 bytes.
12761 \end_layout
12762
12763 \begin_layout Subsubsection
12764 code
12765 \begin_inset LatexCommand index
12766 name "code"
12767
12768 \end_inset
12769
12770
12771 \begin_inset LatexCommand index
12772 name "\\_\\_code"
12773
12774 \end_inset
12775
12776
12777 \end_layout
12778
12779 \begin_layout Standard
12780 'Variables' declared with this storage class will be placed in the code
12781  memory:
12782 \end_layout
12783
12784 \begin_layout Verse
12785
12786 \family typewriter
12787 __code unsigned char test_code;
12788 \end_layout
12789
12790 \begin_layout Standard
12791 Read access to this variable generates the assembly code:
12792 \end_layout
12793
12794 \begin_layout Verse
12795
12796 \family typewriter
12797 90s00r6F\InsetSpace ~
12798 \InsetSpace ~
12799 \InsetSpace ~
12800 mov dptr,#_test_code
12801 \newline
12802 E4\InsetSpace ~
12803 \InsetSpace ~
12804 \InsetSpace ~
12805 \InsetSpace ~
12806 \InsetSpace ~
12807 \InsetSpace ~
12808 \InsetSpace ~
12809 \InsetSpace ~
12810 \InsetSpace ~
12811 clr a
12812 \newline
12813 93\InsetSpace ~
12814 \InsetSpace ~
12815 \InsetSpace ~
12816 \InsetSpace ~
12817 \InsetSpace ~
12818 \InsetSpace ~
12819 \InsetSpace ~
12820 \InsetSpace ~
12821 \InsetSpace ~
12822 movc a,@a+dptr 
12823 \end_layout
12824
12825 \begin_layout Standard
12826
12827 \family typewriter
12828 char
12829 \family default
12830  indexed arrays of characters in code memory can be accessed efficiently:
12831 \end_layout
12832
12833 \begin_layout Verse
12834
12835 \family typewriter
12836 __code char test_array[] = {'c','h','e','a','p'}; 
12837 \end_layout
12838
12839 \begin_layout Standard
12840 Read access to this array using an 8-bit unsigned index generates the assembly
12841  code:
12842 \end_layout
12843
12844 \begin_layout Verse
12845
12846 \family typewriter
12847 E5*00\InsetSpace ~
12848 \InsetSpace ~
12849 \InsetSpace ~
12850 \InsetSpace ~
12851 \InsetSpace ~
12852 \InsetSpace ~
12853 mov a,_index 
12854 \end_layout
12855
12856 \begin_layout Verse
12857
12858 \family typewriter
12859 90s00r41\InsetSpace ~
12860 \InsetSpace ~
12861 \InsetSpace ~
12862 mov dptr,#_test_array
12863 \end_layout
12864
12865 \begin_layout Verse
12866
12867 \family typewriter
12868 93\InsetSpace ~
12869 \InsetSpace ~
12870 \InsetSpace ~
12871 \InsetSpace ~
12872 \InsetSpace ~
12873 \InsetSpace ~
12874 \InsetSpace ~
12875 \InsetSpace ~
12876 \InsetSpace ~
12877 movc a,@a+dptr 
12878 \end_layout
12879
12880 \begin_layout Subsubsection
12881 bit
12882 \begin_inset LatexCommand index
12883 name "bit"
12884
12885 \end_inset
12886
12887
12888 \begin_inset LatexCommand index
12889 name "\\_\\_bit"
12890
12891 \end_inset
12892
12893
12894 \end_layout
12895
12896 \begin_layout Standard
12897 This is a data-type and a storage class specifier.
12898  When a variable is declared as a bit, it is allocated into the bit addressable
12899  memory of 8051, e.g.:
12900 \end_layout
12901
12902 \begin_layout Verse
12903
12904 \family typewriter
12905 __bit test_bit;
12906 \end_layout
12907
12908 \begin_layout Standard
12909 Writing 1 to this variable generates the assembly code:
12910 \end_layout
12911
12912 \begin_layout Verse
12913
12914 \family typewriter
12915 D2*00\InsetSpace ~
12916 \InsetSpace ~
12917 \InsetSpace ~
12918 \InsetSpace ~
12919 \InsetSpace ~
12920 \InsetSpace ~
12921 \InsetSpace ~
12922 setb\InsetSpace ~
12923 _test_bit
12924 \end_layout
12925
12926 \begin_layout Standard
12927 The bit addressable memory consists of 128 bits which are located from 0x20
12928  to 0x2f in data memory.
12929  
12930 \newline
12931 Apart from this 8051 specific storage class most architectures support
12932  ANSI-C bitfields
12933 \begin_inset LatexCommand index
12934 name "bitfields"
12935
12936 \end_inset
12937
12938
12939 \begin_inset Foot
12940 status open
12941
12942 \begin_layout Standard
12943 Not really meant as examples, but nevertheless showing what bitfields are
12944  about: device/include/mc68hc908qy.h and support/regression/tests/bitfields.c
12945 \end_layout
12946
12947 \end_inset
12948
12949 .
12950  In accordance with ISO/IEC 9899 bits and bitfields without an explicit
12951  signed modifier are implemented as unsigned.
12952 \end_layout
12953
12954 \begin_layout Subsubsection
12955 sfr
12956 \begin_inset LatexCommand index
12957 name "sfr"
12958
12959 \end_inset
12960
12961
12962 \begin_inset LatexCommand index
12963 name "\\_\\_sfr"
12964
12965 \end_inset
12966
12967  / sfr16
12968 \begin_inset LatexCommand index
12969 name "sfr16"
12970
12971 \end_inset
12972
12973
12974 \begin_inset LatexCommand index
12975 name "\\_\\_sfr16"
12976
12977 \end_inset
12978
12979  / sfr32
12980 \begin_inset LatexCommand index
12981 name "sfr32"
12982
12983 \end_inset
12984
12985
12986 \begin_inset LatexCommand index
12987 name "\\_\\_sfr32"
12988
12989 \end_inset
12990
12991  / sbit
12992 \begin_inset LatexCommand index
12993 name "\\_\\_sbit"
12994
12995 \end_inset
12996
12997
12998 \begin_inset LatexCommand index
12999 name "sbit"
13000
13001 \end_inset
13002
13003
13004 \end_layout
13005
13006 \begin_layout Standard
13007 Like the bit keyword, 
13008 \emph on
13009 sfr / sfr16 / sfr32 / sbit
13010 \emph default
13011  signify both a data-type and storage class, they are used to describe the
13012  
13013 \emph on
13014 s
13015 \emph default
13016 pecial 
13017 \emph on
13018 f
13019 \emph default
13020 unction 
13021 \emph on
13022 r
13023 \emph default
13024 egisters and 
13025 \emph on
13026 s
13027 \emph default
13028 pecial 
13029 \emph on
13030 bit
13031 \emph default
13032  variables of a 8051, eg:
13033 \end_layout
13034
13035 \begin_layout Verse
13036
13037 \family typewriter
13038 __sfr __at
13039 \begin_inset LatexCommand index
13040 name "at"
13041
13042 \end_inset
13043
13044
13045 \begin_inset LatexCommand index
13046 name "\\_\\_at"
13047
13048 \end_inset
13049
13050  (0x80) P0;\InsetSpace ~
13051  /* special function register P0 at location 0x80 */
13052 \newline
13053
13054 \newline
13055 /* 16 bit
13056  special function register combination for timer 0
13057 \newline
13058 \InsetSpace ~
13059 \InsetSpace ~
13060  with the high byte at
13061  location 0x8C and the low byte at location 0x8A */
13062 \newline
13063 __sfr16 __at (0x8C8A)
13064  TMR0;
13065 \newline
13066
13067 \newline
13068 __sbit __at
13069 \begin_inset LatexCommand index
13070 name "at"
13071
13072 \end_inset
13073
13074
13075 \begin_inset LatexCommand index
13076 name "\\_\\_at"
13077
13078 \end_inset
13079
13080  (0xd7) CY;\InsetSpace ~
13081  /* CY (Carry Flag
13082 \begin_inset LatexCommand index
13083 name "Flags"
13084
13085 \end_inset
13086
13087
13088 \begin_inset LatexCommand index
13089 name "Carry flag"
13090
13091 \end_inset
13092
13093 ) */
13094 \end_layout
13095
13096 \begin_layout Standard
13097 Special function registers which are located on an address dividable by
13098  8 are bit-addressable, an 
13099 \emph on
13100 sbit
13101 \emph default
13102  addresses a specific bit within these sfr.
13103 \newline
13104 16 Bit and 32 bit special function
13105  register combinations which require a certain access order are better not
13106  declared using 
13107 \emph on
13108 sfr16
13109 \emph default
13110  or 
13111 \emph on
13112 sfr32.
13113
13114 \emph default
13115  Allthough SDCC usually accesses them Least Significant Byte (LSB) first,
13116  this is not guaranteed.
13117 \newline
13118
13119 \end_layout
13120
13121 \begin_layout Standard
13122 Please note, if you use a header file which was written for another compiler
13123  then the sfr / sfr16 / sfr32 / sbit Storage Class extensions will most
13124  likely be 
13125 \emph on
13126 not
13127 \emph default
13128  compatible.
13129  Specifically the syntax 
13130 \family typewriter
13131 \InsetSpace ~
13132 sfr P0 = 0x80;\InsetSpace ~
13133
13134 \family default
13135  is compiled 
13136 \emph on
13137 without warning
13138 \emph default
13139  by SDCC to an assignment of 0x80 to a variable called P0 
13140 \family typewriter
13141
13142 \begin_inset Marginal
13143 status collapsed
13144
13145 \begin_layout Standard
13146
13147 \series bold
13148 \InsetSpace ~
13149 !
13150 \end_layout
13151
13152 \end_inset
13153
13154 .
13155
13156 \family default
13157  
13158 \series bold
13159 Nevertheless it is possible to write header files
13160 \begin_inset LatexCommand index
13161 name "Header files"
13162
13163 \end_inset
13164
13165
13166 \begin_inset LatexCommand index
13167 name "Include files"
13168
13169 \end_inset
13170
13171  which can be shared among different compilers (see section 
13172 \begin_inset LatexCommand ref
13173 reference "sec:Porting-code-to-other-compilers"
13174
13175 \end_inset
13176
13177 ).
13178  
13179 \end_layout
13180
13181 \begin_layout Subsubsection
13182 Pointers
13183 \begin_inset LatexCommand index
13184 name "Pointer"
13185
13186 \end_inset
13187
13188  to MCS51/DS390 specific memory spaces
13189 \end_layout
13190
13191 \begin_layout Standard
13192 SDCC allows (via language extensions) pointers to explicitly point to any
13193  of the memory spaces
13194 \begin_inset LatexCommand index
13195 name "Memory model"
13196
13197 \end_inset
13198
13199  of the 8051.
13200  In addition to the explicit pointers, the compiler uses (by default) generic
13201  pointers which can be used to point to any of the memory spaces.
13202 \newline
13203
13204 \newline
13205 Pointer
13206  declaration examples:
13207 \end_layout
13208
13209 \begin_layout Verse
13210
13211 \family typewriter
13212 /* pointer physically in internal ram pointing to object in external ram
13213  */ 
13214 \newline
13215 __xdata unsigned char * __data p;
13216 \newline
13217
13218 \newline
13219 /* pointer physically in external ram
13220  pointing to object in internal ram */ 
13221 \newline
13222 __data unsigned char * __xdata p;
13223 \newline
13224
13225 \newline
13226 /*
13227  pointer physically in code rom pointing to data in xdata space */ 
13228 \newline
13229 __xdata
13230  unsigned char * __code p;
13231 \newline
13232
13233 \newline
13234 /* pointer physically in code space pointing to
13235  data in code space */ 
13236 \newline
13237 __code unsigned char * __code p;
13238 \newline
13239
13240 \newline
13241 /* generic pointer
13242  physically located in xdata space */
13243 \newline
13244 unsigned char * __xdata p;
13245 \newline
13246
13247 \newline
13248 /* generic
13249  pointer physically located in default memory space */
13250 \newline
13251 unsigned char * p;
13252 \newline
13253
13254 \newline
13255 /*
13256  the following is a function pointer
13257 \begin_inset LatexCommand index
13258 name "function pointer"
13259
13260 \end_inset
13261
13262  physically located in data space */
13263 \newline
13264 char (* __data fp)(void);
13265 \end_layout
13266
13267 \begin_layout Standard
13268 Well you get the idea.
13269  
13270 \newline
13271
13272 \newline
13273 All unqualified pointers are treated as 3-byte (4-byte for the ds390) 
13274 \emph on
13275 generic
13276 \emph default
13277  pointers.
13278  
13279 \size small
13280
13281 \newline
13282
13283 \newline
13284
13285 \size default
13286 The highest order byte of the 
13287 \emph on
13288 generic
13289 \emph default
13290  pointers contains the data space information.
13291  Assembler support routines are called whenever data is stored or retrieved
13292  using 
13293 \emph on
13294 generic
13295 \emph default
13296  pointers.
13297  These are useful for developing reusable library
13298 \begin_inset LatexCommand index
13299 name "Libraries"
13300
13301 \end_inset
13302
13303  routines.
13304  Explicitly specifying the pointer
13305 \begin_inset LatexCommand index
13306 name "pointer"
13307
13308 \end_inset
13309
13310  type will generate the most efficient code.
13311 \end_layout
13312
13313 \begin_layout Subsubsection
13314 Notes on MCS51 memory
13315 \begin_inset LatexCommand index
13316 name "MCS51 memory"
13317
13318 \end_inset
13319
13320  layout
13321 \end_layout
13322
13323 \begin_layout Standard
13324 The 8051 family of microcontrollers have a minimum of 128 bytes of internal
13325  RAM memory which is structured as follows:
13326 \newline
13327
13328 \newline
13329 - Bytes 00-1F - 32 bytes to hold
13330  up to 4 banks of the registers R0 to R7, 
13331 \newline
13332 - Bytes 20-2F - 16 bytes to hold
13333  128 bit
13334 \begin_inset LatexCommand index
13335 name "bit"
13336
13337 \end_inset
13338
13339  variables and, 
13340 \newline
13341 - Bytes 30-7F - 80 bytes for general purpose use.
13342 \newline
13343
13344 \end_layout
13345
13346 \begin_layout Standard
13347 Additionally some members of the MCS51 family may have up to 128 bytes of
13348  additional, indirectly addressable, internal RAM memory (
13349 \emph on
13350 idata
13351 \emph default
13352
13353 \begin_inset LatexCommand index
13354 name "idata (mcs51, ds390 storage class)"
13355
13356 \end_inset
13357
13358
13359 \begin_inset LatexCommand index
13360 name "\\_\\_idata (mcs51, ds390 storage class)"
13361
13362 \end_inset
13363
13364 ).
13365  Furthermore, some chips may have some built in external memory (
13366 \emph on
13367 xdata
13368 \emph default
13369
13370 \begin_inset LatexCommand index
13371 name "xdata (mcs51, ds390 storage class)"
13372
13373 \end_inset
13374
13375
13376 \begin_inset LatexCommand index
13377 name "\\_\\_xdata (mcs51, ds390 storage class)"
13378
13379 \end_inset
13380
13381 ) which should not be confused with the internal, directly addressable RAM
13382  memory (
13383 \emph on
13384 data
13385 \emph default
13386
13387 \begin_inset LatexCommand index
13388 name "data (mcs51, ds390 storage class)"
13389
13390 \end_inset
13391
13392
13393 \begin_inset LatexCommand index
13394 name "\\_\\_data (mcs51, ds390 storage class)"
13395
13396 \end_inset
13397
13398 ).
13399  Sometimes this built in 
13400 \emph on
13401 xdata
13402 \emph default
13403  memory has to be activated before using it (you can probably find this
13404  information on the datasheet of the microcontroller your are using, see
13405  also section 
13406 \begin_inset LatexCommand ref
13407 reference "sub:Startup-Code"
13408
13409 \end_inset
13410
13411 \InsetSpace ~
13412 Startup-Code).
13413 \end_layout
13414
13415 \begin_layout Standard
13416 Normally SDCC will only use the first bank
13417 \begin_inset LatexCommand index
13418 name "register bank (mcs51, ds390)"
13419
13420 \end_inset
13421
13422  of registers (register bank 0), but it is possible to specify that other
13423  banks of registers (keyword 
13424 \emph on
13425 using
13426 \emph default
13427  
13428 \emph on
13429
13430 \begin_inset LatexCommand index
13431 name "using (mcs51, ds390 register bank)"
13432
13433 \end_inset
13434
13435
13436 \begin_inset LatexCommand index
13437 name "\\_\\_using (mcs51, ds390 register bank)"
13438
13439 \end_inset
13440
13441
13442 \emph default
13443 ) should be used for example in interrupt
13444 \begin_inset LatexCommand index
13445 name "interrupt"
13446
13447 \end_inset
13448
13449
13450 \begin_inset LatexCommand index
13451 name "\\_\\_interrupt"
13452
13453 \end_inset
13454
13455  routines.
13456  By default, the compiler will place the stack after the last byte of allocated
13457  memory for variables.
13458  For example, if the first 2 banks of registers are used, and only four
13459  bytes are used for 
13460 \emph on
13461 data
13462 \emph default
13463  variables, it will position the base of the internal stack at address 20
13464  (0x14).
13465  This implies that as the stack
13466 \begin_inset LatexCommand index
13467 name "stack"
13468
13469 \end_inset
13470
13471  grows, it will use up the remaining register banks, and the 16 bytes used
13472  by the 128 bit variables, and 80 bytes for general purpose use.
13473  If any bit variables are used, the data variables will be placed in unused
13474  register banks and after the byte holding the last bit variable.
13475  For example, if register banks 0 and 1 are used, and there are 9 bit variables
13476  (two bytes used), 
13477 \emph on
13478 data
13479 \emph default
13480  variables will be placed starting from address 0x10 to 0x20 and continue
13481  at address 0x22.
13482  You can also use -
13483 \begin_inset ERT
13484 status collapsed
13485
13486 \begin_layout Standard
13487
13488
13489 \backslash
13490 /
13491 \end_layout
13492
13493 \end_inset
13494
13495 -data-loc
13496 \begin_inset LatexCommand index
13497 name "-\\/-data-loc <Value>"
13498
13499 \end_inset
13500
13501  to specify the start address of the 
13502 \emph on
13503 data
13504 \emph default
13505  and -
13506 \begin_inset ERT
13507 status collapsed
13508
13509 \begin_layout Standard
13510
13511
13512 \backslash
13513 /
13514 \end_layout
13515
13516 \end_inset
13517
13518 -iram-size
13519 \begin_inset LatexCommand index
13520 name "-\\/-iram-size <Value>"
13521
13522 \end_inset
13523
13524  to specify the size of the total internal RAM (
13525 \emph on
13526 data
13527 \emph default
13528 +
13529 \emph on
13530 idata
13531 \emph default
13532 ).
13533  
13534 \newline
13535
13536 \end_layout
13537
13538 \begin_layout Standard
13539 By default the 8051 linker will place the stack after the last byte of (i)data
13540  variables.
13541  Option -
13542 \begin_inset ERT
13543 status collapsed
13544
13545 \begin_layout Standard
13546
13547
13548 \backslash
13549 /
13550 \end_layout
13551
13552 \end_inset
13553
13554 -stack-loc
13555 \begin_inset LatexCommand index
13556 name "-\\/-stack-loc <Value>"
13557
13558 \end_inset
13559
13560  allows you to specify the start of the stack, i.e.
13561  you could start it after any data in the general purpose area.
13562  If your microcontroller has additional indirectly addressable internal
13563  RAM (
13564 \emph on
13565 idata
13566 \emph default
13567 ) you can place the stack on it.
13568  You may also need to use -
13569 \begin_inset ERT
13570 status collapsed
13571
13572 \begin_layout Standard
13573
13574
13575 \backslash
13576 /
13577 \end_layout
13578
13579 \end_inset
13580
13581 -xdata-loc
13582 \begin_inset LatexCommand index
13583 name "-\\/-xdata-loc<Value>"
13584
13585 \end_inset
13586
13587  to set the start address of the external RAM (
13588 \emph on
13589 xdata
13590 \emph default
13591 ) and -
13592 \begin_inset ERT
13593 status collapsed
13594
13595 \begin_layout Standard
13596
13597
13598 \backslash
13599 /
13600 \end_layout
13601
13602 \end_inset
13603
13604 -xram-size
13605 \begin_inset LatexCommand index
13606 name "-\\/-xram-size <Value>"
13607
13608 \end_inset
13609
13610  to specify its size.
13611  Same goes for the code memory, using -
13612 \begin_inset ERT
13613 status collapsed
13614
13615 \begin_layout Standard
13616
13617
13618 \backslash
13619 /
13620 \end_layout
13621
13622 \end_inset
13623
13624 -code-loc
13625 \begin_inset LatexCommand index
13626 name "-\\/-code-loc <Value>"
13627
13628 \end_inset
13629
13630  and -
13631 \begin_inset ERT
13632 status collapsed
13633
13634 \begin_layout Standard
13635
13636
13637 \backslash
13638 /
13639 \end_layout
13640
13641 \end_inset
13642
13643 -code-size
13644 \begin_inset LatexCommand index
13645 name "-\\/-code-size <Value>"
13646
13647 \end_inset
13648
13649 .
13650  If in doubt, don't specify any options and see if the resulting memory
13651  layout is appropriate, then you can adjust it.
13652 \end_layout
13653
13654 \begin_layout Standard
13655 The linker generates two files with memory allocation information.
13656  The first, with extension .map
13657 \begin_inset LatexCommand index
13658 name "<file>.map"
13659
13660 \end_inset
13661
13662  shows all the variables and segments.
13663  The second with extension .mem
13664 \begin_inset LatexCommand index
13665 name "<file>.mem"
13666
13667 \end_inset
13668
13669  shows the final memory layout.
13670  The linker will complain either if memory segments overlap, there is not
13671  enough memory, or there is not enough space for stack.
13672  If you get any linking warnings and/or errors related to stack or segments
13673  allocation, take a look at either the .map or .mem files to find out what
13674  the problem is.
13675  The .mem file may even suggest a solution to the problem.
13676 \begin_inset VSpace bigskip
13677 \end_inset
13678
13679
13680 \end_layout
13681
13682 \begin_layout Subsection
13683 Z80/Z180 Storage Class
13684 \begin_inset LatexCommand index
13685 name "Z80!Storage class"
13686
13687 \end_inset
13688
13689  Language Extensions
13690 \end_layout
13691
13692 \begin_layout Subsubsection
13693 sfr
13694 \begin_inset LatexCommand index
13695 name "sfr"
13696
13697 \end_inset
13698
13699
13700 \begin_inset LatexCommand index
13701 name "\\_\\_sfr"
13702
13703 \end_inset
13704
13705  (in/out to 8-bit addresses)
13706 \end_layout
13707
13708 \begin_layout Standard
13709 The Z80
13710 \begin_inset LatexCommand index
13711 name "Z80"
13712
13713 \end_inset
13714
13715  family has separate address spaces for memory and 
13716 \emph on
13717 i
13718 \emph default
13719 nput/
13720 \emph on
13721 o
13722 \emph default
13723 utput memory.
13724  I/O memory
13725 \begin_inset LatexCommand index
13726 name "I/O memory (Z80, Z180)"
13727
13728 \end_inset
13729
13730
13731 \begin_inset LatexCommand index
13732 name "Z80!I/O memory"
13733
13734 \end_inset
13735
13736
13737 \begin_inset LatexCommand index
13738 name "Z180!I/O memory"
13739
13740 \end_inset
13741
13742  is accessed with special instructions, e.g.:
13743 \end_layout
13744
13745 \begin_layout Verse
13746
13747 \family typewriter
13748 sfr at 0x78 IoPort;\InsetSpace ~
13749 \InsetSpace ~
13750 /* define a var in I/O space at 78h called IoPort */
13751  
13752 \end_layout
13753
13754 \begin_layout Standard
13755 Writing 0x01 to this variable generates the assembly code:
13756 \end_layout
13757
13758 \begin_layout Verse
13759
13760 \family typewriter
13761 3E 01\InsetSpace ~
13762 \InsetSpace ~
13763 \InsetSpace ~
13764 \InsetSpace ~
13765 \InsetSpace ~
13766 \InsetSpace ~
13767 ld a,#0x01
13768 \newline
13769 D3 78\InsetSpace ~
13770 \InsetSpace ~
13771 \InsetSpace ~
13772 \InsetSpace ~
13773 \InsetSpace ~
13774 \InsetSpace ~
13775 out (_IoPort),a 
13776 \end_layout
13777
13778 \begin_layout Subsubsection
13779 banked sfr
13780 \begin_inset LatexCommand index
13781 name "sfr"
13782
13783 \end_inset
13784
13785
13786 \begin_inset LatexCommand index
13787 name "\\_\\_sfr"
13788
13789 \end_inset
13790
13791  (in/out to 16-bit addresses)
13792 \end_layout
13793
13794 \begin_layout Standard
13795 The keyword 
13796 \emph on
13797 banked
13798 \emph default
13799  is used to support 16 bit addresses in I/O memory e.g.:
13800 \end_layout
13801
13802 \begin_layout Verse
13803
13804 \family typewriter
13805 sfr banked at
13806 \begin_inset LatexCommand index
13807 name "at"
13808
13809 \end_inset
13810
13811
13812 \begin_inset LatexCommand index
13813 name "\\_\\_at"
13814
13815 \end_inset
13816
13817  0x123 IoPort; 
13818 \end_layout
13819
13820 \begin_layout Standard
13821 Writing 0x01 to this variable generates the assembly code:
13822 \end_layout
13823
13824 \begin_layout Verse
13825
13826 \family typewriter
13827 01 23 01\InsetSpace ~
13828 \InsetSpace ~
13829 \InsetSpace ~
13830 ld bc,#_IoPort
13831 \newline
13832 3E 01\InsetSpace ~
13833 \InsetSpace ~
13834 \InsetSpace ~
13835 \InsetSpace ~
13836 \InsetSpace ~
13837 \InsetSpace ~
13838 ld a,#0x01 
13839 \newline
13840 ED 79\InsetSpace ~
13841 \InsetSpace ~
13842 \InsetSpace ~
13843 \InsetSpace ~
13844 \InsetSpace ~
13845 \InsetSpace ~
13846 out (c),a 
13847 \end_layout
13848
13849 \begin_layout Subsubsection
13850 sfr
13851 \begin_inset LatexCommand index
13852 name "sfr"
13853
13854 \end_inset
13855
13856
13857 \begin_inset LatexCommand index
13858 name "\\_\\_sfr"
13859
13860 \end_inset
13861
13862  (in0/out0 to 8 bit addresses on Z180
13863 \begin_inset LatexCommand index
13864 name "Z180"
13865
13866 \end_inset
13867
13868 /HD64180
13869 \begin_inset LatexCommand index
13870 name "HD64180 (see Z180)"
13871
13872 \end_inset
13873
13874 )
13875 \end_layout
13876
13877 \begin_layout Standard
13878 The compiler option -
13879 \begin_inset ERT
13880 status collapsed
13881
13882 \begin_layout Standard
13883
13884
13885 \backslash
13886 /
13887 \end_layout
13888
13889 \end_inset
13890
13891 -portmode
13892 \begin_inset LatexCommand index
13893 name "Z180!Options!-\\/-portmode"
13894
13895 \end_inset
13896
13897 =180 (80) and a compiler #pragma\InsetSpace ~
13898 portmode
13899 \begin_inset LatexCommand index
13900 name "Z180!Pragmas!\\#pragma portmode"
13901
13902 \end_inset
13903
13904  z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructio
13905 ns 
13906 \family typewriter
13907 in0/out0
13908 \family default
13909  instead of 
13910 \family typewriter
13911 in/out
13912 \family default
13913 .
13914  If you include the file z180.h this will be set automatically.
13915 \begin_inset VSpace bigskip
13916 \end_inset
13917
13918
13919 \end_layout
13920
13921 \begin_layout Subsection
13922 HC08 Storage Class
13923 \begin_inset LatexCommand index
13924 name "HC08!Storage class"
13925
13926 \end_inset
13927
13928  Language Extensions
13929 \end_layout
13930
13931 \begin_layout Subsubsection
13932 data
13933 \begin_inset LatexCommand index
13934 name "data (hc08 storage class)"
13935
13936 \end_inset
13937
13938
13939 \begin_inset LatexCommand index
13940 name "\\_\\_data (hc08 storage class)"
13941
13942 \end_inset
13943
13944  
13945 \end_layout
13946
13947 \begin_layout Standard
13948 The data storage class declares a variable that resides in the first 256
13949  bytes of memory (the direct page).
13950  The HC08
13951 \begin_inset LatexCommand index
13952 name "HC08"
13953
13954 \end_inset
13955
13956  is most efficient at accessing variables (especially pointers) stored here.
13957 \end_layout
13958
13959 \begin_layout Subsubsection
13960 xdata
13961 \begin_inset LatexCommand index
13962 name "xdata (hc08 storage class)"
13963
13964 \end_inset
13965
13966
13967 \begin_inset LatexCommand index
13968 name "\\_\\_xdata (hc08 storage class)"
13969
13970 \end_inset
13971
13972  
13973 \end_layout
13974
13975 \begin_layout Standard
13976 The xdata storage class declares a variable that can reside anywhere in
13977  memory.
13978  This is the default if no storage class is specified.
13979  
13980 \begin_inset VSpace bigskip
13981 \end_inset
13982
13983
13984 \end_layout
13985
13986 \begin_layout Section
13987 Other SDCC language extensions
13988 \begin_inset LatexCommand index
13989 name "Other SDCC language extensions"
13990
13991 \end_inset
13992
13993
13994 \end_layout
13995
13996 \begin_layout Subsection
13997 Binary constants
13998 \end_layout
13999
14000 \begin_layout Standard
14001 SDCC supports the use of binary constants, such as 0b01100010.
14002  This feature is only enabled when the compiler is invoked using --std-sdccxx.
14003 \end_layout
14004
14005 \begin_layout Standard
14006 \begin_inset VSpace bigskip
14007 \end_inset
14008
14009
14010 \end_layout
14011
14012 \begin_layout Section
14013 Absolute Addressing
14014 \begin_inset LatexCommand index
14015 name "Absolute addressing"
14016
14017 \end_inset
14018
14019
14020 \end_layout
14021
14022 \begin_layout Standard
14023 Data items can be assigned an absolute address with the 
14024 \emph on
14025 at
14026 \begin_inset LatexCommand index
14027 name "at"
14028
14029 \end_inset
14030
14031
14032 \begin_inset LatexCommand index
14033 name "\\_\\_at"
14034
14035 \end_inset
14036
14037  <address>
14038 \emph default
14039  keyword, in addition to a storage class, e.g.:
14040 \end_layout
14041
14042 \begin_layout Verse
14043
14044 \family typewriter
14045 xdata
14046 \begin_inset LatexCommand index
14047 name "xdata (mcs51, ds390 storage class)"
14048
14049 \end_inset
14050
14051
14052 \begin_inset LatexCommand index
14053 name "\\_\\_xdata (mcs51, ds390 storage class)"
14054
14055 \end_inset
14056
14057  at
14058 \begin_inset LatexCommand index
14059 name "at"
14060
14061 \end_inset
14062
14063
14064 \begin_inset LatexCommand index
14065 name "\\_\\_at"
14066
14067 \end_inset
14068
14069  0x7ffe unsigned int chksum;
14070 \end_layout
14071
14072 \begin_layout Standard
14073 or, better conforming to ISO/IEC 9899 C:
14074 \end_layout
14075
14076 \begin_layout Verse
14077
14078 \family typewriter
14079 __xdata __at (0x7ffe) unsigned int chksum;
14080 \end_layout
14081
14082 \begin_layout Standard
14083 In the above example the variable chksum will be located at 0x7ffe and 0x7fff
14084  of the external ram.
14085  The compiler does 
14086 \emph on
14087 not
14088 \emph default
14089  reserve any space for variables declared in this way
14090 \begin_inset Marginal
14091 status collapsed
14092
14093 \begin_layout Standard
14094
14095 \series bold
14096 \InsetSpace ~
14097 !
14098 \end_layout
14099
14100 \end_inset
14101
14102  (they are implemented with an equate in the assembler).
14103  Thus it is left to the programmer to make sure there are no overlaps with
14104  other variables that are declared without the absolute address.
14105  The assembler listing file (.lst
14106 \begin_inset LatexCommand index
14107 name "<file>.lst"
14108
14109 \end_inset
14110
14111 ) and the linker output files (.rst
14112 \begin_inset LatexCommand index
14113 name "<file>.rst"
14114
14115 \end_inset
14116
14117 ) and (.map
14118 \begin_inset LatexCommand index
14119 name "<file>.map"
14120
14121 \end_inset
14122
14123 ) are good places to look for such overlaps.
14124 \end_layout
14125
14126 \begin_layout Standard
14127 If however you provide an initializer
14128 \begin_inset LatexCommand index
14129 name "Variable initialization"
14130
14131 \end_inset
14132
14133  actual memory allocation will take place and overlaps will be detected
14134  by the linker.
14135  E.g.:
14136 \end_layout
14137
14138 \begin_layout Verse
14139
14140 \family typewriter
14141 __code __at (0x7ff0) char Id[5] = 
14142 \begin_inset Quotes sld
14143 \end_inset
14144
14145 SDCC
14146 \begin_inset Quotes srd
14147 \end_inset
14148
14149 ;
14150 \end_layout
14151
14152 \begin_layout Standard
14153 In the above example the variable Id will be located from 0x7ff0 to 0x7ff4
14154  in code memory.
14155 \end_layout
14156
14157 \begin_layout Standard
14158 In case of memory mapped I/O devices the keyword 
14159 \emph on
14160 volatile
14161 \emph default
14162  has to be used to tell the compiler that accesses might not be removed:
14163 \end_layout
14164
14165 \begin_layout Verse
14166
14167 \family typewriter
14168 volatile
14169 \begin_inset LatexCommand index
14170 name "volatile"
14171
14172 \end_inset
14173
14174  __xdata
14175 \begin_inset LatexCommand index
14176 name "xdata (mcs51, ds390 storage class)"
14177
14178 \end_inset
14179
14180  __at
14181 \begin_inset LatexCommand index
14182 name "at"
14183
14184 \end_inset
14185
14186  (0x8000) unsigned char PORTA_8255;
14187 \end_layout
14188
14189 \begin_layout Standard
14190 For some architectures (mcs51) array accesses are more efficient if an (xdata/fa
14191 r) array
14192 \family typewriter
14193 \size footnotesize
14194
14195 \begin_inset LatexCommand index
14196 name "Aligned array"
14197
14198 \end_inset
14199
14200
14201 \family default
14202 \size default
14203  starts at a block (256 byte) boundary
14204 \begin_inset LatexCommand index
14205 name "block boundary"
14206
14207 \end_inset
14208
14209  (section 
14210 \begin_inset LatexCommand ref
14211 reference "sub:A-Step-by Assembler Introduction"
14212
14213 \end_inset
14214
14215  has an example).
14216 \newline
14217 Absolute addresses can be specified for variables in all
14218  storage classes, e.g.:
14219 \end_layout
14220
14221 \begin_layout Verse
14222
14223 \family typewriter
14224 __bit
14225 \begin_inset LatexCommand index
14226 name "bit"
14227
14228 \end_inset
14229
14230  __at
14231 \begin_inset LatexCommand index
14232 name "at"
14233
14234 \end_inset
14235
14236  (0x02) bvar;
14237 \end_layout
14238
14239 \begin_layout Standard
14240 The above example will allocate the variable at offset 0x02 in the bit-addressab
14241 le space.
14242  There is no real advantage to assigning absolute addresses to variables
14243  in this manner, unless you want strict control over all the variables allocated.
14244  One possible use would be to write hardware portable code.
14245  For example, if you have a routine that uses one or more of the microcontroller
14246  I/O pins, and such pins are different for two different hardwares, you
14247  can declare the I/O pins in your routine using:
14248 \end_layout
14249
14250 \begin_layout Verse
14251
14252 \family typewriter
14253 extern volatile
14254 \begin_inset LatexCommand index
14255 name "volatile"
14256
14257 \end_inset
14258
14259  __bit MOSI;\InsetSpace ~
14260 \InsetSpace ~
14261 \InsetSpace ~
14262 \InsetSpace ~
14263 /* master out, slave in */
14264 \newline
14265 extern volatile __bit MISO;\InsetSpace ~
14266 \InsetSpace ~
14267 \InsetSpace ~
14268 \InsetSpace ~
14269 /* master
14270  in, slave out */
14271 \newline
14272 extern volatile __bit MCLK;\InsetSpace ~
14273 \InsetSpace ~
14274 \InsetSpace ~
14275 \InsetSpace ~
14276 /* master clock */
14277 \newline
14278
14279 \newline
14280 /* Input and
14281  Output of a byte on a 3-wire serial bus.
14282 \newline
14283 \InsetSpace ~
14284 \InsetSpace ~
14285 \InsetSpace ~
14286 If needed adapt polarity of clock,
14287  polarity of data and bit order
14288 \newline
14289 \InsetSpace ~
14290 */
14291 \newline
14292 unsigned char spi_io(unsigned char out_byte)
14293  
14294 \newline
14295
14296 \newline
14297 \InsetSpace ~
14298 \InsetSpace ~
14299 \InsetSpace ~
14300 \InsetSpace ~
14301 unsigned char i=8;
14302 \newline
14303 \InsetSpace ~
14304 \InsetSpace ~
14305 \InsetSpace ~
14306 \InsetSpace ~
14307 do { 
14308 \newline
14309 \InsetSpace ~
14310 \InsetSpace ~
14311 \InsetSpace ~
14312 \InsetSpace ~
14313 \InsetSpace ~
14314 \InsetSpace ~
14315 \InsetSpace ~
14316 \InsetSpace ~
14317 MOSI = out_byte & 0x80; 
14318 \newline
14319 \InsetSpace ~
14320 \InsetSpace ~
14321 \InsetSpace ~
14322 \InsetSpace ~
14323 \InsetSpace ~
14324 \InsetSpace ~
14325 \InsetSpace ~
14326 \InsetSpace ~
14327 out_byte <<= 1;
14328 \newline
14329 \InsetSpace ~
14330 \InsetSpace ~
14331 \InsetSpace ~
14332 \InsetSpace ~
14333 \InsetSpace ~
14334 \InsetSpace ~
14335 \InsetSpace ~
14336 \InsetSpace ~
14337 MCLK =
14338  1; 
14339 \newline
14340 \InsetSpace ~
14341 \InsetSpace ~
14342 \InsetSpace ~
14343 \InsetSpace ~
14344 \InsetSpace ~
14345 \InsetSpace ~
14346 \InsetSpace ~
14347 \InsetSpace ~
14348 /* _asm nop _endasm; */\InsetSpace ~
14349 \InsetSpace ~
14350 \InsetSpace ~
14351 \InsetSpace ~
14352 \InsetSpace ~
14353 \InsetSpace ~
14354 \InsetSpace ~
14355 \InsetSpace ~
14356 /* for slow peripherals */
14357 \newline
14358 \InsetSpace ~
14359 \InsetSpace ~
14360 \InsetSpace ~
14361 \InsetSpace ~
14362 \InsetSpace ~
14363 \InsetSpace ~
14364 \InsetSpace ~
14365 \InsetSpace ~
14366 if(MISO) 
14367 \newline
14368 \InsetSpace ~
14369 \InsetSpace ~
14370 \InsetSpace ~
14371 \InsetSpace ~
14372 \InsetSpace ~
14373 \InsetSpace ~
14374 \InsetSpace ~
14375 \InsetSpace ~
14376 \InsetSpace ~
14377 \InsetSpace ~
14378 \InsetSpace ~
14379 \InsetSpace ~
14380 out_byte +=
14381  1; 
14382 \newline
14383 \InsetSpace ~
14384 \InsetSpace ~
14385 \InsetSpace ~
14386 \InsetSpace ~
14387 \InsetSpace ~
14388 \InsetSpace ~
14389 \InsetSpace ~
14390 \InsetSpace ~
14391 MCLK = 0; 
14392 \newline
14393 \InsetSpace ~
14394 \InsetSpace ~
14395 \InsetSpace ~
14396 \InsetSpace ~
14397 } while(--i);
14398 \newline
14399 \InsetSpace ~
14400 \InsetSpace ~
14401 \InsetSpace ~
14402 \InsetSpace ~
14403 return out_byte; 
14404 \newline
14405 }
14406 \end_layout
14407
14408 \begin_layout Standard
14409 Then, someplace in the code for the first hardware you would use
14410 \end_layout
14411
14412 \begin_layout Verse
14413
14414 \family typewriter
14415 __bit __at
14416 \begin_inset LatexCommand index
14417 name "at"
14418
14419 \end_inset
14420
14421
14422 \begin_inset LatexCommand index
14423 name "\\_\\_at"
14424
14425 \end_inset
14426
14427  (0x80) MOSI;\InsetSpace ~
14428 \InsetSpace ~
14429 \InsetSpace ~
14430 \InsetSpace ~
14431 /* I/O port 0, bit 0 */
14432 \newline
14433 __bit __at (0x81) MISO;\InsetSpace ~
14434 \InsetSpace ~
14435 \InsetSpace ~
14436 \InsetSpace ~
14437 /* I/O port 0,
14438  bit 1 */
14439 \newline
14440 __bit __at (0x82) MCLK;\InsetSpace ~
14441 \InsetSpace ~
14442 \InsetSpace ~
14443 \InsetSpace ~
14444 /* I/O port 0, bit 2 */
14445 \end_layout
14446
14447 \begin_layout Standard
14448 Similarly, for the second hardware you would use
14449 \end_layout
14450
14451 \begin_layout Verse
14452
14453 \family typewriter
14454 __bit __at (0x83) MOSI;\InsetSpace ~
14455 \InsetSpace ~
14456 \InsetSpace ~
14457 \InsetSpace ~
14458 /* I/O port 0, bit 3 */
14459 \newline
14460 __bit __at (0x91) MISO;\InsetSpace ~
14461 \InsetSpace ~
14462 \InsetSpace ~
14463 \InsetSpace ~
14464 /*
14465  I/O port 1, bit 1 */
14466 \newline
14467 __bit
14468 \begin_inset LatexCommand index
14469 name "bit"
14470
14471 \end_inset
14472
14473  __at (0x92) MCLK;\InsetSpace ~
14474 \InsetSpace ~
14475 \InsetSpace ~
14476 \InsetSpace ~
14477 /* I/O port 1, bit 2 */
14478 \end_layout
14479
14480 \begin_layout Standard
14481 and you can use the same hardware dependent routine without changes, as
14482  for example in a library.
14483  This is somehow similar to sbit, but only one absolute address has to be
14484  specified in the whole project.
14485 \begin_inset VSpace bigskip
14486 \end_inset
14487
14488
14489 \end_layout
14490
14491 \begin_layout Section
14492 Parameters
14493 \begin_inset LatexCommand index
14494 name "Parameters"
14495
14496 \end_inset
14497
14498
14499 \begin_inset LatexCommand index
14500 name "function parameter"
14501
14502 \end_inset
14503
14504  & Local Variables
14505 \begin_inset LatexCommand index
14506 name "local variables"
14507
14508 \end_inset
14509
14510
14511 \begin_inset LatexCommand label
14512 name "sec:Parameters-and-Local-Variables"
14513
14514 \end_inset
14515
14516
14517 \end_layout
14518
14519 \begin_layout Standard
14520 Automatic (local) variables and parameters to functions can either be placed
14521  on the stack or in data-space.
14522  The default action of the compiler is to place these variables in the internal
14523  RAM (for small model) or external RAM (for medium or large model).
14524  This in fact makes them similar to 
14525 \emph on
14526 static
14527 \begin_inset LatexCommand index
14528 name "static"
14529
14530 \end_inset
14531
14532
14533 \emph default
14534  so by default functions are non-reentrant
14535 \begin_inset LatexCommand index
14536 name "reentrant"
14537
14538 \end_inset
14539
14540 .
14541  
14542 \newline
14543
14544 \newline
14545 They can be placed on the stack
14546 \begin_inset LatexCommand index
14547 name "stack"
14548
14549 \end_inset
14550
14551  by using the 
14552 \emph on
14553 -
14554 \begin_inset ERT
14555 status collapsed
14556
14557 \begin_layout Standard
14558
14559
14560 \backslash
14561 /
14562 \end_layout
14563
14564 \end_inset
14565
14566 -stack-auto
14567 \begin_inset LatexCommand index
14568 name "-\\/-stack-auto"
14569
14570 \end_inset
14571
14572
14573 \emph default
14574  option, by using 
14575 \emph on
14576 #pragma\InsetSpace ~
14577 stackauto
14578 \emph default
14579
14580 \begin_inset LatexCommand index
14581 name "\\#pragma stackauto"
14582
14583 \end_inset
14584
14585  or by using the 
14586 \emph on
14587 reentrant
14588 \begin_inset LatexCommand index
14589 name "reentrant"
14590
14591 \end_inset
14592
14593
14594 \emph default
14595  keyword in the function declaration, e.g.:
14596 \end_layout
14597
14598 \begin_layout Verse
14599
14600 \family typewriter
14601 unsigned char foo(char i) __reentrant 
14602 \newline
14603
14604 \newline
14605 \InsetSpace ~
14606 \InsetSpace ~
14607 \InsetSpace ~
14608 \InsetSpace ~
14609 ...
14610  
14611 \newline
14612 }
14613 \end_layout
14614
14615 \begin_layout Standard
14616 Since stack space on 8051 is limited, the 
14617 \emph on
14618 reentrant
14619 \emph default
14620  keyword or the 
14621 \emph on
14622 -
14623 \begin_inset ERT
14624 status collapsed
14625
14626 \begin_layout Standard
14627
14628
14629 \backslash
14630 /
14631 \end_layout
14632
14633 \end_inset
14634
14635 -stack-auto
14636 \emph default
14637  option should be used sparingly.
14638  Note that the reentrant keyword just means that the parameters & local
14639  variables will be allocated to the stack, it 
14640 \emph on
14641 does not
14642 \emph default
14643  mean that the function is register bank
14644 \begin_inset LatexCommand index
14645 name "register bank (mcs51, ds390)"
14646
14647 \end_inset
14648
14649  independent.
14650 \newline
14651
14652 \newline
14653 Local variables
14654 \begin_inset LatexCommand index
14655 name "local variables"
14656
14657 \end_inset
14658
14659  can be assigned storage classes and absolute
14660 \begin_inset LatexCommand index
14661 name "Absolute addressing"
14662
14663 \end_inset
14664
14665  addresses, e.g.: 
14666 \end_layout
14667
14668 \begin_layout Verse
14669
14670 \family typewriter
14671 unsigned char foo() 
14672 \newline
14673 {
14674 \newline
14675 \InsetSpace ~
14676 \InsetSpace ~
14677 \InsetSpace ~
14678 \InsetSpace ~
14679 __xdata unsigned char i;
14680 \newline
14681 \InsetSpace ~
14682 \InsetSpace ~
14683 \InsetSpace ~
14684 \InsetSpace ~
14685 __bit bvar;
14686 \newline
14687 \InsetSpace ~
14688 \InsetSpace ~
14689 \InsetSpace ~
14690 \InsetSpace ~
14691 __data __at
14692 \begin_inset LatexCommand index
14693 name "at"
14694
14695 \end_inset
14696
14697  (0x31) unsigned char j;
14698 \newline
14699 \InsetSpace ~
14700 \InsetSpace ~
14701 \InsetSpace ~
14702 \InsetSpace ~
14703 ...
14704  
14705 \newline
14706 }
14707 \end_layout
14708
14709 \begin_layout Standard
14710 In the above example the variable 
14711 \emph on
14712 i
14713 \emph default
14714  will be allocated in the external ram, 
14715 \emph on
14716 bvar
14717 \emph default
14718  in bit addressable space and 
14719 \emph on
14720 j
14721 \emph default
14722  in internal ram.
14723  When compiled with 
14724 \emph on
14725 -
14726 \begin_inset ERT
14727 status collapsed
14728
14729 \begin_layout Standard
14730
14731
14732 \backslash
14733 /
14734 \end_layout
14735
14736 \end_inset
14737
14738 -stack-auto
14739 \emph default
14740  or when a function is declared as 
14741 \emph on
14742 reentrant
14743 \emph default
14744  this should only be done for static variables.
14745 \end_layout
14746
14747 \begin_layout Standard
14748 Parameters
14749 \begin_inset LatexCommand index
14750 name "function parameter"
14751
14752 \end_inset
14753
14754  however are not allowed any storage class
14755 \begin_inset LatexCommand index
14756 name "Storage class"
14757
14758 \end_inset
14759
14760 , (storage classes for parameters will be ignored), their allocation is
14761  governed by the memory model in use, and the reentrancy options.
14762 \end_layout
14763
14764 \begin_layout Standard
14765 It is however allowed to use bit parameters in reentrant functions and also
14766  non-static local bit variables are supported.
14767  Efficient use is limited to 8 semi-bitregisters in bit space.
14768  They are pushed and popped to stack
14769 \begin_inset LatexCommand index
14770 name "stack"
14771
14772 \end_inset
14773
14774  as a single byte just like the normal registers.
14775 \end_layout
14776
14777 \begin_layout Section
14778 Overlaying
14779 \begin_inset LatexCommand label
14780 name "sub:Overlaying"
14781
14782 \end_inset
14783
14784
14785 \begin_inset LatexCommand index
14786 name "Overlaying"
14787
14788 \end_inset
14789
14790
14791 \end_layout
14792
14793 \begin_layout Standard
14794 For non-reentrant
14795 \begin_inset LatexCommand index
14796 name "reentrant"
14797
14798 \end_inset
14799
14800  functions SDCC will try to reduce internal ram space usage by overlaying
14801  parameters and local variables of a function (if possible).
14802  Parameters and local variables
14803 \begin_inset LatexCommand index
14804 name "local variables"
14805
14806 \end_inset
14807
14808  of a function will be allocated to an overlayable segment if the function
14809  has 
14810 \emph on
14811 no other function calls and the function is non-reentrant and the memory
14812  model
14813 \begin_inset LatexCommand index
14814 name "Memory model"
14815
14816 \end_inset
14817
14818  is small.
14819
14820 \emph default
14821  If an explicit storage class
14822 \begin_inset LatexCommand index
14823 name "Storage class"
14824
14825 \end_inset
14826
14827  is specified for a local variable, it will NOT be overlaid.
14828 \end_layout
14829
14830 \begin_layout Standard
14831 Note that the compiler (not the linkage editor) makes the decision for overlayin
14832 g the data items.
14833  Functions that are called from an interrupt service routine
14834 \begin_inset Marginal
14835 status collapsed
14836
14837 \begin_layout Standard
14838
14839 \series bold
14840 !
14841 \end_layout
14842
14843 \end_inset
14844
14845  should be preceded by a #pragma\InsetSpace ~
14846 nooverlay
14847 \begin_inset LatexCommand index
14848 name "\\#pragma nooverlay"
14849
14850 \end_inset
14851
14852  if they are not reentrant.
14853 \end_layout
14854
14855 \begin_layout Standard
14856 Also note that the compiler does not do any processing of inline assembler
14857  code, so the compiler might incorrectly assign local variables and parameters
14858  of a function into the overlay segment if the inline assembler code calls
14859  other c-functions that might use the overlay.
14860  In that case the #pragma\InsetSpace ~
14861 nooverlay should be used.
14862 \end_layout
14863
14864 \begin_layout Standard
14865 Parameters and local variables of functions that contain 16 or 32 bit multiplica
14866 tion
14867 \begin_inset LatexCommand index
14868 name "Multiplication"
14869
14870 \end_inset
14871
14872  or division
14873 \begin_inset LatexCommand index
14874 name "Division"
14875
14876 \end_inset
14877
14878  will NOT be overlaid since these are implemented using external functions,
14879  e.g.:
14880 \end_layout
14881
14882 \begin_layout Verse
14883
14884 \family typewriter
14885 #pragma save 
14886 \newline
14887 #pragma nooverlay
14888 \begin_inset LatexCommand index
14889 name "\\#pragma nooverlay"
14890
14891 \end_inset
14892
14893  
14894 \newline
14895 void set_error(unsigned char errcd) 
14896 \newline
14897 {
14898 \newline
14899 \InsetSpace ~
14900 \InsetSpace ~
14901 \InsetSpace ~
14902 \InsetSpace ~
14903 P3 = errcd;
14904 \newline
14905
14906 \newline
14907 #pragma restore 
14908 \newline
14909
14910 \newline
14911 void
14912  some_isr () __interrupt
14913 \begin_inset LatexCommand index
14914 name "interrupt"
14915
14916 \end_inset
14917
14918  (2)
14919 \newline
14920 {
14921 \newline
14922 \InsetSpace ~
14923 \InsetSpace ~
14924 \InsetSpace ~
14925 \InsetSpace ~
14926 ...
14927 \newline
14928 \InsetSpace ~
14929 \InsetSpace ~
14930 \InsetSpace ~
14931 \InsetSpace ~
14932 set_error(10);
14933 \newline
14934 \InsetSpace ~
14935 \InsetSpace ~
14936 \InsetSpace ~
14937 \InsetSpace ~
14938 ...
14939  
14940 \newline
14941 }
14942 \end_layout
14943
14944 \begin_layout Standard
14945 In the above example the parameter 
14946 \emph on
14947 errcd
14948 \emph default
14949  for the function 
14950 \emph on
14951 set_error
14952 \emph default
14953  would be assigned to the overlayable segment if the #pragma\InsetSpace ~
14954 nooverlay was
14955  not present, this could cause unpredictable runtime behavior when called
14956  from an interrupt service routine.
14957  The #pragma\InsetSpace ~
14958 nooverlay ensures that the parameters and local variables for
14959  the function are NOT overlaid.
14960 \begin_inset VSpace bigskip
14961 \end_inset
14962
14963
14964 \end_layout
14965
14966 \begin_layout Section
14967 Interrupt Service Routines
14968 \begin_inset LatexCommand label
14969 name "sub:Interrupt-Service-Routines"
14970
14971 \end_inset
14972
14973
14974 \end_layout
14975
14976 \begin_layout Subsection
14977 General Information
14978 \end_layout
14979
14980 \begin_layout Standard
14981 SDCC allows 
14982 \emph on
14983 i
14984 \emph default
14985 nterrupt 
14986 \emph on
14987 s
14988 \emph default
14989 ervice 
14990 \emph on
14991 r
14992 \emph default
14993 outines to be coded in C, with some extended keywords.
14994 \end_layout
14995
14996 \begin_layout Verse
14997
14998 \family typewriter
14999 void timer_isr (void) __interrupt (1) __using (1) 
15000 \newline
15001
15002 \newline
15003 \InsetSpace ~
15004 \InsetSpace ~
15005 \InsetSpace ~
15006 \InsetSpace ~
15007 ...
15008  
15009 \newline
15010 }
15011 \end_layout
15012
15013 \begin_layout Standard
15014 The optional number following the 
15015 \emph on
15016 interrupt
15017 \begin_inset LatexCommand index
15018 name "interrupt"
15019
15020 \end_inset
15021
15022
15023 \begin_inset LatexCommand index
15024 name "\\_\\_interrupt"
15025
15026 \end_inset
15027
15028
15029 \emph default
15030  keyword is the interrupt number this routine will service.
15031  When present, the compiler will insert a call to this routine in the interrupt
15032  vector table
15033 \begin_inset LatexCommand index
15034 name "interrupt vector table"
15035
15036 \end_inset
15037
15038  for the interrupt number specified.
15039  If you have multiple source files in your project, interrupt service routines
15040  can be present in any of them, but a prototype of the isr MUST be present
15041  or included in the file that contains the function 
15042 \emph on
15043 main
15044 \emph default
15045 .
15046  The optional (8051 specific) keyword 
15047 \emph on
15048 using
15049 \begin_inset LatexCommand index
15050 name "using (mcs51, ds390 register bank)"
15051
15052 \end_inset
15053
15054
15055 \begin_inset LatexCommand index
15056 name "\\_\\_using (mcs51, ds390 register bank)"
15057
15058 \end_inset
15059
15060
15061 \emph default
15062  can be used to tell the compiler to use the specified register bank when
15063  generating code for this function.
15064  
15065 \newline
15066 Interrupt service routines open the door for some very interesting bugs:
15067 \end_layout
15068
15069 \begin_layout Subsubsection
15070 \begin_inset LatexCommand label
15071 name "sub:Common-interrupt-pitfall-volatile"
15072
15073 \end_inset
15074
15075 Common interrupt pitfall: variable not declared 
15076 \emph on
15077 volatile
15078 \end_layout
15079
15080 \begin_layout Standard
15081 If an interrupt service routine changes variables which are accessed by
15082  other functions these variables have to be declared 
15083 \emph on
15084 volatile
15085 \emph default
15086
15087 \begin_inset LatexCommand index
15088 name "volatile"
15089
15090 \end_inset
15091
15092 .
15093  See 
15094 \begin_inset LatexCommand url
15095 target "http://en.wikipedia.org/wiki/Volatile_variable"
15096
15097 \end_inset
15098
15099  .
15100 \end_layout
15101
15102 \begin_layout Subsubsection
15103 \begin_inset LatexCommand label
15104 name "sub:Common-interrupt-pitfall-non-atomic"
15105
15106 \end_inset
15107
15108 Common interrupt pitfall: 
15109 \emph on
15110 non-atomic access
15111 \end_layout
15112
15113 \begin_layout Standard
15114 If the access to these variables is not 
15115 \emph on
15116 atomic
15117 \begin_inset LatexCommand index
15118 name "atomic"
15119
15120 \end_inset
15121
15122
15123 \emph default
15124  (i.e.
15125  the processor needs more than one instruction for the access and could
15126  be interrupted while accessing the variable) the interrupt must be disabled
15127  during the access to avoid inconsistent data.
15128  
15129 \newline
15130 Access to 16 or 32 bit variables is obviously not atomic on 8 bit CPUs
15131  and should be protected by disabling interrupts.
15132  You're not automatically on the safe side if you use 8 bit variables though.
15133  We need an example here: f.e.
15134  on the 8051 the harmless looking 
15135 \begin_inset Quotes srd
15136 \end_inset
15137
15138
15139 \family typewriter
15140 flags\InsetSpace ~
15141 |=\InsetSpace ~
15142 0x80;
15143 \family default
15144
15145 \begin_inset Quotes sld
15146 \end_inset
15147
15148  is not atomic if 
15149 \family typewriter
15150 flags
15151 \family default
15152  resides in xdata.
15153  Setting 
15154 \begin_inset Quotes srd
15155 \end_inset
15156
15157
15158 \family typewriter
15159 flags\InsetSpace ~
15160 |=\InsetSpace ~
15161 0x40;
15162 \family default
15163
15164 \begin_inset Quotes sld
15165 \end_inset
15166
15167  from within an interrupt routine might get lost if the interrupt occurs
15168  at the wrong time.
15169  
15170 \begin_inset Quotes sld
15171 \end_inset
15172
15173
15174 \family typewriter
15175 counter\InsetSpace ~
15176 +=\InsetSpace ~
15177 8;
15178 \family default
15179
15180 \begin_inset Quotes srd
15181 \end_inset
15182
15183  is not atomic on the 8051 even if 
15184 \family typewriter
15185 counter
15186 \family default
15187  is located in data memory.
15188 \newline
15189 Bugs like these are hard to reproduce and can
15190  cause a lot of trouble.
15191  
15192 \end_layout
15193
15194 \begin_layout Subsubsection
15195 \begin_inset LatexCommand label
15196 name "sub:Common-interrupt-pitfall-stack-overflow"
15197
15198 \end_inset
15199
15200 Common interrupt pitfall: 
15201 \emph on
15202 stack overflow
15203 \end_layout
15204
15205 \begin_layout Standard
15206 The return address and the registers used in the interrupt service routine
15207  are saved on the stack
15208 \begin_inset LatexCommand index
15209 name "stack"
15210
15211 \end_inset
15212
15213  so there must be sufficient stack space.
15214  If there isn't variables or registers (or even the return address itself)
15215  will be corrupted.
15216  This 
15217 \emph on
15218 stack overflow
15219 \emph default
15220
15221 \begin_inset LatexCommand index
15222 name "stack overflow"
15223
15224 \end_inset
15225
15226  is most likely to happen if the interrupt occurs during the 
15227 \begin_inset Quotes sld
15228 \end_inset
15229
15230 deepest
15231 \begin_inset Quotes srd
15232 \end_inset
15233
15234  subroutine when the stack is already in use for f.e.
15235  many return addresses.
15236 \end_layout
15237
15238 \begin_layout Subsubsection
15239 \begin_inset LatexCommand label
15240 name "sub:Common-interrupt-pitfall-non-reentrant"
15241
15242 \end_inset
15243
15244 Common interrupt pitfall: 
15245 \emph on
15246 use of non-reentrant functions
15247 \end_layout
15248
15249 \begin_layout Standard
15250 A special note here, int (16 bit) and long (32 bit) integer division
15251 \begin_inset LatexCommand index
15252 name "Division"
15253
15254 \end_inset
15255
15256 , multiplication
15257 \begin_inset LatexCommand index
15258 name "Multiplication"
15259
15260 \end_inset
15261
15262  & modulus
15263 \begin_inset LatexCommand index
15264 name "Modulus"
15265
15266 \end_inset
15267
15268  and floating-point
15269 \begin_inset LatexCommand index
15270 name "Floating point support"
15271
15272 \end_inset
15273
15274  operations are implemented using external support routines.
15275  If an interrupt service routine needs to do any of these operations then
15276  the support routines (as mentioned in a following section) will have to
15277  be recompiled using the 
15278 \emph on
15279 -
15280 \begin_inset ERT
15281 status collapsed
15282
15283 \begin_layout Standard
15284
15285
15286 \backslash
15287 /
15288 \end_layout
15289
15290 \end_inset
15291
15292 -stack-auto
15293 \begin_inset LatexCommand index
15294 name "-\\/-stack-auto"
15295
15296 \end_inset
15297
15298
15299 \emph default
15300  option and the source file will need to be compiled using the 
15301 \emph on
15302 -
15303 \begin_inset ERT
15304 status collapsed
15305
15306 \begin_layout Standard
15307
15308
15309 \backslash
15310 /
15311 \end_layout
15312
15313 \end_inset
15314
15315 -int-long-reent
15316 \emph default
15317
15318 \begin_inset LatexCommand index
15319 name "-\\/-int-long-reent"
15320
15321 \end_inset
15322
15323  compiler option.
15324  
15325 \newline
15326 Note, the type promotion
15327 \begin_inset LatexCommand index
15328 name "type promotion"
15329
15330 \end_inset
15331
15332  required by ANSI C can cause 16 bit routines to be used
15333 \begin_inset Marginal
15334 status collapsed
15335
15336 \begin_layout Standard
15337
15338 \series bold
15339 \InsetSpace ~
15340 !
15341 \end_layout
15342
15343 \end_inset
15344
15345  without the programmer being aware of it.
15346  See f.e.
15347  the cast 
15348 \family typewriter
15349 \series bold
15350 (unsigned char)(tail-1)
15351 \family default
15352 \series default
15353  
15354 \series bold
15355 within the if clause in section 
15356 \begin_inset LatexCommand ref
15357 reference "sub:A-Step-by Assembler Introduction"
15358
15359 \end_inset
15360
15361 .
15362 \end_layout
15363
15364 \begin_layout Standard
15365 Calling other functions from an interrupt service routine is not recommended,
15366  avoid it if possible.
15367  Note that when some function is called from an interrupt service routine
15368  it should be preceded by a #pragma\InsetSpace ~
15369 nooverlay
15370 \begin_inset LatexCommand index
15371 name "\\#pragma nooverlay"
15372
15373 \end_inset
15374
15375  if it is not reentrant.
15376  Furthermore nonreentrant functions should not be called from the main program
15377  while the interrupt service routine might be active.
15378  They also must not be called from low priority interrupt service routines
15379  while a high priority interrupt service routine might be active.
15380  You could use semaphores or make the function 
15381 \emph on
15382 critical
15383 \emph default
15384  if all parameters are passed in registers.
15385 \newline
15386  Also see section 
15387 \begin_inset LatexCommand ref
15388 reference "sub:Overlaying"
15389
15390 \end_inset
15391
15392 \InsetSpace ~
15393 about Overlaying and section 
15394 \begin_inset LatexCommand ref
15395 reference "sub:Functions-using-private-banks"
15396
15397 \end_inset
15398
15399 \InsetSpace ~
15400 about Functions using private register banks.
15401 \begin_inset VSpace bigskip
15402 \end_inset
15403
15404
15405 \end_layout
15406
15407 \begin_layout Subsection
15408 MCS51/DS390 Interrupt Service Routines
15409 \end_layout
15410
15411 \begin_layout Standard
15412 Interrupt
15413 \begin_inset LatexCommand index
15414 name "interrupt"
15415
15416 \end_inset
15417
15418  numbers and the corresponding address & descriptions for the Standard 8051/8052
15419  are listed below.
15420  SDCC will automatically adjust the 
15421 \begin_inset LatexCommand index
15422 name "interrupt vector table"
15423
15424 \end_inset
15425
15426  to the maximum interrupt number specified.
15427 \newline
15428
15429 \end_layout
15430
15431 \begin_layout Standard
15432 \align center
15433 \begin_inset Tabular
15434 <lyxtabular version="3" rows="9" columns="3">
15435 <features>
15436 <column alignment="center" valignment="top" leftline="true" width="0in">
15437 <column alignment="left" valignment="top" leftline="true" width="0in">
15438 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0in">
15439 <row topline="true" bottomline="true">
15440 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15441 \begin_inset Text
15442
15443 \begin_layout Standard
15444 Interrupt #
15445 \end_layout
15446
15447 \end_inset
15448 </cell>
15449 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15450 \begin_inset Text
15451
15452 \begin_layout Standard
15453 Description
15454 \end_layout
15455
15456 \end_inset
15457 </cell>
15458 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15459 \begin_inset Text
15460
15461 \begin_layout Standard
15462 Vector Address
15463 \end_layout
15464
15465 \end_inset
15466 </cell>
15467 </row>
15468 <row topline="true">
15469 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15470 \begin_inset Text
15471
15472 \begin_layout Standard
15473 0
15474 \end_layout
15475
15476 \end_inset
15477 </cell>
15478 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15479 \begin_inset Text
15480
15481 \begin_layout Standard
15482 External 0
15483 \end_layout
15484
15485 \end_inset
15486 </cell>
15487 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15488 \begin_inset Text
15489
15490 \begin_layout Standard
15491 0x0003
15492 \end_layout
15493
15494 \end_inset
15495 </cell>
15496 </row>
15497 <row topline="true">
15498 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15499 \begin_inset Text
15500
15501 \begin_layout Standard
15502 1
15503 \end_layout
15504
15505 \end_inset
15506 </cell>
15507 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15508 \begin_inset Text
15509
15510 \begin_layout Standard
15511 Timer 0
15512 \end_layout
15513
15514 \end_inset
15515 </cell>
15516 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15517 \begin_inset Text
15518
15519 \begin_layout Standard
15520 0x000b
15521 \end_layout
15522
15523 \end_inset
15524 </cell>
15525 </row>
15526 <row topline="true">
15527 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15528 \begin_inset Text
15529
15530 \begin_layout Standard
15531 2
15532 \end_layout
15533
15534 \end_inset
15535 </cell>
15536 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15537 \begin_inset Text
15538
15539 \begin_layout Standard
15540 External 1
15541 \end_layout
15542
15543 \end_inset
15544 </cell>
15545 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15546 \begin_inset Text
15547
15548 \begin_layout Standard
15549 0x0013
15550 \end_layout
15551
15552 \end_inset
15553 </cell>
15554 </row>
15555 <row topline="true">
15556 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15557 \begin_inset Text
15558
15559 \begin_layout Standard
15560 3
15561 \end_layout
15562
15563 \end_inset
15564 </cell>
15565 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15566 \begin_inset Text
15567
15568 \begin_layout Standard
15569 Timer 1
15570 \end_layout
15571
15572 \end_inset
15573 </cell>
15574 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15575 \begin_inset Text
15576
15577 \begin_layout Standard
15578 0x001b
15579 \end_layout
15580
15581 \end_inset
15582 </cell>
15583 </row>
15584 <row topline="true">
15585 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15586 \begin_inset Text
15587
15588 \begin_layout Standard
15589 4
15590 \end_layout
15591
15592 \end_inset
15593 </cell>
15594 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15595 \begin_inset Text
15596
15597 \begin_layout Standard
15598 Serial
15599 \end_layout
15600
15601 \end_inset
15602 </cell>
15603 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15604 \begin_inset Text
15605
15606 \begin_layout Standard
15607 0x0023
15608 \end_layout
15609
15610 \end_inset
15611 </cell>
15612 </row>
15613 <row topline="true">
15614 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15615 \begin_inset Text
15616
15617 \begin_layout Standard
15618 5
15619 \end_layout
15620
15621 \end_inset
15622 </cell>
15623 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15624 \begin_inset Text
15625
15626 \begin_layout Standard
15627 Timer 2 (8052)
15628 \end_layout
15629
15630 \end_inset
15631 </cell>
15632 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15633 \begin_inset Text
15634
15635 \begin_layout Standard
15636 0x002b
15637 \end_layout
15638
15639 \end_inset
15640 </cell>
15641 </row>
15642 <row topline="true">
15643 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15644 \begin_inset Text
15645
15646 \begin_layout Standard
15647 ...
15648 \end_layout
15649
15650 \end_inset
15651 </cell>
15652 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15653 \begin_inset Text
15654
15655 \begin_layout Standard
15656
15657 \end_layout
15658
15659 \end_inset
15660 </cell>
15661 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15662 \begin_inset Text
15663
15664 \begin_layout Standard
15665 ...
15666 \end_layout
15667
15668 \end_inset
15669 </cell>
15670 </row>
15671 <row topline="true" bottomline="true">
15672 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15673 \begin_inset Text
15674
15675 \begin_layout Standard
15676 n
15677 \end_layout
15678
15679 \end_inset
15680 </cell>
15681 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15682 \begin_inset Text
15683
15684 \begin_layout Standard
15685
15686 \end_layout
15687
15688 \end_inset
15689 </cell>
15690 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15691 \begin_inset Text
15692
15693 \begin_layout Standard
15694 0x0003 + 8*n
15695 \end_layout
15696
15697 \end_inset
15698 </cell>
15699 </row>
15700 </lyxtabular>
15701
15702 \end_inset
15703
15704
15705 \newline
15706
15707 \end_layout
15708
15709 \begin_layout Standard
15710 If the interrupt service routine is defined without 
15711 \emph on
15712 using
15713 \begin_inset LatexCommand index
15714 name "using (mcs51, ds390 register bank)"
15715
15716 \end_inset
15717
15718
15719 \begin_inset LatexCommand index
15720 name "\\_\\_using (mcs51, ds390 register bank)"
15721
15722 \end_inset
15723
15724
15725 \emph default
15726  a register bank or with register bank 0 (
15727 \emph on
15728 using
15729 \emph default
15730  0), the compiler will save the registers used by itself on the stack upon
15731  entry and restore them at exit, however if such an interrupt service routine
15732  calls another function then the entire register bank will be saved on the
15733  stack.
15734  This scheme may be advantageous for small interrupt service routines which
15735  have low register usage.
15736 \end_layout
15737
15738 \begin_layout Standard
15739 If the interrupt service routine is defined to be using a specific register
15740  bank then only 
15741 \emph on
15742 a, b, dptr
15743 \emph default
15744  & psw are saved and restored, if such an interrupt service routine calls
15745  another function (using another register bank) then the entire register
15746  bank of the called function will be saved on the stack
15747 \begin_inset LatexCommand index
15748 name "stack"
15749
15750 \end_inset
15751
15752 .
15753  This scheme is recommended for larger interrupt service routines.
15754 \begin_inset VSpace bigskip
15755 \end_inset
15756
15757
15758 \end_layout
15759
15760 \begin_layout Subsection
15761 HC08
15762 \begin_inset LatexCommand index
15763 name "HC08"
15764
15765 \end_inset
15766
15767  Interrupt Service Routines
15768 \end_layout
15769
15770 \begin_layout Standard
15771 Since the number of interrupts
15772 \begin_inset LatexCommand index
15773 name "HC08!interrupt"
15774
15775 \end_inset
15776
15777  available is chip specific and the interrupt vector table always ends at
15778  the last byte of memory, the interrupt numbers corresponds to the interrupt
15779  vectors in reverse order of address.
15780  For example, interrupt 1 will use the interrupt vector at 0xfffc, interrupt
15781  2 will use the interrupt vector at 0xfffa, and so on.
15782  However, interrupt 0 (the reset vector at 0xfffe) is not redefinable in
15783  this way; instead see section 
15784 \begin_inset LatexCommand ref
15785 reference "sub:Startup-Code"
15786
15787 \end_inset
15788
15789  for details on customizing startup.
15790 \begin_inset VSpace bigskip
15791 \end_inset
15792
15793
15794 \end_layout
15795
15796 \begin_layout Subsection
15797 Z80 Interrupt Service Routines
15798 \end_layout
15799
15800 \begin_layout Standard
15801 The Z80
15802 \begin_inset LatexCommand index
15803 name "Z80"
15804
15805 \end_inset
15806
15807  uses several different methods for determining the correct interrupt
15808 \begin_inset LatexCommand index
15809 name "Z80!interrupt"
15810
15811 \end_inset
15812
15813  vector depending on the hardware implementation.
15814  Therefore, SDCC ignores the optional interrupt number and does not attempt
15815  to generate an interrupt vector table.
15816 \end_layout
15817
15818 \begin_layout Standard
15819 By default, SDCC generates code for a maskable interrupt, which uses a RETI
15820  instruction to return from the interrupt.
15821  To write an interrupt handler for the non-maskable interrupt, which needs
15822  a RETN instruction instead, add the 
15823 \emph on
15824 critical
15825 \emph default
15826  keyword:
15827 \end_layout
15828
15829 \begin_layout Verse
15830
15831 \family typewriter
15832 void nmi_isr (void) critical interrupt
15833 \newline
15834
15835 \newline
15836 \InsetSpace ~
15837 \InsetSpace ~
15838 \InsetSpace ~
15839 \InsetSpace ~
15840 ...
15841  
15842 \newline
15843 }
15844 \end_layout
15845
15846 \begin_layout Standard
15847 However if you need to create a non-interruptable interrupt service routine
15848  you would also require the 
15849 \emph on
15850 critical
15851 \emph default
15852  keyword.
15853  To distinguish between this and an nmi_isr you must provide an interrupt
15854  number.
15855 \begin_inset VSpace bigskip
15856 \end_inset
15857
15858
15859 \end_layout
15860
15861 \begin_layout Section
15862 Enabling and Disabling Interrupts
15863 \end_layout
15864
15865 \begin_layout Subsection
15866 Critical Functions and Critical Statements
15867 \end_layout
15868
15869 \begin_layout Standard
15870 A special keyword may be associated with a block or a function declaring
15871  it as 
15872 \emph on
15873 critical
15874 \emph default
15875 .
15876  SDCC will generate code to disable all interrupts
15877 \begin_inset LatexCommand index
15878 name "interrupt"
15879
15880 \end_inset
15881
15882  upon entry to a critical function and restore the interrupt enable to the
15883  previous state before returning.
15884  Nesting critical functions will need one additional byte on the stack
15885 \begin_inset LatexCommand index
15886 name "stack"
15887
15888 \end_inset
15889
15890  for each call.
15891 \end_layout
15892
15893 \begin_layout Verse
15894
15895 \family typewriter
15896 int foo () __critical
15897 \begin_inset LatexCommand index
15898 name "critical"
15899
15900 \end_inset
15901
15902
15903 \begin_inset LatexCommand index
15904 name "\\_\\_critical"
15905
15906 \end_inset
15907
15908  
15909 \newline
15910
15911 \newline
15912 \InsetSpace ~
15913 \InsetSpace ~
15914 \InsetSpace ~
15915 \InsetSpace ~
15916 ...
15917  
15918 \newline
15919 \InsetSpace ~
15920 \InsetSpace ~
15921 \InsetSpace ~
15922 \InsetSpace ~
15923 ...
15924  
15925 \newline
15926 }
15927 \end_layout
15928
15929 \begin_layout Standard
15930 The critical attribute maybe used with other attributes like 
15931 \emph on
15932 reentrant.
15933 \emph default
15934
15935 \newline
15936 The keyword 
15937 \emph on
15938 critical
15939 \emph default
15940  may also be used to disable interrupts more locally:
15941 \end_layout
15942
15943 \begin_layout Verse
15944
15945 \family typewriter
15946 __critical{ i++; }
15947 \end_layout
15948
15949 \begin_layout Standard
15950 More than one statement could have been included in the block.
15951 \end_layout
15952
15953 \begin_layout Subsection
15954 Enabling and Disabling Interrupts directly
15955 \end_layout
15956
15957 \begin_layout Standard
15958 Interrupts
15959 \begin_inset LatexCommand index
15960 name "interrupt"
15961
15962 \end_inset
15963
15964  can also be disabled and enabled directly (8051):
15965 \end_layout
15966
15967 \begin_layout Verse
15968
15969 \family typewriter
15970 EA = 0;\InsetSpace ~
15971 \InsetSpace ~
15972 \InsetSpace ~
15973 \InsetSpace ~
15974 \InsetSpace ~
15975 \InsetSpace ~
15976 \InsetSpace ~
15977 \InsetSpace ~
15978 \InsetSpace ~
15979 \InsetSpace ~
15980 \InsetSpace ~
15981 \InsetSpace ~
15982 or:\InsetSpace ~
15983 \InsetSpace ~
15984 \InsetSpace ~
15985 \InsetSpace ~
15986 \InsetSpace ~
15987 \InsetSpace ~
15988 \InsetSpace ~
15989 \InsetSpace ~
15990 \InsetSpace ~
15991 \InsetSpace ~
15992 \InsetSpace ~
15993 EA_SAVE = EA;
15994 \end_layout
15995
15996 \begin_layout Verse
15997
15998 \family typewriter
15999 ...\InsetSpace ~
16000 \InsetSpace ~
16001 \InsetSpace ~
16002 \InsetSpace ~
16003 \InsetSpace ~
16004 \InsetSpace ~
16005 \InsetSpace ~
16006 \InsetSpace ~
16007 \InsetSpace ~
16008 \InsetSpace ~
16009 \InsetSpace ~
16010 \InsetSpace ~
16011 \InsetSpace ~
16012 \InsetSpace ~
16013 \InsetSpace ~
16014 \InsetSpace ~
16015 \InsetSpace ~
16016 \InsetSpace ~
16017 \InsetSpace ~
16018 \InsetSpace ~
16019 \InsetSpace ~
16020 \InsetSpace ~
16021 \InsetSpace ~
16022 \InsetSpace ~
16023 \InsetSpace ~
16024 \InsetSpace ~
16025 \InsetSpace ~
16026 \InsetSpace ~
16027 \InsetSpace ~
16028 \InsetSpace ~
16029 EA = 0;
16030 \end_layout
16031
16032 \begin_layout Verse
16033
16034 \family typewriter
16035 EA = 1;\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 ...
16062 \end_layout
16063
16064 \begin_layout Verse
16065
16066 \family typewriter
16067 \InsetSpace ~
16068 \InsetSpace ~
16069 \InsetSpace ~
16070 \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 \InsetSpace ~
16097 \InsetSpace ~
16098 \InsetSpace ~
16099 \InsetSpace ~
16100 EA = EA_SAVE;
16101 \end_layout
16102
16103 \begin_layout Standard
16104 On other architectures which have separate opcodes for enabling and disabling
16105  interrupts you might want to make use of defines with inline assembly
16106 \begin_inset LatexCommand index
16107 name "Assembler routines"
16108
16109 \end_inset
16110
16111  (HC08
16112 \begin_inset LatexCommand index
16113 name "HC08!interrupt"
16114
16115 \end_inset
16116
16117 ):
16118 \end_layout
16119
16120 \begin_layout Verse
16121
16122 \family typewriter
16123 #define CLI _asm
16124 \begin_inset LatexCommand index
16125 name "\\_asm"
16126
16127 \end_inset
16128
16129 \InsetSpace ~
16130 \InsetSpace ~
16131 cli\InsetSpace ~
16132 \InsetSpace ~
16133 _endasm
16134 \begin_inset LatexCommand index
16135 name "\\_endasm"
16136
16137 \end_inset
16138
16139
16140 \end_layout
16141
16142 \begin_layout Verse
16143
16144 \family typewriter
16145 #define SEI _asm\InsetSpace ~
16146 \InsetSpace ~
16147 sei\InsetSpace ~
16148 \InsetSpace ~
16149 _endasm; 
16150 \end_layout
16151
16152 \begin_layout Verse
16153
16154 \family typewriter
16155 ...
16156 \end_layout
16157
16158 \begin_layout Standard
16159 Note: it is sometimes sufficient to disable only a specific interrupt source
16160  like f.e.
16161  a timer or serial interrupt by manipulating an 
16162 \emph on
16163 interrupt mask
16164 \begin_inset LatexCommand index
16165 name "interrupt mask"
16166
16167 \end_inset
16168
16169
16170 \emph default
16171  register.
16172  
16173 \end_layout
16174
16175 \begin_layout Standard
16176 Usually the time during which interrupts are disabled should be kept as
16177  short as possible.
16178  This minimizes both 
16179 \emph on
16180 interrupt latency
16181 \emph default
16182
16183 \begin_inset LatexCommand index
16184 name "interrupt latency"
16185
16186 \end_inset
16187
16188  (the time between the occurrence of the interrupt and the execution of
16189  the first code in the interrupt routine) and 
16190 \emph on
16191 interrupt jitter
16192 \emph default
16193
16194 \begin_inset LatexCommand index
16195 name "interrupt jitter"
16196
16197 \end_inset
16198
16199  (the difference between the shortest and the longest interrupt latency).
16200  These really are something different, f.e.
16201  a serial interrupt has to be served before its buffer overruns so it cares
16202  for the maximum interrupt latency, whereas it does not care about jitter.
16203  On a loudspeaker driven via a digital to analog converter which is fed
16204  by an interrupt a latency of a few milliseconds might be tolerable, whereas
16205  a much smaller jitter will be very audible.
16206 \end_layout
16207
16208 \begin_layout Standard
16209 You can reenable interrupts within an interrupt routine and on some architecture
16210 s you can make use of two (or more) levels of 
16211 \emph on
16212 interrupt priorities
16213 \emph default
16214
16215 \begin_inset LatexCommand index
16216 name "interrupt priority"
16217
16218 \end_inset
16219
16220 .
16221  On some architectures which don't support interrupt priorities these can
16222  be implemented by manipulating the interrupt mask and reenabling interrupts
16223  within the interrupt routine.
16224  Check there is sufficient space on the stack
16225 \begin_inset LatexCommand index
16226 name "stack"
16227
16228 \end_inset
16229
16230  and don't add complexity unless you have to.
16231  
16232 \end_layout
16233
16234 \begin_layout Subsection
16235 Semaphore
16236 \begin_inset LatexCommand index
16237 name "semaphore"
16238
16239 \end_inset
16240
16241  locking (mcs51/ds390)
16242 \end_layout
16243
16244 \begin_layout Standard
16245 Some architectures (mcs51/ds390) have an atomic
16246 \begin_inset LatexCommand index
16247 name "atomic"
16248
16249 \end_inset
16250
16251  bit test and clear instruction.
16252  These type of instructions are typically used in preemptive multitasking
16253  systems, where a routine f.e.
16254  claims the use of a data structure ('acquires a lock
16255 \begin_inset LatexCommand index
16256 name "lock"
16257
16258 \end_inset
16259
16260  on it'), makes some modifications and then releases the lock when the data
16261  structure is consistent again.
16262  The instruction may also be used if interrupt and non-interrupt code have
16263  to compete for a resource.
16264  With the atomic bit test and clear instruction interrupts
16265 \begin_inset LatexCommand index
16266 name "interrupt"
16267
16268 \end_inset
16269
16270  don't have to be disabled for the locking operation.
16271  
16272 \end_layout
16273
16274 \begin_layout Standard
16275 SDCC generates this instruction if the source follows this pattern:
16276 \end_layout
16277
16278 \begin_layout Verse
16279
16280 \family typewriter
16281 volatile
16282 \begin_inset LatexCommand index
16283 name "volatile"
16284
16285 \end_inset
16286
16287  bit resource_is_free; 
16288 \newline
16289
16290 \newline
16291 if (resource_is_free) 
16292 \newline
16293 \InsetSpace ~
16294 \InsetSpace ~
16295
16296 \newline
16297 \InsetSpace ~
16298 \InsetSpace ~
16299 \InsetSpace ~
16300 \InsetSpace ~
16301 resource_is_free=0; 
16302 \newline
16303 \InsetSpace ~
16304 \InsetSpace ~
16305 \InsetSpace ~
16306 \InsetSpace ~
16307 ...
16308  
16309 \newline
16310 \InsetSpace ~
16311 \InsetSpace ~
16312 \InsetSpace ~
16313 \InsetSpace ~
16314 resource_is_free=1;
16315 \newline
16316 \InsetSpace ~
16317 \InsetSpace ~
16318
16319 \end_layout
16320
16321 \begin_layout Standard
16322 Note, mcs51 and ds390 support only an atomic
16323 \begin_inset LatexCommand index
16324 name "atomic"
16325
16326 \end_inset
16327
16328  bit test and 
16329 \emph on
16330 clear
16331 \emph default
16332  instruction (as opposed to atomic bit test and 
16333 \emph on
16334 set).
16335 \end_layout
16336
16337 \begin_layout Section
16338 Functions using private register banks
16339 \begin_inset LatexCommand label
16340 name "sub:Functions-using-private-banks"
16341
16342 \end_inset
16343
16344  (mcs51/ds390)
16345 \end_layout
16346
16347 \begin_layout Standard
16348 Some architectures have support for quickly changing register sets.
16349  SDCC supports this feature with the 
16350 \emph on
16351 using
16352 \begin_inset LatexCommand index
16353 name "using (mcs51, ds390 register bank)"
16354
16355 \end_inset
16356
16357
16358 \begin_inset LatexCommand index
16359 name "\\_\\_using (mcs51, ds390 register bank)"
16360
16361 \end_inset
16362
16363
16364 \emph default
16365  attribute (which tells the compiler to use a register bank
16366 \begin_inset LatexCommand index
16367 name "register bank (mcs51, ds390)"
16368
16369 \end_inset
16370
16371  other than the default bank zero).
16372  It should only be applied to 
16373 \emph on
16374 interrupt
16375 \begin_inset LatexCommand index
16376 name "interrupt"
16377
16378 \end_inset
16379
16380
16381 \emph default
16382  functions (see footnote below).
16383  This will in most circumstances make the generated ISR code more efficient
16384  since it will not have to save registers on the stack.
16385 \end_layout
16386
16387 \begin_layout Standard
16388 The 
16389 \emph on
16390 using
16391 \emph default
16392  attribute will have no effect on the generated code for a 
16393 \emph on
16394 non-interrupt
16395 \emph default
16396  function (but may occasionally be useful anyway
16397 \begin_inset Foot
16398 status open
16399
16400 \begin_layout Standard
16401 possible exception: if a function is called ONLY from 'interrupt' functions
16402  using a particular bank, it can be declared with the same 'using' attribute
16403  as the calling 'interrupt' functions.
16404  For instance, if you have several ISRs using bank one, and all of them
16405  call memcpy(), it might make sense to create a specialized version of memcpy()
16406  'using 1', since this would prevent the ISR from having to save bank zero
16407  to the stack on entry and switch to bank zero before calling the function
16408 \end_layout
16409
16410 \end_inset
16411
16412 ).
16413 \newline
16414
16415 \emph on
16416 (pending: Note, nowadays the
16417 \emph default
16418  using 
16419 \emph on
16420 attribute has an effect on
16421 \emph default
16422  
16423 \emph on
16424 the generated code for a
16425 \emph default
16426  non-interrupt 
16427 \emph on
16428 function
16429 \emph default
16430 .
16431 \emph on
16432 )
16433 \end_layout
16434
16435 \begin_layout Standard
16436 An 
16437 \emph on
16438 interrupt
16439 \emph default
16440  function using a non-zero bank will assume that it can trash that register
16441  bank, and will not save it.
16442  Since high-priority interrupts
16443 \begin_inset LatexCommand index
16444 name "interrupts"
16445
16446 \end_inset
16447
16448
16449 \begin_inset LatexCommand index
16450 name "interrupt priority"
16451
16452 \end_inset
16453
16454  can interrupt low-priority ones on the 8051 and friends, this means that
16455  if a high-priority ISR 
16456 \emph on
16457 using
16458 \emph default
16459  a particular bank occurs while processing a low-priority ISR 
16460 \emph on
16461 using
16462 \emph default
16463  the same bank, terrible and bad things can happen.
16464  To prevent this, no single register bank should be 
16465 \emph on
16466 used
16467 \emph default
16468  by both a high priority and a low priority ISR.
16469  This is probably most easily done by having all high priority ISRs use
16470  one bank and all low priority ISRs use another.
16471  If you have an ISR which can change priority at runtime, you're on your
16472  own: I suggest using the default bank zero and taking the small performance
16473  hit.
16474 \end_layout
16475
16476 \begin_layout Standard
16477 It is most efficient if your ISR calls no other functions.
16478  If your ISR must call other functions, it is most efficient if those functions
16479  use the same bank as the ISR (see note 1 below); the next best is if the
16480  called functions use bank zero.
16481  It is very inefficient to call a function using a different, non-zero bank
16482  from an ISR.
16483  
16484 \begin_inset VSpace bigskip
16485 \end_inset
16486
16487
16488 \end_layout
16489
16490 \begin_layout Section
16491 Startup Code
16492 \begin_inset LatexCommand label
16493 name "sub:Startup-Code"
16494
16495 \end_inset
16496
16497
16498 \begin_inset LatexCommand index
16499 name "Startup code"
16500
16501 \end_inset
16502
16503
16504 \end_layout
16505
16506 \begin_layout Subsection
16507 MCS51/DS390 Startup Code
16508 \end_layout
16509
16510 \begin_layout Standard
16511 The compiler triggers the linker to link certain initialization modules
16512  from the runtime library
16513 \begin_inset LatexCommand index
16514 name "Runtime library"
16515
16516 \end_inset
16517
16518  called crt<something>.
16519  Only the necessary ones are linked, for instance crtxstack.asm (GSINIT1,
16520  GSINIT5) is not linked unless the -
16521 \series bold
16522
16523 \begin_inset ERT
16524 status open
16525
16526 \begin_layout Standard
16527
16528
16529 \backslash
16530 /
16531 \end_layout
16532
16533 \end_inset
16534
16535
16536 \series default
16537 -xstack option is used.
16538  These modules are highly entangled by the use of special segments/areas,
16539  but a common layout is shown below:
16540 \end_layout
16541
16542 \begin_layout Verse
16543
16544 \family typewriter
16545 \series bold
16546 \size footnotesize
16547 (main.asm)
16548 \end_layout
16549
16550 \begin_layout Verse
16551
16552 \family typewriter
16553 \size footnotesize
16554 \InsetSpace ~
16555 \InsetSpace ~
16556 \InsetSpace ~
16557 \InsetSpace ~
16558 \InsetSpace ~
16559 \InsetSpace ~
16560 \InsetSpace ~
16561 \InsetSpace ~
16562 .area HOME (CODE)
16563 \newline
16564 __interrupt_vect:
16565 \newline
16566 \InsetSpace ~
16567 \InsetSpace ~
16568 \InsetSpace ~
16569 \InsetSpace ~
16570 \InsetSpace ~
16571 \InsetSpace ~
16572 \InsetSpace ~
16573 \InsetSpace ~
16574 ljmp __sdcc_gsinit_startup
16575 \end_layout
16576
16577 \begin_layout Verse
16578
16579 \family typewriter
16580 \series bold
16581 \size footnotesize
16582 (crtstart.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 GSINIT0 (CODE)
16598 \newline
16599 __sdcc_gsinit_startup::
16600 \newline
16601 \InsetSpace ~
16602 \InsetSpace ~
16603 \InsetSpace ~
16604 \InsetSpace ~
16605 \InsetSpace ~
16606 \InsetSpace ~
16607 \InsetSpace ~
16608 \InsetSpace ~
16609 mov sp,#__start__stack - 1
16610 \end_layout
16611
16612 \begin_layout Verse
16613
16614 \family typewriter
16615 \series bold
16616 \size footnotesize
16617 (crtxstack.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 GSINIT1 (CODE)
16633 \newline
16634 __sdcc_init_xstack::
16635 \newline
16636 ; Need to initialize in GSINIT1 in
16637  case the user's __sdcc_external_startup uses the xstack.
16638 \newline
16639 \InsetSpace ~
16640 \InsetSpace ~
16641 \InsetSpace ~
16642 \InsetSpace ~
16643 \InsetSpace ~
16644 \InsetSpace ~
16645 \InsetSpace ~
16646 \InsetSpace ~
16647 mov __XPAGE,#(__start__x
16648 stack >> 8)
16649 \newline
16650 \InsetSpace ~
16651 \InsetSpace ~
16652 \InsetSpace ~
16653 \InsetSpace ~
16654 \InsetSpace ~
16655 \InsetSpace ~
16656 \InsetSpace ~
16657 \InsetSpace ~
16658 mov _spx,#__start__xstack
16659 \end_layout
16660
16661 \begin_layout Verse
16662
16663 \family typewriter
16664 \series bold
16665 \size footnotesize
16666 (crtstart.asm)
16667 \end_layout
16668
16669 \begin_layout Verse
16670
16671 \family typewriter
16672 \size footnotesize
16673 \InsetSpace ~
16674 \InsetSpace ~
16675 \InsetSpace ~
16676 \InsetSpace ~
16677 \InsetSpace ~
16678 \InsetSpace ~
16679 \InsetSpace ~
16680 \InsetSpace ~
16681 .area GSINIT2 (CODE)
16682 \newline
16683 \InsetSpace ~
16684 \InsetSpace ~
16685 \InsetSpace ~
16686 \InsetSpace ~
16687 \InsetSpace ~
16688 \InsetSpace ~
16689 \InsetSpace ~
16690 \InsetSpace ~
16691 lcall __sdcc_external_startup
16692 \newline
16693 \InsetSpace ~
16694 \InsetSpace ~
16695 \InsetSpace ~
16696 \InsetSpace ~
16697 \InsetSpace ~
16698 \InsetSpace ~
16699 \InsetSpace ~
16700 \InsetSpace ~
16701 mov a,dpl
16702 \newline
16703 \InsetSpace ~
16704 \InsetSpace ~
16705 \InsetSpace ~
16706 \InsetSpace ~
16707 \InsetSpace ~
16708 \InsetSpace ~
16709 \InsetSpace ~
16710 \InsetSpace ~
16711 jz __sdcc_init_data
16712 \newline
16713 \InsetSpace ~
16714 \InsetSpace ~
16715 \InsetSpace ~
16716 \InsetSpace ~
16717 \InsetSpace ~
16718 \InsetSpace ~
16719 \InsetSpace ~
16720 \InsetSpace ~
16721 ljmp
16722  __sdcc_program_startup
16723 \newline
16724 __sdcc_init_data:
16725 \end_layout
16726
16727 \begin_layout Verse
16728
16729 \family typewriter
16730 \series bold
16731 \size footnotesize
16732 (crtxinit.asm)
16733 \end_layout
16734
16735 \begin_layout Verse
16736
16737 \family typewriter
16738 \size footnotesize
16739 \InsetSpace ~
16740 \InsetSpace ~
16741 \InsetSpace ~
16742 \InsetSpace ~
16743 \InsetSpace ~
16744 \InsetSpace ~
16745 \InsetSpace ~
16746 \InsetSpace ~
16747 .area GSINIT3 (CODE)
16748 \newline
16749 __mcs51_genXINIT::
16750 \newline
16751 \InsetSpace ~
16752 \InsetSpace ~
16753 \InsetSpace ~
16754 \InsetSpace ~
16755 \InsetSpace ~
16756 \InsetSpace ~
16757 \InsetSpace ~
16758 \InsetSpace ~
16759 mov r1,#l_XINIT
16760 \newline
16761 \InsetSpace ~
16762 \InsetSpace ~
16763 \InsetSpace ~
16764 \InsetSpace ~
16765 \InsetSpace ~
16766 \InsetSpace ~
16767 \InsetSpace ~
16768 \InsetSpace ~
16769 mov a,r1
16770 \newline
16771 \InsetSpace ~
16772 \InsetSpace ~
16773 \InsetSpace ~
16774 \InsetSpace ~
16775 \InsetSpace ~
16776 \InsetSpace ~
16777 \InsetSpace ~
16778 \InsetSpace ~
16779 orl a,#(l_XINIT
16780  >> 8)
16781 \newline
16782 \InsetSpace ~
16783 \InsetSpace ~
16784 \InsetSpace ~
16785 \InsetSpace ~
16786 \InsetSpace ~
16787 \InsetSpace ~
16788 \InsetSpace ~
16789 \InsetSpace ~
16790 jz 00003$
16791 \newline
16792 \InsetSpace ~
16793 \InsetSpace ~
16794 \InsetSpace ~
16795 \InsetSpace ~
16796 \InsetSpace ~
16797 \InsetSpace ~
16798 \InsetSpace ~
16799 \InsetSpace ~
16800 mov r2,#((l_XINIT+255) >> 8)
16801 \newline
16802 \InsetSpace ~
16803 \InsetSpace ~
16804 \InsetSpace ~
16805 \InsetSpace ~
16806 \InsetSpace ~
16807 \InsetSpace ~
16808 \InsetSpace ~
16809 \InsetSpace ~
16810 mov dptr,#s_XINIT
16811 \newline
16812 \InsetSpace ~
16813 \InsetSpace ~
16814 \InsetSpace ~
16815 \InsetSpace ~
16816 \InsetSpace ~
16817 \InsetSpace ~
16818 \InsetSpace ~
16819 \InsetSpace ~
16820 mov r0,#s_XISEG
16821 \newline
16822 \InsetSpace ~
16823 \InsetSpace ~
16824 \InsetSpace ~
16825 \InsetSpace ~
16826 \InsetSpace ~
16827 \InsetSpace ~
16828 \InsetSpace ~
16829 \InsetSpace ~
16830 mov
16831  __XPAGE,#(s_XISEG >> 8)
16832 \newline
16833 00001$:\InsetSpace ~
16834 clr a
16835 \newline
16836 \InsetSpace ~
16837 \InsetSpace ~
16838 \InsetSpace ~
16839 \InsetSpace ~
16840 \InsetSpace ~
16841 \InsetSpace ~
16842 \InsetSpace ~
16843 \InsetSpace ~
16844 movc a,@a+dptr
16845 \newline
16846 \InsetSpace ~
16847 \InsetSpace ~
16848 \InsetSpace ~
16849 \InsetSpace ~
16850 \InsetSpace ~
16851 \InsetSpace ~
16852 \InsetSpace ~
16853 \InsetSpace ~
16854 movx @r0,a
16855 \newline
16856 \InsetSpace ~
16857 \InsetSpace ~
16858 \InsetSpace ~
16859 \InsetSpace ~
16860 \InsetSpace ~
16861 \InsetSpace ~
16862 \InsetSpace ~
16863 \InsetSpace ~
16864 inc dptr
16865 \newline
16866 \InsetSpace ~
16867 \InsetSpace ~
16868 \InsetSpace ~
16869 \InsetSpace ~
16870 \InsetSpace ~
16871 \InsetSpace ~
16872 \InsetSpace ~
16873 \InsetSpace ~
16874 inc
16875  r0
16876 \newline
16877 \InsetSpace ~
16878 \InsetSpace ~
16879 \InsetSpace ~
16880 \InsetSpace ~
16881 \InsetSpace ~
16882 \InsetSpace ~
16883 \InsetSpace ~
16884 \InsetSpace ~
16885 cjne r0,#0,00002$
16886 \newline
16887 \InsetSpace ~
16888 \InsetSpace ~
16889 \InsetSpace ~
16890 \InsetSpace ~
16891 \InsetSpace ~
16892 \InsetSpace ~
16893 \InsetSpace ~
16894 \InsetSpace ~
16895 inc __XPAGE
16896 \newline
16897 00002$:\InsetSpace ~
16898 djnz r1,00001$
16899 \newline
16900 \InsetSpace ~
16901 \InsetSpace ~
16902 \InsetSpace ~
16903 \InsetSpace ~
16904 \InsetSpace ~
16905 \InsetSpace ~
16906 \InsetSpace ~
16907 \InsetSpace ~
16908 djnz r2,00001$
16909 \newline
16910 \InsetSpace ~
16911 \InsetSpace ~
16912 \InsetSpace ~
16913 \InsetSpace ~
16914 \InsetSpace ~
16915 \InsetSpace ~
16916 \InsetSpace ~
16917 \InsetSpace ~
16918 mov __XPAGE,#0
16919 xFF
16920 \newline
16921 00003$:
16922 \end_layout
16923
16924 \begin_layout Verse
16925
16926 \family typewriter
16927 \series bold
16928 \size footnotesize
16929 (crtclear.asm)
16930 \end_layout
16931
16932 \begin_layout Verse
16933
16934 \family typewriter
16935 \size footnotesize
16936 \InsetSpace ~
16937 \InsetSpace ~
16938 \InsetSpace ~
16939 \InsetSpace ~
16940 \InsetSpace ~
16941 \InsetSpace ~
16942 \InsetSpace ~
16943 \InsetSpace ~
16944 .area GSINIT4 (CODE)
16945 \newline
16946 __mcs51_genRAMCLEAR::
16947 \newline
16948 \InsetSpace ~
16949 \InsetSpace ~
16950 \InsetSpace ~
16951 \InsetSpace ~
16952 \InsetSpace ~
16953 \InsetSpace ~
16954 \InsetSpace ~
16955 \InsetSpace ~
16956 clr a
16957 \newline
16958 \InsetSpace ~
16959 \InsetSpace ~
16960 \InsetSpace ~
16961 \InsetSpace ~
16962 \InsetSpace ~
16963 \InsetSpace ~
16964 \InsetSpace ~
16965 \InsetSpace ~
16966 mov r0,#(l_IRAM-1)
16967 \newline
16968 00004$:\InsetSpace ~
16969 mov
16970  @r0,a
16971 \newline
16972 \InsetSpace ~
16973 \InsetSpace ~
16974 \InsetSpace ~
16975 \InsetSpace ~
16976 \InsetSpace ~
16977 \InsetSpace ~
16978 \InsetSpace ~
16979 \InsetSpace ~
16980 djnz r0,00004$
16981 \newline
16982 ; _mcs51_genRAMCLEAR() end
16983 \end_layout
16984
16985 \begin_layout Verse
16986
16987 \family typewriter
16988 \series bold
16989 \size footnotesize
16990 (crtxclear.asm)
16991 \end_layout
16992
16993 \begin_layout Verse
16994
16995 \family typewriter
16996 \size footnotesize
16997 \InsetSpace ~
16998 \InsetSpace ~
16999 \InsetSpace ~
17000 \InsetSpace ~
17001 \InsetSpace ~
17002 \InsetSpace ~
17003 \InsetSpace ~
17004 \InsetSpace ~
17005 .area GSINIT4 (CODE)
17006 \newline
17007 __mcs51_genXRAMCLEAR::
17008 \newline
17009 \InsetSpace ~
17010 \InsetSpace ~
17011 \InsetSpace ~
17012 \InsetSpace ~
17013 \InsetSpace ~
17014 \InsetSpace ~
17015 \InsetSpace ~
17016 \InsetSpace ~
17017 mov r0,#l_PSEG
17018 \newline
17019 \InsetSpace ~
17020 \InsetSpace ~
17021 \InsetSpace ~
17022 \InsetSpace ~
17023 \InsetSpace ~
17024 \InsetSpace ~
17025 \InsetSpace ~
17026 \InsetSpace ~
17027 mov a,r0
17028 \newline
17029 \InsetSpace ~
17030 \InsetSpace ~
17031 \InsetSpace ~
17032 \InsetSpace ~
17033 \InsetSpace ~
17034 \InsetSpace ~
17035 \InsetSpace ~
17036 \InsetSpace ~
17037 orl a,#(l_PSEG
17038  >> 8)
17039 \newline
17040 \InsetSpace ~
17041 \InsetSpace ~
17042 \InsetSpace ~
17043 \InsetSpace ~
17044 \InsetSpace ~
17045 \InsetSpace ~
17046 \InsetSpace ~
17047 \InsetSpace ~
17048 jz 00006$
17049 \newline
17050 \InsetSpace ~
17051 \InsetSpace ~
17052 \InsetSpace ~
17053 \InsetSpace ~
17054 \InsetSpace ~
17055 \InsetSpace ~
17056 \InsetSpace ~
17057 \InsetSpace ~
17058 mov r1,#s_PSEG
17059 \newline
17060 \InsetSpace ~
17061 \InsetSpace ~
17062 \InsetSpace ~
17063 \InsetSpace ~
17064 \InsetSpace ~
17065 \InsetSpace ~
17066 \InsetSpace ~
17067 \InsetSpace ~
17068 mov __XPAGE,#(s_PSEG >> 8)
17069 \newline
17070 \InsetSpace ~
17071 \InsetSpace ~
17072 \InsetSpace ~
17073 \InsetSpace ~
17074 \InsetSpace ~
17075 \InsetSpace ~
17076 \InsetSpace ~
17077 \InsetSpace ~
17078 clr a
17079 \newline
17080 00005$:\InsetSpace ~
17081 movx
17082  @r1,a
17083 \newline
17084 \InsetSpace ~
17085 \InsetSpace ~
17086 \InsetSpace ~
17087 \InsetSpace ~
17088 \InsetSpace ~
17089 \InsetSpace ~
17090 \InsetSpace ~
17091 \InsetSpace ~
17092 inc r1
17093 \newline
17094 \InsetSpace ~
17095 \InsetSpace ~
17096 \InsetSpace ~
17097 \InsetSpace ~
17098 \InsetSpace ~
17099 \InsetSpace ~
17100 \InsetSpace ~
17101 \InsetSpace ~
17102 djnz r0,00005$
17103 \newline
17104 00006$:
17105 \newline
17106 \InsetSpace ~
17107 \InsetSpace ~
17108 \InsetSpace ~
17109 \InsetSpace ~
17110 \InsetSpace ~
17111 \InsetSpace ~
17112 \InsetSpace ~
17113 \InsetSpace ~
17114 mov r0,#l_XSEG
17115 \newline
17116 \InsetSpace ~
17117 \InsetSpace ~
17118 \InsetSpace ~
17119 \InsetSpace ~
17120 \InsetSpace ~
17121 \InsetSpace ~
17122 \InsetSpace ~
17123 \InsetSpace ~
17124 mov a,r0
17125 \newline
17126 \InsetSpace ~
17127 \InsetSpace ~
17128 \InsetSpace ~
17129 \InsetSpace ~
17130 \InsetSpace ~
17131 \InsetSpace ~
17132 \InsetSpace ~
17133 \InsetSpace ~
17134 orl a,#(l_XSEG >>
17135  8)
17136 \newline
17137 \InsetSpace ~
17138 \InsetSpace ~
17139 \InsetSpace ~
17140 \InsetSpace ~
17141 \InsetSpace ~
17142 \InsetSpace ~
17143 \InsetSpace ~
17144 \InsetSpace ~
17145 jz 00008$
17146 \newline
17147 \InsetSpace ~
17148 \InsetSpace ~
17149 \InsetSpace ~
17150 \InsetSpace ~
17151 \InsetSpace ~
17152 \InsetSpace ~
17153 \InsetSpace ~
17154 \InsetSpace ~
17155 mov r1,#((l_XSEG + 255) >> 8)
17156 \newline
17157 \InsetSpace ~
17158 \InsetSpace ~
17159 \InsetSpace ~
17160 \InsetSpace ~
17161 \InsetSpace ~
17162 \InsetSpace ~
17163 \InsetSpace ~
17164 \InsetSpace ~
17165 mov dptr,#s_XSEG
17166 \newline
17167 \InsetSpace ~
17168 \InsetSpace ~
17169 \InsetSpace ~
17170 \InsetSpace ~
17171 \InsetSpace ~
17172 \InsetSpace ~
17173 \InsetSpace ~
17174 \InsetSpace ~
17175 clr a
17176 \newline
17177 00007$:\InsetSpace ~
17178 movx
17179  @dptr,a
17180 \newline
17181 \InsetSpace ~
17182 \InsetSpace ~
17183 \InsetSpace ~
17184 \InsetSpace ~
17185 \InsetSpace ~
17186 \InsetSpace ~
17187 \InsetSpace ~
17188 \InsetSpace ~
17189 inc dptr
17190 \newline
17191 \InsetSpace ~
17192 \InsetSpace ~
17193 \InsetSpace ~
17194 \InsetSpace ~
17195 \InsetSpace ~
17196 \InsetSpace ~
17197 \InsetSpace ~
17198 \InsetSpace ~
17199 djnz r0,00007$
17200 \newline
17201 \InsetSpace ~
17202 \InsetSpace ~
17203 \InsetSpace ~
17204 \InsetSpace ~
17205 \InsetSpace ~
17206 \InsetSpace ~
17207 \InsetSpace ~
17208 \InsetSpace ~
17209 djnz r1,00007$
17210 \newline
17211 00008$:
17212 \end_layout
17213
17214 \begin_layout Verse
17215
17216 \family typewriter
17217 \series bold
17218 \size footnotesize
17219 (crtxstack.asm)
17220 \end_layout
17221
17222 \begin_layout Verse
17223
17224 \family typewriter
17225 \size footnotesize
17226 \InsetSpace ~
17227 \InsetSpace ~
17228 \InsetSpace ~
17229 \InsetSpace ~
17230 \InsetSpace ~
17231 \InsetSpace ~
17232 \InsetSpace ~
17233 \InsetSpace ~
17234 .area GSINIT5 (CODE)
17235 \newline
17236 ; Need to initialize in GSINIT5 because __mcs51_genXINIT
17237  modifies __XPAGE
17238 \newline
17239 ; and __mcs51_genRAMCLEAR modifies _spx.
17240 \newline
17241 \InsetSpace ~
17242 \InsetSpace ~
17243 \InsetSpace ~
17244 \InsetSpace ~
17245 \InsetSpace ~
17246 \InsetSpace ~
17247 \InsetSpace ~
17248 \InsetSpace ~
17249 mov __XPAGE,#(__start__x
17250 stack >> 8)
17251 \newline
17252 \InsetSpace ~
17253 \InsetSpace ~
17254 \InsetSpace ~
17255 \InsetSpace ~
17256 \InsetSpace ~
17257 \InsetSpace ~
17258 \InsetSpace ~
17259 \InsetSpace ~
17260 mov _spx,#__start__xstack
17261 \end_layout
17262
17263 \begin_layout Verse
17264
17265 \family typewriter
17266 \series bold
17267 \size footnotesize
17268 (application modules)
17269 \end_layout
17270
17271 \begin_layout Verse
17272
17273 \family typewriter
17274 \size footnotesize
17275 \InsetSpace ~
17276 \InsetSpace ~
17277 \InsetSpace ~
17278 \InsetSpace ~
17279 \InsetSpace ~
17280 \InsetSpace ~
17281 \InsetSpace ~
17282 \InsetSpace ~
17283 .area GSINIT (CODE)
17284 \end_layout
17285
17286 \begin_layout Verse
17287
17288 \family typewriter
17289 \series bold
17290 \size footnotesize
17291 (main.asm)
17292 \end_layout
17293
17294 \begin_layout Verse
17295
17296 \family typewriter
17297 \size footnotesize
17298 \InsetSpace ~
17299 \InsetSpace ~
17300 \InsetSpace ~
17301 \InsetSpace ~
17302 \InsetSpace ~
17303 \InsetSpace ~
17304 \InsetSpace ~
17305 \InsetSpace ~
17306 .area GSFINAL (CODE)
17307 \newline
17308 \InsetSpace ~
17309 \InsetSpace ~
17310 \InsetSpace ~
17311 \InsetSpace ~
17312 \InsetSpace ~
17313 \InsetSpace ~
17314 \InsetSpace ~
17315 \InsetSpace ~
17316 ljmp __sdcc_program_startup
17317 \newline
17318 ;---------------------------------
17319 -----------------------
17320 \newline
17321 ; Home
17322 \newline
17323 ;--------------------------------------------------
17324 ------
17325 \newline
17326 \InsetSpace ~
17327 \InsetSpace ~
17328 \InsetSpace ~
17329 \InsetSpace ~
17330 \InsetSpace ~
17331 \InsetSpace ~
17332 \InsetSpace ~
17333 \InsetSpace ~
17334 .area HOME (CODE)
17335 \newline
17336 \InsetSpace ~
17337 \InsetSpace ~
17338 \InsetSpace ~
17339 \InsetSpace ~
17340 \InsetSpace ~
17341 \InsetSpace ~
17342 \InsetSpace ~
17343 \InsetSpace ~
17344 .area CSEG (CODE)
17345 \newline
17346 __sdcc_program_startup:
17347 \newline
17348 \InsetSpace ~
17349 \InsetSpace ~
17350 \InsetSpace ~
17351 \InsetSpace ~
17352 \InsetSpace ~
17353 \InsetSpace ~
17354 \InsetSpace ~
17355 \InsetSpace ~
17356 lcall _main
17357 \newline
17358 ;
17359  return from main will lock up
17360 \newline
17361 \InsetSpace ~
17362 \InsetSpace ~
17363 \InsetSpace ~
17364 \InsetSpace ~
17365 \InsetSpace ~
17366 \InsetSpace ~
17367 \InsetSpace ~
17368 \InsetSpace ~
17369 sjmp .
17370 \end_layout
17371
17372 \begin_layout Standard
17373 One of these modules (crtstart.asm) contains a call to the C routine 
17374 \emph on
17375 _sdcc_external_startup()
17376 \begin_inset LatexCommand index
17377 name "\\_sdcc\\_external\\_startup()"
17378
17379 \end_inset
17380
17381
17382 \emph default
17383  at the start of the CODE area.
17384  This routine is also in the runtime library
17385 \begin_inset LatexCommand index
17386 name "Runtime library"
17387
17388 \end_inset
17389
17390  and returns 0 by default.
17391  If this routine returns a non-zero value, the static & global variable
17392  initialization will be skipped and the function main will be invoked.
17393  Otherwise static & global variables will be initialized before the function
17394  main is invoked.
17395  You could add an 
17396 \emph on
17397 _sdcc_external_startup()
17398 \emph default
17399  routine to your program to override the default if you need to setup hardware
17400  or perform some other critical operation prior to static & global variable
17401  initialization
17402 \begin_inset LatexCommand index
17403 name "Variable initialization"
17404
17405 \end_inset
17406
17407 .
17408  On some mcs51 variants xdata
17409 \begin_inset LatexCommand index
17410 name "xdata (mcs51, ds390 storage class)"
17411
17412 \end_inset
17413
17414  memory has to be explicitly enabled before it can be accessed or if the
17415  watchdog
17416 \begin_inset LatexCommand index
17417 name "watchdog"
17418
17419 \end_inset
17420
17421  needs to be disabled, this is the place to do it.
17422  The startup code clears all internal data memory, 256 bytes by default,
17423  but from 0 to n-1 if 
17424 \emph on
17425 -
17426 \begin_inset ERT
17427 status collapsed
17428
17429 \begin_layout Standard
17430
17431
17432 \backslash
17433 /
17434 \end_layout
17435
17436 \end_inset
17437
17438 -iram-size
17439 \begin_inset LatexCommand index
17440 name "-\\/-iram-size <Value>"
17441
17442 \end_inset
17443
17444 n
17445 \emph default
17446  is used.
17447  (recommended for Chipcon CC1010).
17448 \end_layout
17449
17450 \begin_layout Standard
17451 See also the compiler options 
17452 \emph on
17453 -
17454 \begin_inset ERT
17455 status collapsed
17456
17457 \begin_layout Standard
17458
17459
17460 \backslash
17461 /
17462 \end_layout
17463
17464 \end_inset
17465
17466 -no-xinit
17467 \emph default
17468 -
17469 \emph on
17470 opt
17471 \emph default
17472
17473 \begin_inset LatexCommand index
17474 name "-\\/-no-xinit-opt"
17475
17476 \end_inset
17477
17478
17479 \emph on
17480 -
17481 \begin_inset ERT
17482 status collapsed
17483
17484 \begin_layout Standard
17485
17486
17487 \backslash
17488 /
17489 \end_layout
17490
17491 \end_inset
17492
17493 -main-return
17494 \emph default
17495
17496 \begin_inset LatexCommand index
17497 name "-\\/-main-return"
17498
17499 \end_inset
17500
17501  and section 
17502 \begin_inset LatexCommand ref
17503 reference "sub:MCS51-variants"
17504
17505 \end_inset
17506
17507  about MCS51-variants.
17508 \newline
17509
17510 \end_layout
17511
17512 \begin_layout Standard
17513 While these initialization modules are meant as generic startup code there
17514  might be the need for customization.
17515  Let's assume the return value of 
17516 \emph on
17517 _sdcc_external_startup()
17518 \emph default
17519  in 
17520 \emph on
17521 crtstart.asm
17522 \emph default
17523  should not be checked (or 
17524 \emph on
17525 _sdcc_external_startup()
17526 \emph default
17527  should not be called at all).
17528  The recommended way would be to copy 
17529 \emph on
17530 crtstart.asm
17531 \emph default
17532  (f.e.
17533  from 
17534 \begin_inset LatexCommand url
17535 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/device/lib/mcs51/crtstart.asm"
17536
17537 \end_inset
17538
17539 ) into the source directory, adapt it there, then assemble it with 
17540 \emph on
17541 asx8051 -plosgff
17542 \begin_inset Foot
17543 status open
17544
17545 \begin_layout Standard
17546 \begin_inset Quotes sld
17547 \end_inset
17548
17549 -plosgff
17550 \begin_inset Quotes srd
17551 \end_inset
17552
17553  are the assembler options used in 
17554 \begin_inset LatexCommand url
17555 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/lib/mcs51/Makefile.in?view=markup "
17556
17557 \end_inset
17558
17559
17560 \end_layout
17561
17562 \end_inset
17563
17564  crtstart.asm
17565 \emph default
17566  and when linking your project explicitly specify 
17567 \emph on
17568 crtstart.rel
17569 \emph default
17570 .
17571  As a bonus a listing of the relocated object file 
17572 \emph on
17573 crtstart.rst
17574 \emph default
17575  is generated.
17576 \end_layout
17577
17578 \begin_layout Standard
17579 \begin_inset VSpace bigskip
17580 \end_inset
17581
17582
17583 \end_layout
17584
17585 \begin_layout Subsection
17586 HC08 Startup Code
17587 \end_layout
17588
17589 \begin_layout Standard
17590 The HC08
17591 \begin_inset LatexCommand index
17592 name "HC08"
17593
17594 \end_inset
17595
17596  startup code follows the same scheme as the MCS51 startup code.
17597 \begin_inset VSpace bigskip
17598 \end_inset
17599
17600
17601 \end_layout
17602
17603 \begin_layout Subsection
17604 Z80 Startup Code
17605 \end_layout
17606
17607 \begin_layout Standard
17608 On the Z80
17609 \begin_inset LatexCommand index
17610 name "Z80"
17611
17612 \end_inset
17613
17614  the startup code is inserted by linking with crt0.o which is generated from
17615  sdcc/device/lib/z80/crt0.s.
17616  If you need a different startup code you can use the compiler option 
17617 \emph on
17618 -
17619 \series bold
17620 \emph default
17621
17622 \begin_inset ERT
17623 status collapsed
17624
17625 \begin_layout Standard
17626
17627
17628 \backslash
17629 /
17630 \end_layout
17631
17632 \end_inset
17633
17634
17635 \series default
17636 \emph on
17637 -no-std-crt0
17638 \emph default
17639
17640 \begin_inset LatexCommand index
17641 name "-\\/-no-std-crt0"
17642
17643 \end_inset
17644
17645  and provide your own crt0.o.
17646  
17647 \begin_inset VSpace bigskip
17648 \end_inset
17649
17650
17651 \end_layout
17652
17653 \begin_layout Section
17654 Inline Assembler Code
17655 \begin_inset LatexCommand index
17656 name "Assembler routines"
17657
17658 \end_inset
17659
17660
17661 \end_layout
17662
17663 \begin_layout Subsection
17664 A Step by Step Introduction
17665 \begin_inset LatexCommand label
17666 name "sub:A-Step-by Assembler Introduction"
17667
17668 \end_inset
17669
17670
17671 \end_layout
17672
17673 \begin_layout Standard
17674 Starting from a small snippet of c-code this example shows for the MCS51
17675  how to use inline assembly, access variables, a function parameter and
17676  an array in xdata memory.
17677  The example uses an MCS51 here but is easily adapted for other architectures.
17678  This is a buffer routine which should be optimized:
17679 \end_layout
17680
17681 \begin_layout Verse
17682
17683 \family typewriter
17684 \size footnotesize
17685 unsigned char __far
17686 \begin_inset LatexCommand index
17687 name "far (storage class)"
17688
17689 \end_inset
17690
17691
17692 \begin_inset LatexCommand index
17693 name "\\_\\_far (storage class)"
17694
17695 \end_inset
17696
17697  __at
17698 \begin_inset LatexCommand index
17699 name "at"
17700
17701 \end_inset
17702
17703
17704 \begin_inset LatexCommand index
17705 name "\\_\\_at"
17706
17707 \end_inset
17708
17709 (0x7f00) buf[0x100];
17710 \begin_inset LatexCommand index
17711 name "Aligned array"
17712
17713 \end_inset
17714
17715
17716 \newline
17717 unsigned char head, tail;\InsetSpace ~
17718 \InsetSpace ~
17719 \InsetSpace ~
17720 \InsetSpace ~
17721 \InsetSpace ~
17722 \InsetSpace ~
17723 \InsetSpace ~
17724 \InsetSpace ~
17725 \InsetSpace ~
17726 \InsetSpace ~
17727 \InsetSpace ~
17728 \InsetSpace ~
17729 \InsetSpace ~
17730 \InsetSpace ~
17731 \InsetSpace ~
17732 \InsetSpace ~
17733 \InsetSpace ~
17734 /* if interrupts
17735 \begin_inset LatexCommand index
17736 name "interrupt"
17737
17738 \end_inset
17739
17740  are involved see
17741 \newline
17742 \InsetSpace ~
17743 \InsetSpace ~
17744 \InsetSpace ~
17745 \InsetSpace ~
17746 \InsetSpace ~
17747 \InsetSpace ~
17748 \InsetSpace ~
17749 \InsetSpace ~
17750 \InsetSpace ~
17751 \InsetSpace ~
17752 \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 \InsetSpace ~
17770 \InsetSpace ~
17771 \InsetSpace ~
17772 \InsetSpace ~
17773 \InsetSpace ~
17774 \InsetSpace ~
17775 \InsetSpace ~
17776 \InsetSpace ~
17777 \InsetSpace ~
17778 \InsetSpace ~
17779 \InsetSpace ~
17780 \InsetSpace ~
17781 \InsetSpace ~
17782 \InsetSpace ~
17783 \InsetSpace ~
17784 \InsetSpace ~
17785 \InsetSpace ~
17786 \InsetSpace ~
17787 section 
17788 \begin_inset LatexCommand ref
17789 reference "sub:Common-interrupt-pitfall-volatile"
17790
17791 \end_inset
17792
17793  about
17794 \family default
17795  
17796 \family typewriter
17797 \series bold
17798 volatile
17799 \family default
17800 \series default
17801  
17802 \family typewriter
17803 */
17804 \newline
17805
17806 \newline
17807 void to_buffer( unsigned char c ) 
17808 \newline
17809 {
17810 \newline
17811 \InsetSpace ~
17812 \InsetSpace ~
17813 \InsetSpace ~
17814 \InsetSpace ~
17815 if( head != (unsigned char)(tail-1)
17816  )\InsetSpace ~
17817 /* cast
17818 \family default
17819  
17820 \family typewriter
17821 \series bold
17822 needed
17823 \family default
17824 \series default
17825  
17826 \family typewriter
17827 to avoid promotion
17828 \begin_inset LatexCommand index
17829 name "promotion to signed int"
17830
17831 \end_inset
17832
17833
17834 \begin_inset LatexCommand index
17835 name "type promotion"
17836
17837 \end_inset
17838
17839  to integer */
17840 \begin_inset Marginal
17841 status collapsed
17842
17843 \begin_layout Standard
17844
17845 \series bold
17846 \InsetSpace ~
17847 !
17848 \end_layout
17849
17850 \end_inset
17851
17852
17853 \newline
17854 \InsetSpace ~
17855 \InsetSpace ~
17856 \InsetSpace ~
17857 \InsetSpace ~
17858 \InsetSpace ~
17859 \InsetSpace ~
17860 \InsetSpace ~
17861 \InsetSpace ~
17862 buf[ head++ ] = c;\InsetSpace ~
17863 \InsetSpace ~
17864 \InsetSpace ~
17865 \InsetSpace ~
17866 \InsetSpace ~
17867 \InsetSpace ~
17868 \InsetSpace ~
17869 \InsetSpace ~
17870 \InsetSpace ~
17871 \InsetSpace ~
17872 \InsetSpace ~
17873 \InsetSpace ~
17874 \InsetSpace ~
17875 \InsetSpace ~
17876 \InsetSpace ~
17877 \InsetSpace ~
17878 /* access to a 256 byte aligned array */
17879 \newline
17880
17881 \end_layout
17882
17883 \begin_layout Standard
17884 If the code snippet (assume it is saved in buffer.c) is compiled with SDCC
17885  then a corresponding buffer.asm file is generated.
17886  We define a new function 
17887 \family typewriter
17888 to_buffer_asm()
17889 \family default
17890  in file buffer.c in which we cut and paste the generated code, removing
17891  unwanted comments and some ':'.
17892  Then add 
17893 \begin_inset Quotes sld
17894 \end_inset
17895
17896
17897 \series bold
17898 _asm
17899 \series default
17900
17901 \begin_inset Quotes srd
17902 \end_inset
17903
17904  and 
17905 \begin_inset Quotes sld
17906 \end_inset
17907
17908
17909 \series bold
17910 _endasm;
17911 \series default
17912
17913 \begin_inset Quotes srd
17914 \end_inset
17915
17916
17917 \begin_inset Foot
17918 status open
17919
17920 \begin_layout Standard
17921 Note, that the single underscore form (_asm and _endasm) are not C99-compatible,
17922  and for C-99 compatibility, the double-underscore form (__asm and __endasm)
17923  has to be used.
17924  The latter is also used in the library functions.
17925 \end_layout
17926
17927 \end_inset
17928
17929  to the beginning and the end of the function body:
17930 \end_layout
17931
17932 \begin_layout Verse
17933
17934 \family typewriter
17935 \size footnotesize
17936 /* With a cut and paste from the .asm file, we have something to start with.
17937 \newline
17938 \InsetSpace ~
17939 \InsetSpace ~
17940 \InsetSpace ~
17941 The
17942  function is not yet OK! (registers aren't saved) */ 
17943 \newline
17944 void to_buffer_asm(
17945  unsigned char c ) 
17946 \newline
17947
17948 \newline
17949 \InsetSpace ~
17950 \InsetSpace ~
17951 \InsetSpace ~
17952 \InsetSpace ~
17953 _asm
17954 \begin_inset LatexCommand index
17955 name "\\_asm"
17956
17957 \end_inset
17958
17959
17960 \begin_inset LatexCommand index
17961 name "\\_\\_asm"
17962
17963 \end_inset
17964
17965
17966 \newline
17967 \InsetSpace ~
17968 \InsetSpace ~
17969 \InsetSpace ~
17970 \InsetSpace ~
17971 mov\InsetSpace ~
17972 \InsetSpace ~
17973 r2,dpl 
17974 \newline
17975 ;buffer.c if( head != (unsigned char)(tail-1) ) \InsetSpace ~
17976 /* cast
17977 \family default
17978  
17979 \family typewriter
17980 \series bold
17981 needed
17982 \family default
17983 \series default
17984  
17985 \family typewriter
17986 to avoid promotion
17987 \begin_inset LatexCommand index
17988 name "promotion to signed int"
17989
17990 \end_inset
17991
17992
17993 \begin_inset LatexCommand index
17994 name "type promotion"
17995
17996 \end_inset
17997
17998  to integer */
17999 \newline
18000 \InsetSpace ~
18001 \InsetSpace ~
18002 \InsetSpace ~
18003 \InsetSpace ~
18004 mov\InsetSpace ~
18005 \InsetSpace ~
18006 a,_tail 
18007 \newline
18008 \InsetSpace ~
18009 \InsetSpace ~
18010 \InsetSpace ~
18011 \InsetSpace ~
18012 dec\InsetSpace ~
18013 \InsetSpace ~
18014
18015 \newline
18016 \InsetSpace ~
18017 \InsetSpace ~
18018 \InsetSpace ~
18019 \InsetSpace ~
18020 mov\InsetSpace ~
18021 \InsetSpace ~
18022 r3,a 
18023 \newline
18024 \InsetSpace ~
18025 \InsetSpace ~
18026 \InsetSpace ~
18027 \InsetSpace ~
18028 mov\InsetSpace ~
18029 \InsetSpace ~
18030 a,_head 
18031 \newline
18032 \InsetSpace ~
18033 \InsetSpace ~
18034 \InsetSpace ~
18035 \InsetSpace ~
18036 cjne a,ar3,00106$ 
18037 \newline
18038 \InsetSpace ~
18039 \InsetSpace ~
18040 \InsetSpace ~
18041 \InsetSpace ~
18042 ret
18043 \newline
18044 00106$:
18045  
18046 \newline
18047 ;buffer.c buf[ head++ ] = c; /* access to a 256 byte aligned array */
18048 \begin_inset LatexCommand index
18049 name "Aligned array"
18050
18051 \end_inset
18052
18053
18054 \newline
18055 \InsetSpace ~
18056 \InsetSpace ~
18057 \InsetSpace ~
18058 \InsetSpace ~
18059 mov\InsetSpace ~
18060 \InsetSpace ~
18061 r3,_head 
18062 \newline
18063 \InsetSpace ~
18064 \InsetSpace ~
18065 \InsetSpace ~
18066 \InsetSpace ~
18067 inc\InsetSpace ~
18068 \InsetSpace ~
18069 _head 
18070 \newline
18071 \InsetSpace ~
18072 \InsetSpace ~
18073 \InsetSpace ~
18074 \InsetSpace ~
18075 mov\InsetSpace ~
18076 \InsetSpace ~
18077 dpl,r3 
18078 \newline
18079 \InsetSpace ~
18080 \InsetSpace ~
18081 \InsetSpace ~
18082 \InsetSpace ~
18083 mov\InsetSpace ~
18084 \InsetSpace ~
18085 dph,#(_buf >> 8) 
18086 \newline
18087 \InsetSpace ~
18088 \InsetSpace ~
18089 \InsetSpace ~
18090 \InsetSpace ~
18091 mov\InsetSpace ~
18092 \InsetSpace ~
18093 a,r2 
18094 \newline
18095 \InsetSpace ~
18096 \InsetSpace ~
18097 \InsetSpace ~
18098 \InsetSpace ~
18099 movx @dptr,a
18100  
18101 \newline
18102 00103$: 
18103 \newline
18104 \InsetSpace ~
18105 \InsetSpace ~
18106 \InsetSpace ~
18107 \InsetSpace ~
18108 ret
18109 \newline
18110 \InsetSpace ~
18111 \InsetSpace ~
18112 \InsetSpace ~
18113 \InsetSpace ~
18114 _endasm
18115 \begin_inset LatexCommand index
18116 name "\\_endasm"
18117
18118 \end_inset
18119
18120
18121 \begin_inset LatexCommand index
18122 name "\\_\\_endasm"
18123
18124 \end_inset
18125
18126 ;
18127 \newline
18128
18129 \end_layout
18130
18131 \begin_layout Standard
18132 The new file buffer.c should compile with only one warning about the unreferenced
18133  function argument 'c'.
18134  Now we hand-optimize the assembly code and insert an #define USE_ASSEMBLY
18135  (1) and finally have:
18136 \end_layout
18137
18138 \begin_layout Verse
18139
18140 \family typewriter
18141 \size footnotesize
18142 unsigned char __far __at(0x7f00) buf[0x100];
18143 \newline
18144 unsigned char head, tail;
18145 \newline
18146 #define
18147  USE_ASSEMBLY (1)
18148 \newline
18149
18150 \newline
18151 #if !USE_ASSEMBLY
18152 \newline
18153
18154 \newline
18155 void to_buffer( unsigned char c )
18156 \newline
18157 {
18158 \newline
18159 \InsetSpace ~
18160 \InsetSpace ~
18161 \InsetSpace ~
18162 \InsetSpace ~
18163 if(
18164  head != (unsigned char)(tail-1) )
18165 \newline
18166 \InsetSpace ~
18167 \InsetSpace ~
18168 \InsetSpace ~
18169 \InsetSpace ~
18170 \InsetSpace ~
18171 \InsetSpace ~
18172 \InsetSpace ~
18173 \InsetSpace ~
18174 buf[ head++ ] = c;
18175 \newline
18176 }
18177 \newline
18178
18179 \newline
18180 #else
18181 \newline
18182
18183 \newline
18184 void to_buffer(
18185  unsigned char c )
18186 \newline
18187 {
18188 \newline
18189 \InsetSpace ~
18190 \InsetSpace ~
18191 \InsetSpace ~
18192 \InsetSpace ~
18193 c; // to avoid warning: unreferenced function argument
18194 \newline
18195 \InsetSpace ~
18196 \InsetSpace ~
18197 \InsetSpace ~
18198 \InsetSpace ~
18199 _asm
18200 \begin_inset LatexCommand index
18201 name "\\_asm"
18202
18203 \end_inset
18204
18205
18206 \begin_inset LatexCommand index
18207 name "\\_\\_asm"
18208
18209 \end_inset
18210
18211
18212 \newline
18213 \InsetSpace ~
18214 \InsetSpace ~
18215 \InsetSpace ~
18216 \InsetSpace ~
18217 \InsetSpace ~
18218 \InsetSpace ~
18219 \InsetSpace ~
18220 \InsetSpace ~
18221 ; save used registers here.
18222  
18223 \newline
18224 \InsetSpace ~
18225 \InsetSpace ~
18226 \InsetSpace ~
18227 \InsetSpace ~
18228 \InsetSpace ~
18229 \InsetSpace ~
18230 \InsetSpace ~
18231 \InsetSpace ~
18232 ; If we were still using r2,r3 we would have to push them here.
18233  
18234 \newline
18235 ; if( head != (unsigned char)(tail-1) )
18236 \newline
18237 \InsetSpace ~
18238 \InsetSpace ~
18239 \InsetSpace ~
18240 \InsetSpace ~
18241 \InsetSpace ~
18242 \InsetSpace ~
18243 \InsetSpace ~
18244 \InsetSpace ~
18245 mov\InsetSpace ~
18246  a,_tail
18247 \newline
18248 \InsetSpace ~
18249 \InsetSpace ~
18250 \InsetSpace ~
18251 \InsetSpace ~
18252 \InsetSpace ~
18253 \InsetSpace ~
18254 \InsetSpace ~
18255 \InsetSpace ~
18256 dec\InsetSpace ~
18257  a
18258 \newline
18259 \InsetSpace ~
18260 \InsetSpace ~
18261 \InsetSpace ~
18262 \InsetSpace ~
18263 \InsetSpace ~
18264 \InsetSpace ~
18265 \InsetSpace ~
18266 \InsetSpace ~
18267 xrl\InsetSpace ~
18268  a,_head
18269 \newline
18270 \InsetSpace ~
18271 \InsetSpace ~
18272 \InsetSpace ~
18273 \InsetSpace ~
18274 \InsetSpace ~
18275 \InsetSpace ~
18276 \InsetSpace ~
18277 \InsetSpace ~
18278 ; we
18279  could do an ANL a,#0x0f here to use a smaller buffer (see below)
18280 \newline
18281 \InsetSpace ~
18282 \InsetSpace ~
18283 \InsetSpace ~
18284 \InsetSpace ~
18285 \InsetSpace ~
18286 \InsetSpace ~
18287 \InsetSpace ~
18288 \InsetSpace ~
18289 jz\InsetSpace ~
18290 \InsetSpace ~
18291  t_b_end$
18292 \newline
18293 \InsetSpace ~
18294 \InsetSpace ~
18295 \InsetSpace ~
18296 \InsetSpace ~
18297 \InsetSpace ~
18298 \InsetSpace ~
18299 \InsetSpace ~
18300 \InsetSpace ~
18301 ;
18302 \newline
18303 ;
18304  buf[ head++ ] = c;
18305 \newline
18306 \InsetSpace ~
18307 \InsetSpace ~
18308 \InsetSpace ~
18309 \InsetSpace ~
18310 \InsetSpace ~
18311 \InsetSpace ~
18312 \InsetSpace ~
18313 \InsetSpace ~
18314 mov\InsetSpace ~
18315  a,dpl \InsetSpace ~
18316 \InsetSpace ~
18317 \InsetSpace ~
18318 \InsetSpace ~
18319 \InsetSpace ~
18320 \InsetSpace ~
18321 \InsetSpace ~
18322 ; dpl holds lower byte of function argument
18323 \newline
18324 \InsetSpace ~
18325 \InsetSpace ~
18326 \InsetSpace ~
18327 \InsetSpace ~
18328 \InsetSpace ~
18329 \InsetSpace ~
18330 \InsetSpace ~
18331 \InsetSpace ~
18332 mov\InsetSpace ~
18333
18334  dpl,_head \InsetSpace ~
18335 \InsetSpace ~
18336 \InsetSpace ~
18337 ; buf is 0x100 byte aligned so head can be used directly
18338 \newline
18339 \InsetSpace ~
18340 \InsetSpace ~
18341 \InsetSpace ~
18342 \InsetSpace ~
18343 \InsetSpace ~
18344 \InsetSpace ~
18345 \InsetSpace ~
18346 \InsetSpace ~
18347 mov\InsetSpace ~
18348  dph,#(_bu
18349 f>>8)
18350 \newline
18351 \InsetSpace ~
18352 \InsetSpace ~
18353 \InsetSpace ~
18354 \InsetSpace ~
18355 \InsetSpace ~
18356 \InsetSpace ~
18357 \InsetSpace ~
18358 \InsetSpace ~
18359 movx @dptr,a
18360 \newline
18361 \InsetSpace ~
18362 \InsetSpace ~
18363 \InsetSpace ~
18364 \InsetSpace ~
18365 \InsetSpace ~
18366 \InsetSpace ~
18367 \InsetSpace ~
18368 \InsetSpace ~
18369 inc \InsetSpace ~
18370 _head
18371 \newline
18372 \InsetSpace ~
18373 \InsetSpace ~
18374 \InsetSpace ~
18375 \InsetSpace ~
18376 \InsetSpace ~
18377 \InsetSpace ~
18378 \InsetSpace ~
18379 \InsetSpace ~
18380 ; we could do an ANL _head,#0x0f here to use a
18381  smaller buffer (see above)
18382 \newline
18383 t_b_end$:
18384 \newline
18385 \InsetSpace ~
18386 \InsetSpace ~
18387 \InsetSpace ~
18388 \InsetSpace ~
18389 \InsetSpace ~
18390 \InsetSpace ~
18391 \InsetSpace ~
18392 \InsetSpace ~
18393 ; restore used registers here 
18394 \newline
18395 \InsetSpace ~
18396 \InsetSpace ~
18397 \InsetSpace ~
18398 \InsetSpace ~
18399 _endasm
18400 \begin_inset LatexCommand index
18401 name "\\_endasm"
18402
18403 \end_inset
18404
18405
18406 \begin_inset LatexCommand index
18407 name "\\_\\_endasm"
18408
18409 \end_inset
18410
18411 ;
18412 \newline
18413 }
18414 \newline
18415 #endif
18416 \end_layout
18417
18418 \begin_layout Standard
18419 The inline assembler code can contain any valid code understood by the assembler
18420 , this includes any assembler directives and comment lines.
18421  The assembler does not like some characters like ':' or ''' in comments.
18422  You'll find an 100+ pages assembler manual in sdcc/as/doc/asxhtm.html
18423 \begin_inset LatexCommand index
18424 name "asXXXX (as-gbz80, as-hc08, asx8051, as-z80)"
18425
18426 \end_inset
18427
18428
18429 \begin_inset LatexCommand index
18430 name "Assembler documentation"
18431
18432 \end_inset
18433
18434  or online at 
18435 \begin_inset LatexCommand url
18436 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html"
18437
18438 \end_inset
18439
18440 \InsetSpace ~
18441 .
18442 \end_layout
18443
18444 \begin_layout Standard
18445 The compiler does not do any validation of the code within the 
18446 \family typewriter
18447 _asm
18448 \begin_inset LatexCommand index
18449 name "\\_asm"
18450
18451 \end_inset
18452
18453
18454 \begin_inset LatexCommand index
18455 name "\\_\\_asm"
18456
18457 \end_inset
18458
18459  ...
18460  _endasm
18461 \size footnotesize
18462
18463 \begin_inset LatexCommand index
18464 name "\\_endasm"
18465
18466 \end_inset
18467
18468
18469 \begin_inset LatexCommand index
18470 name "\\_\\_endasm"
18471
18472 \end_inset
18473
18474
18475 \size default
18476 ;
18477 \family default
18478  keyword pair.
18479  Specifically it will not know which registers are used and thus register
18480  pushing/popping
18481 \begin_inset LatexCommand index
18482 name "push/pop"
18483
18484 \end_inset
18485
18486  has to be done manually.
18487  
18488 \end_layout
18489
18490 \begin_layout Standard
18491 It is recommended that each assembly instruction (including labels) be placed
18492  in a separate line (as the example shows).
18493  When the -
18494 \begin_inset ERT
18495 status collapsed
18496
18497 \begin_layout Standard
18498
18499
18500 \backslash
18501 /
18502 \end_layout
18503
18504 \end_inset
18505
18506 -
18507 \emph on
18508 peep-asm
18509 \begin_inset LatexCommand index
18510 name "-\\/-peep-asm"
18511
18512 \end_inset
18513
18514
18515 \emph default
18516  command line option is used, the inline assembler code will be passed through
18517  the peephole optimizer
18518 \begin_inset LatexCommand index
18519 name "Peephole optimizer"
18520
18521 \end_inset
18522
18523 .
18524  There are only a few (if any) cases where this option makes sense, it might
18525  cause some unexpected changes in the inline assembler code.
18526  Please go through the peephole optimizer rules defined in file 
18527 \emph on
18528 SDCCpeeph.def
18529 \emph default
18530  before using this option.
18531 \end_layout
18532
18533 \begin_layout Subsection
18534 Naked Functions
18535 \begin_inset LatexCommand label
18536 name "sub:Naked-Functions"
18537
18538 \end_inset
18539
18540
18541 \begin_inset LatexCommand index
18542 name "Naked functions"
18543
18544 \end_inset
18545
18546
18547 \end_layout
18548
18549 \begin_layout Standard
18550 A special keyword may be associated with a function declaring it as 
18551 \emph on
18552 _naked
18553 \begin_inset LatexCommand index
18554 name "\\_naked"
18555
18556 \end_inset
18557
18558
18559 \begin_inset LatexCommand index
18560 name "\\_\\_naked"
18561
18562 \end_inset
18563
18564 .
18565
18566 \emph default
18567  The 
18568 \emph on
18569 _naked
18570 \emph default
18571  function modifier attribute prevents the compiler from generating prologue
18572 \begin_inset LatexCommand index
18573 name "function prologue"
18574
18575 \end_inset
18576
18577  and epilogue
18578 \begin_inset LatexCommand index
18579 name "function epilogue"
18580
18581 \end_inset
18582
18583  code for that function.
18584  This means that the user is entirely responsible for such things as saving
18585  any registers that may need to be preserved, selecting the proper register
18586  bank, generating the 
18587 \emph on
18588 return
18589 \emph default
18590  instruction at the end, etc.
18591  Practically, this means that the contents of the function must be written
18592  in inline assembler.
18593  This is particularly useful for interrupt functions, which can have a large
18594  (and often unnecessary) prologue/epilogue.
18595  For example, compare the code generated by these two functions:
18596 \end_layout
18597
18598 \begin_layout Verse
18599
18600 \family typewriter
18601 volatile
18602 \begin_inset LatexCommand index
18603 name "volatile"
18604
18605 \end_inset
18606
18607  data unsigned char counter;
18608 \newline
18609
18610 \newline
18611 void simpleInterrupt(void) __interrupt
18612 \begin_inset LatexCommand index
18613 name "interrupt"
18614
18615 \end_inset
18616
18617
18618 \begin_inset LatexCommand index
18619 name "\\_\\_interrupt"
18620
18621 \end_inset
18622
18623  (1)
18624 \newline
18625 {
18626 \newline
18627 \InsetSpace ~
18628 \InsetSpace ~
18629 \InsetSpace ~
18630 \InsetSpace ~
18631 counter++;
18632 \newline
18633 }
18634 \newline
18635
18636 \newline
18637 void nakedInterrupt(void) __interrupt (2) __naked
18638 \newline
18639 {
18640 \newline
18641 \InsetSpace ~
18642 \InsetSpace ~
18643 \InsetSpace ~
18644 \InsetSpace ~
18645 _asm
18646 \begin_inset LatexCommand index
18647 name "\\_asm"
18648
18649 \end_inset
18650
18651
18652 \begin_inset LatexCommand index
18653 name "\\_\\_asm"
18654
18655 \end_inset
18656
18657
18658 \newline
18659 \InsetSpace ~
18660 \InsetSpace ~
18661 \InsetSpace ~
18662 \InsetSpace ~
18663 \InsetSpace ~
18664 \InsetSpace ~
18665 inc\InsetSpace ~
18666 \InsetSpace ~
18667 \InsetSpace ~
18668 \InsetSpace ~
18669 \InsetSpace ~
18670 _counter ; does not change flags, no need to save psw
18671 \newline
18672 \InsetSpace ~
18673 \InsetSpace ~
18674 \InsetSpace ~
18675 \InsetSpace ~
18676 \InsetSpace ~
18677 \InsetSpace ~
18678 reti\InsetSpace ~
18679 \InsetSpace ~
18680 \InsetSpace ~
18681 \InsetSpace ~
18682 ; MUST explicitly
18683  include ret or reti in _naked function.
18684 \newline
18685 \InsetSpace ~
18686 \InsetSpace ~
18687 \InsetSpace ~
18688 \InsetSpace ~
18689 _endasm
18690 \begin_inset LatexCommand index
18691 name "\\_endasm"
18692
18693 \end_inset
18694
18695
18696 \begin_inset LatexCommand index
18697 name "\\_\\_endasm"
18698
18699 \end_inset
18700
18701 ;
18702 \newline
18703 }
18704 \end_layout
18705
18706 \begin_layout Standard
18707 For an 8051 target, the generated simpleInterrupt looks like:
18708 \end_layout
18709
18710 \begin_layout Verse
18711
18712 \family typewriter
18713 Note, this is an
18714 \family default
18715  
18716 \family typewriter
18717 \emph on
18718 outdated
18719 \family default
18720 \emph default
18721  
18722 \family typewriter
18723 example, recent versions of SDCC generate
18724 \newline
18725 the
18726 \family default
18727  
18728 \family typewriter
18729 \emph on
18730 same
18731 \family default
18732 \emph default
18733  
18734 \family typewriter
18735 code for simpleInterrupt() and nakedInterrupt()!
18736 \newline
18737
18738 \newline
18739 _simpleInterrupt:
18740 \newline
18741 \InsetSpace ~
18742 \InsetSpace ~
18743 \InsetSpace ~
18744 \InsetSpace ~
18745 push\InsetSpace ~
18746 \InsetSpace ~
18747 \InsetSpace ~
18748 \InsetSpace ~
18749 acc
18750 \newline
18751 \InsetSpace ~
18752 \InsetSpace ~
18753 \InsetSpace ~
18754 \InsetSpace ~
18755 push\InsetSpace ~
18756 \InsetSpace ~
18757 \InsetSpace ~
18758 \InsetSpace ~
18759 b
18760 \newline
18761 \InsetSpace ~
18762 \InsetSpace ~
18763 \InsetSpace ~
18764 \InsetSpace ~
18765 pus
18766 h\InsetSpace ~
18767 \InsetSpace ~
18768 \InsetSpace ~
18769 \InsetSpace ~
18770 dpl
18771 \newline
18772 \InsetSpace ~
18773 \InsetSpace ~
18774 \InsetSpace ~
18775 \InsetSpace ~
18776 push\InsetSpace ~
18777 \InsetSpace ~
18778 \InsetSpace ~
18779 \InsetSpace ~
18780 dph
18781 \newline
18782 \InsetSpace ~
18783 \InsetSpace ~
18784 \InsetSpace ~
18785 \InsetSpace ~
18786 push\InsetSpace ~
18787 \InsetSpace ~
18788 \InsetSpace ~
18789 \InsetSpace ~
18790 psw
18791 \newline
18792 \InsetSpace ~
18793 \InsetSpace ~
18794 \InsetSpace ~
18795 \InsetSpace ~
18796 mov\InsetSpace ~
18797 \InsetSpace ~
18798 \InsetSpace ~
18799 \InsetSpace ~
18800 \InsetSpace ~
18801 psw,#0x00
18802 \newline
18803 \InsetSpace ~
18804 \InsetSpace ~
18805 \InsetSpace ~
18806 \InsetSpace ~
18807 inc\InsetSpace ~
18808 \InsetSpace ~
18809 \InsetSpace ~
18810 \InsetSpace ~
18811 \InsetSpace ~
18812 _counter
18813 \newline
18814 \InsetSpace ~
18815 \InsetSpace ~
18816 \InsetSpace ~
18817 \InsetSpace ~
18818 pop\InsetSpace ~
18819 \InsetSpace ~
18820 \InsetSpace ~
18821 \InsetSpace ~
18822 \InsetSpace ~
18823 psw
18824 \newline
18825 \InsetSpace ~
18826 \InsetSpace ~
18827 \InsetSpace ~
18828 \InsetSpace ~
18829 pop\InsetSpace ~
18830 \InsetSpace ~
18831 \InsetSpace ~
18832 \InsetSpace ~
18833 \InsetSpace ~
18834 dph
18835 \newline
18836 \InsetSpace ~
18837 \InsetSpace ~
18838 \InsetSpace ~
18839 \InsetSpace ~
18840 pop\InsetSpace ~
18841 \InsetSpace ~
18842 \InsetSpace ~
18843 \InsetSpace ~
18844 \InsetSpace ~
18845 dpl
18846 \newline
18847 \InsetSpace ~
18848 \InsetSpace ~
18849 \InsetSpace ~
18850 \InsetSpace ~
18851 pop\InsetSpace ~
18852 \InsetSpace ~
18853 \InsetSpace ~
18854 \InsetSpace ~
18855 \InsetSpace ~
18856 b
18857 \newline
18858 \InsetSpace ~
18859 \InsetSpace ~
18860 \InsetSpace ~
18861 \InsetSpace ~
18862 pop\InsetSpace ~
18863 \InsetSpace ~
18864 \InsetSpace ~
18865 \InsetSpace ~
18866 \InsetSpace ~
18867 acc
18868 \newline
18869 \InsetSpace ~
18870 \InsetSpace ~
18871 \InsetSpace ~
18872 \InsetSpace ~
18873 reti
18874 \end_layout
18875
18876 \begin_layout Standard
18877 whereas nakedInterrupt looks like:
18878 \end_layout
18879
18880 \begin_layout Verse
18881
18882 \family typewriter
18883 _nakedInterrupt:
18884 \newline
18885 \InsetSpace ~
18886 \InsetSpace ~
18887 \InsetSpace ~
18888 \InsetSpace ~
18889 inc\InsetSpace ~
18890 \InsetSpace ~
18891 \InsetSpace ~
18892 \InsetSpace ~
18893 _counter ; does not change flags, no need to save psw
18894 \newline
18895 \InsetSpace ~
18896 \InsetSpace ~
18897 \InsetSpace ~
18898 \InsetSpace ~
18899 reti\InsetSpace ~
18900 \InsetSpace ~
18901 \InsetSpace ~
18902 \InsetSpace ~
18903 \InsetSpace ~
18904 \InsetSpace ~
18905 \InsetSpace ~
18906 \InsetSpace ~
18907 \InsetSpace ~
18908 \InsetSpace ~
18909 \InsetSpace ~
18910 \InsetSpace ~
18911 ;
18912  MUST explicitly include ret or reti in _naked function
18913 \end_layout
18914
18915 \begin_layout Standard
18916 The related directive #pragma exclude
18917 \begin_inset LatexCommand index
18918 name "\\#pragma exclude"
18919
18920 \end_inset
18921
18922  allows a more fine grained control over pushing & popping
18923 \begin_inset LatexCommand index
18924 name "push/pop"
18925
18926 \end_inset
18927
18928  the registers.
18929 \end_layout
18930
18931 \begin_layout Standard
18932 While there is nothing preventing you from writing C code inside a 
18933 \family typewriter
18934 _naked
18935 \family default
18936  function, there are many ways to shoot yourself in the foot doing this,
18937  and it is recommended that you stick to inline assembler.
18938 \end_layout
18939
18940 \begin_layout Subsection
18941 Use of Labels within Inline Assembler
18942 \end_layout
18943
18944 \begin_layout Standard
18945 SDCC allows the use of in-line assembler with a few restrictions regarding
18946  labels.
18947  All labels defined within inline assembler code have to be of the form
18948  
18949 \emph on
18950 nnnnn$
18951 \emph default
18952  where nnnnn is a number less than 100 (which implies a limit of utmost
18953  100 inline assembler labels 
18954 \emph on
18955 per function
18956 \emph default
18957 \noun on
18958 )
18959 \noun default
18960 .
18961 \begin_inset Foot
18962 status open
18963
18964 \begin_layout Standard
18965 This is a slightly more stringent rule than absolutely necessary, but stays
18966  always on the safe side.
18967  Labels in the form of nnnnn$ are local labels in the assembler, locality
18968  of which is confined within two labels of the standard form.
18969  The compiler uses the same form for labels within a function (but starting
18970  from nnnnn=00100); and places always a standard label at the beginning
18971  of a function, thus limiting the locality of labels within the scope of
18972  the function.
18973  So, if the inline assembler part would be embedded into C-code, an improperly
18974  placed non-local label in the assembler would break up the reference space
18975  for labels created by the compiler for the C-code, leading to an assembling
18976  error.
18977 \end_layout
18978
18979 \begin_layout Standard
18980 The numeric part of local labels does not need to have 5 digits (although
18981  this is the form of labels output by the compiler), any valid integer will
18982  do.
18983  Please refer to the assemblers documentation for further details.
18984 \end_layout
18985
18986 \end_inset
18987
18988  
18989 \end_layout
18990
18991 \begin_layout Verse
18992
18993 \family typewriter
18994 _asm
18995 \begin_inset LatexCommand index
18996 name "\\_asm"
18997
18998 \end_inset
18999
19000
19001 \begin_inset LatexCommand index
19002 name "\\_\\_asm"
19003
19004 \end_inset
19005
19006  
19007 \newline
19008 \InsetSpace ~
19009 \InsetSpace ~
19010 \InsetSpace ~
19011 \InsetSpace ~
19012 mov\InsetSpace ~
19013 \InsetSpace ~
19014 \InsetSpace ~
19015 \InsetSpace ~
19016 \InsetSpace ~
19017 b,#10 
19018 \newline
19019 00001$: 
19020 \newline
19021 \InsetSpace ~
19022 \InsetSpace ~
19023 \InsetSpace ~
19024 \InsetSpace ~
19025 djnz\InsetSpace ~
19026 \InsetSpace ~
19027 \InsetSpace ~
19028 \InsetSpace ~
19029 b,00001$ 
19030 \newline
19031 _endasm
19032 \begin_inset LatexCommand index
19033 name "\\_endasm"
19034
19035 \end_inset
19036
19037
19038 \begin_inset LatexCommand index
19039 name "\\_\\_endasm"
19040
19041 \end_inset
19042
19043  ;
19044 \end_layout
19045
19046 \begin_layout Standard
19047 Inline assembler code cannot reference any C-labels, however it can reference
19048  labels
19049 \begin_inset LatexCommand index
19050 name "Labels"
19051
19052 \end_inset
19053
19054  defined by the inline assembler, e.g.:
19055 \end_layout
19056
19057 \begin_layout Verse
19058
19059 \family typewriter
19060 foo() { 
19061 \newline
19062 \InsetSpace ~
19063 \InsetSpace ~
19064 \InsetSpace ~
19065 \InsetSpace ~
19066 /* some c code */ 
19067 \newline
19068 \InsetSpace ~
19069 \InsetSpace ~
19070 \InsetSpace ~
19071 \InsetSpace ~
19072 _asm 
19073 \newline
19074 \InsetSpace ~
19075 \InsetSpace ~
19076 \InsetSpace ~
19077 \InsetSpace ~
19078 \InsetSpace ~
19079 \InsetSpace ~
19080 ; some assembler code 
19081 \newline
19082 \InsetSpace ~
19083 \InsetSpace ~
19084 \InsetSpace ~
19085 \InsetSpace ~
19086 \InsetSpace ~
19087 \InsetSpace ~
19088 ljmp 0003$ 
19089 \newline
19090 \InsetSpace ~
19091 \InsetSpace ~
19092 \InsetSpace ~
19093 \InsetSpace ~
19094 _endasm;
19095  
19096 \newline
19097 \InsetSpace ~
19098 \InsetSpace ~
19099 \InsetSpace ~
19100 \InsetSpace ~
19101 /* some more c code */ 
19102 \newline
19103 clabel:\InsetSpace ~
19104 \InsetSpace ~
19105 /* inline assembler cannot reference this
19106  label */ 
19107 \begin_inset Foot
19108 status open
19109
19110 \begin_layout Standard
19111 Here, the C-label 
19112 \family typewriter
19113 clabel
19114 \family default
19115  is translated by the compiler into a local label, so the locality of labels
19116  within the function is not broken.
19117 \end_layout
19118
19119 \end_inset
19120
19121
19122 \newline
19123 \InsetSpace ~
19124 \InsetSpace ~
19125 \InsetSpace ~
19126 \InsetSpace ~
19127 _asm
19128 \newline
19129 \InsetSpace ~
19130 \InsetSpace ~
19131 \InsetSpace ~
19132 \InsetSpace ~
19133 0003$: ;label (can be referenced by inline assembler only) 
19134 \newline
19135 \InsetSpace ~
19136 \InsetSpace ~
19137 \InsetSpace ~
19138 \InsetSpace ~
19139 _endasm
19140 \begin_inset LatexCommand index
19141 name "\\_endasm"
19142
19143 \end_inset
19144
19145
19146 \begin_inset LatexCommand index
19147 name "\\_\\_endasm"
19148
19149 \end_inset
19150
19151  ; 
19152 \newline
19153 \InsetSpace ~
19154 \InsetSpace ~
19155 \InsetSpace ~
19156 \InsetSpace ~
19157 /* some more c code */
19158 \newline
19159 }
19160 \end_layout
19161
19162 \begin_layout Standard
19163 In other words inline assembly code can access labels defined in inline
19164  assembly within the scope of the function.
19165  The same goes the other way, i.e.
19166  labels defines in inline assembly can not be accessed by C statements.
19167 \end_layout
19168
19169 \begin_layout Section
19170 Interfacing with Assembler Code
19171 \begin_inset LatexCommand index
19172 name "Assembler routines"
19173
19174 \end_inset
19175
19176
19177 \end_layout
19178
19179 \begin_layout Subsection
19180 Global Registers used for Parameter Passing
19181 \begin_inset LatexCommand index
19182 name "Parameter passing"
19183
19184 \end_inset
19185
19186
19187 \end_layout
19188
19189 \begin_layout Standard
19190 The compiler always uses the global registers 
19191 \emph on
19192 DPL, DPH
19193 \begin_inset LatexCommand index
19194 name "DPTR, DPH, DPL"
19195
19196 \end_inset
19197
19198
19199 \begin_inset LatexCommand index
19200 name "DPTR"
19201
19202 \end_inset
19203
19204 , B
19205 \begin_inset LatexCommand index
19206 name "B (mcs51, ds390 register)"
19207
19208 \end_inset
19209
19210
19211 \emph default
19212  and 
19213 \emph on
19214 ACC
19215 \begin_inset LatexCommand index
19216 name "ACC (mcs51, ds390 register)"
19217
19218 \end_inset
19219
19220
19221 \emph default
19222  to pass the first (non-bit) parameter to a function, and also to pass the
19223  return value 
19224 \begin_inset LatexCommand index
19225 name "return value"
19226
19227 \end_inset
19228
19229 of function; according to the following scheme: one byte return value in
19230  
19231 \emph on
19232 DPL
19233 \emph default
19234 , two byte value in 
19235 \emph on
19236 DPL
19237 \emph default
19238  (LSB) and 
19239 \emph on
19240 DPH
19241 \emph default
19242  (MSB).
19243  three byte values (generic pointers) in 
19244 \emph on
19245 DPH
19246 \emph default
19247
19248 \emph on
19249 DPL
19250 \emph default
19251  and 
19252 \emph on
19253 B
19254 \emph default
19255 , and four byte values in 
19256 \emph on
19257 DPH
19258 \emph default
19259
19260 \emph on
19261 DPL
19262 \emph default
19263
19264 \emph on
19265 B
19266 \emph default
19267  and 
19268 \emph on
19269 ACC
19270 \emph default
19271 .
19272  Generic pointers
19273 \begin_inset LatexCommand index
19274 name "generic pointer"
19275
19276 \end_inset
19277
19278  contain type of accessed memory in 
19279 \emph on
19280 B
19281 \emph default
19282
19283 \series bold
19284 0x00
19285 \series default
19286  -- xdata/far, 
19287 \series bold
19288 0x40
19289 \series default
19290  -- idata/near -- , 
19291 \series bold
19292 0x60
19293 \series default
19294  -- pdata, 
19295 \series bold
19296 0x80
19297 \series default
19298  -- code
19299 \begin_inset Note Note
19300 status collapsed
19301
19302 \begin_layout Standard
19303 This might not be the case of certain memory models (medium???)
19304 \end_layout
19305
19306 \end_inset
19307
19308 .
19309 \end_layout
19310
19311 \begin_layout Standard
19312 The second parameter onwards is either allocated on the stack (for reentrant
19313  routines or if -
19314 \begin_inset ERT
19315 status collapsed
19316
19317 \begin_layout Standard
19318
19319
19320 \backslash
19321 /
19322 \end_layout
19323
19324 \end_inset
19325
19326 -stack-auto is used) or in data/xdata memory (depending on the memory model).
19327 \end_layout
19328
19329 \begin_layout Standard
19330 Bit parameters are passed in a virtual register called 'bits' in bit-addressable
19331  space for reentrant functions or allocated directly in bit memory otherwise.
19332 \end_layout
19333
19334 \begin_layout Standard
19335 Functions (with two or more parameters or bit parameters) that are called
19336  through function pointers
19337 \begin_inset LatexCommand index
19338 name "function pointers"
19339
19340 \end_inset
19341
19342  must therefor be reentrant so the compiler knows how to pass the parameters.
19343 \end_layout
19344
19345 \begin_layout Subsection
19346 Registers usage
19347 \end_layout
19348
19349 \begin_layout Standard
19350 Unless the called function is declared as 
19351 \family typewriter
19352 _naked
19353 \family default
19354
19355 \begin_inset LatexCommand index
19356 name "naked"
19357
19358 \end_inset
19359
19360 , or the -
19361 \begin_inset ERT
19362 status collapsed
19363
19364 \begin_layout Standard
19365
19366
19367 \backslash
19368 /
19369 \end_layout
19370
19371 \end_inset
19372
19373 -callee-saves
19374 \begin_inset LatexCommand index
19375 name "-\\/-callee-saves"
19376
19377 \end_inset
19378
19379 /-
19380 \begin_inset ERT
19381 status collapsed
19382
19383 \begin_layout Standard
19384
19385
19386 \backslash
19387 /
19388 \end_layout
19389
19390 \end_inset
19391
19392 -all-callee-saves command line option or the corresponding callee_saves
19393  pragma are used, the caller will save the registers (
19394 \emph on
19395 R0-R7
19396 \emph default
19397 ) around the call, so the called function can destroy they content freely.
19398 \end_layout
19399
19400 \begin_layout Standard
19401 If the called function is not declared as 
19402 \family typewriter
19403 _naked
19404 \family default
19405 , the caller will swap register banks around the call, if caller and callee
19406  use different register banks (having them defined by the 
19407 \family typewriter
19408 _using
19409 \family default
19410  modifier).
19411  
19412 \end_layout
19413
19414 \begin_layout Standard
19415 The called function can also use 
19416 \emph on
19417 DPL
19418 \emph default
19419
19420 \emph on
19421 DPH
19422 \emph default
19423
19424 \emph on
19425 B
19426 \emph default
19427  and 
19428 \emph on
19429 ACC
19430 \emph default
19431  observing that they are used for parameter/return value passing.
19432 \end_layout
19433
19434 \begin_layout Subsection
19435 Assembler Routine (non-reentrant)
19436 \end_layout
19437
19438 \begin_layout Standard
19439 In the following example
19440 \begin_inset LatexCommand index
19441 name "reentrant"
19442
19443 \end_inset
19444
19445
19446 \begin_inset LatexCommand index
19447 name "Assembler routines (non-reentrant)"
19448
19449 \end_inset
19450
19451  the function c_func calls an assembler routine asm_func, which takes two
19452  parameters
19453 \begin_inset LatexCommand index
19454 name "function parameter"
19455
19456 \end_inset
19457
19458 .
19459 \end_layout
19460
19461 \begin_layout Verse
19462
19463 \family typewriter
19464 extern int asm_func(unsigned char, unsigned char);
19465 \newline
19466
19467 \newline
19468 int c_func (unsigned char
19469  i, unsigned char j)
19470 \newline
19471 {
19472 \newline
19473 \InsetSpace ~
19474 \InsetSpace ~
19475 \InsetSpace ~
19476 \InsetSpace ~
19477 return asm_func(i,j);
19478 \newline
19479 }
19480 \newline
19481
19482 \newline
19483 int main()
19484 \newline
19485 {
19486 \newline
19487 \InsetSpace ~
19488 \InsetSpace ~
19489 \InsetSpace ~
19490 \InsetSpace ~
19491 return c_func(10,9);
19492 \newline
19493 }
19494 \end_layout
19495
19496 \begin_layout Standard
19497 The corresponding assembler function is:
19498 \end_layout
19499
19500 \begin_layout Verse
19501
19502 \family typewriter
19503 .globl _asm_func_PARM_2 
19504 \newline
19505 \InsetSpace ~
19506 \InsetSpace ~
19507 \InsetSpace ~
19508 \InsetSpace ~
19509 \InsetSpace ~
19510 \InsetSpace ~
19511 \InsetSpace ~
19512 \InsetSpace ~
19513 .globl _asm_func 
19514 \newline
19515 \InsetSpace ~
19516 \InsetSpace ~
19517 \InsetSpace ~
19518 \InsetSpace ~
19519 \InsetSpace ~
19520 \InsetSpace ~
19521 \InsetSpace ~
19522 \InsetSpace ~
19523 .area OSEG 
19524 \newline
19525 _asm_func_PARM_2:
19526 \newline
19527 \InsetSpace ~
19528 \InsetSpace ~
19529 \InsetSpace ~
19530 \InsetSpace ~
19531 \InsetSpace ~
19532 \InsetSpace ~
19533 \InsetSpace ~
19534 \InsetSpace ~
19535 .ds   
19536  1 
19537 \newline
19538 \InsetSpace ~
19539 \InsetSpace ~
19540 \InsetSpace ~
19541 \InsetSpace ~
19542 \InsetSpace ~
19543 \InsetSpace ~
19544 \InsetSpace ~
19545 \InsetSpace ~
19546 .area CSEG 
19547 \newline
19548 _asm_func: 
19549 \newline
19550 \InsetSpace ~
19551 \InsetSpace ~
19552 \InsetSpace ~
19553 \InsetSpace ~
19554 \InsetSpace ~
19555 \InsetSpace ~
19556 \InsetSpace ~
19557 \InsetSpace ~
19558 mov\InsetSpace ~
19559 \InsetSpace ~
19560 \InsetSpace ~
19561 \InsetSpace ~
19562 a,dpl 
19563 \newline
19564 \InsetSpace ~
19565 \InsetSpace ~
19566 \InsetSpace ~
19567 \InsetSpace ~
19568 \InsetSpace ~
19569 \InsetSpace ~
19570 \InsetSpace ~
19571 \InsetSpace ~
19572 add\InsetSpace ~
19573 \InsetSpace ~
19574 \InsetSpace ~
19575 \InsetSpace ~
19576 a,_asm_func_PARM_2 
19577 \newline
19578 \InsetSpace ~
19579 \InsetSpace ~
19580 \InsetSpace ~
19581 \InsetSpace ~
19582 \InsetSpace ~
19583 \InsetSpace ~
19584 \InsetSpace ~
19585 \InsetSpace ~
19586 mov\InsetSpace ~
19587 \InsetSpace ~
19588 \InsetSpace ~
19589 \InsetSpace ~
19590 dpl,a 
19591 \newline
19592 \InsetSpace ~
19593 \InsetSpace ~
19594 \InsetSpace ~
19595 \InsetSpace ~
19596 \InsetSpace ~
19597 \InsetSpace ~
19598 \InsetSpace ~
19599 \InsetSpace ~
19600 mov\InsetSpace ~
19601 \InsetSpace ~
19602 \InsetSpace ~
19603 \InsetSpace ~
19604 dph
19605 \begin_inset LatexCommand index
19606 name "DPTR, DPH, DPL"
19607
19608 \end_inset
19609
19610 ,#0x00 
19611 \newline
19612 \InsetSpace ~
19613 \InsetSpace ~
19614 \InsetSpace ~
19615 \InsetSpace ~
19616 \InsetSpace ~
19617 \InsetSpace ~
19618 \InsetSpace ~
19619 \InsetSpace ~
19620 ret
19621 \end_layout
19622
19623 \begin_layout Standard
19624 The parameter naming convention is _<function_name>_PARM_<n>, where n is
19625  the parameter number starting from 1, and counting from the left.
19626  The first parameter is passed in 
19627 \emph on
19628 DPH
19629 \emph default
19630
19631 \emph on
19632 DPL
19633 \emph default
19634
19635 \emph on
19636 B
19637 \emph default
19638  and 
19639 \emph on
19640 ACC
19641 \emph default
19642  according to the description above.
19643  The variable name for the second parameter will be _<function_name>_PARM_2.
19644 \newline
19645
19646 \newline
19647 Assem
19648 ble the assembler routine with the following command:
19649 \newline
19650
19651 \newline
19652
19653 \family sans
19654 \series bold
19655 asx8051 -losg asmfunc.asm
19656 \newline
19657
19658 \newline
19659
19660 \family default
19661 \series default
19662 Then compile and link the assembler routine to the C source file with the
19663  following command:
19664 \newline
19665
19666 \newline
19667
19668 \family sans
19669 \series bold
19670 sdcc cfunc.c asmfunc.rel
19671 \end_layout
19672
19673 \begin_layout Subsection
19674 Assembler Routine (reentrant)
19675 \end_layout
19676
19677 \begin_layout Standard
19678 In this case
19679 \begin_inset LatexCommand index
19680 name "reentrant"
19681
19682 \end_inset
19683
19684
19685 \begin_inset LatexCommand index
19686 name "Assembler routines (reentrant)"
19687
19688 \end_inset
19689
19690  the second parameter
19691 \begin_inset LatexCommand index
19692 name "function parameter"
19693
19694 \end_inset
19695
19696  onwards will be passed on the stack, the parameters are pushed from right
19697  to left i.e.
19698  before the call the second leftmost parameter will be on the top of the
19699  stack (the leftmost parameter is passed in registers).
19700  Here is an example:
19701 \end_layout
19702
19703 \begin_layout Verse
19704
19705 \family typewriter
19706 extern int asm_func(unsigned char, unsigned char, unsigned char) reentrant;
19707 \newline
19708
19709 \newline
19710 int
19711  c_func (unsigned char i, unsigned char j, unsigned char k) reentrant 
19712 \newline
19713 {
19714  
19715 \newline
19716 \InsetSpace ~
19717 \InsetSpace ~
19718 \InsetSpace ~
19719 \InsetSpace ~
19720 return asm_func(i,j,k); 
19721 \newline
19722
19723 \newline
19724
19725 \newline
19726 int main() 
19727 \newline
19728
19729 \newline
19730 \InsetSpace ~
19731 \InsetSpace ~
19732 \InsetSpace ~
19733 \InsetSpace ~
19734 return c_func(10,9,8); 
19735 \newline
19736 }
19737 \end_layout
19738
19739 \begin_layout Standard
19740 The corresponding (unoptimized) assembler routine is:
19741 \end_layout
19742
19743 \begin_layout Verse
19744
19745 \family typewriter
19746 .globl _asm_func 
19747 \newline
19748 _asm_func: 
19749 \newline
19750 \InsetSpace ~
19751 \InsetSpace ~
19752 \InsetSpace ~
19753 \InsetSpace ~
19754 push\InsetSpace ~
19755 _bp 
19756 \newline
19757 \InsetSpace ~
19758 \InsetSpace ~
19759 \InsetSpace ~
19760 \InsetSpace ~
19761 mov\InsetSpace ~
19762 \InsetSpace ~
19763 _bp,sp\InsetSpace ~
19764 \InsetSpace ~
19765 \InsetSpace ~
19766 \InsetSpace ~
19767 \InsetSpace ~
19768 \InsetSpace ~
19769 ;stack contains: _bp, return
19770  address, second parameter, third parameter
19771 \newline
19772 \InsetSpace ~
19773 \InsetSpace ~
19774 \InsetSpace ~
19775 \InsetSpace ~
19776 mov\InsetSpace ~
19777 \InsetSpace ~
19778 r2,dpl
19779 \newline
19780 \InsetSpace ~
19781 \InsetSpace ~
19782 \InsetSpace ~
19783 \InsetSpace ~
19784 mov\InsetSpace ~
19785 \InsetSpace ~
19786 a,_bp
19787 \newline
19788 \InsetSpace ~
19789 \InsetSpace ~
19790 \InsetSpace ~
19791 \InsetSpace ~
19792 add\InsetSpace ~
19793 \InsetSpace ~
19794 a,#0xfd\InsetSpace ~
19795 \InsetSpace ~
19796 \InsetSpace ~
19797 \InsetSpace ~
19798 \InsetSpace ~
19799 ;calculate
19800  pointer to the second parameter
19801 \newline
19802 \InsetSpace ~
19803 \InsetSpace ~
19804 \InsetSpace ~
19805 \InsetSpace ~
19806 mov\InsetSpace ~
19807 \InsetSpace ~
19808 r0,a 
19809 \newline
19810 \InsetSpace ~
19811 \InsetSpace ~
19812 \InsetSpace ~
19813 \InsetSpace ~
19814 mov\InsetSpace ~
19815 \InsetSpace ~
19816 a,_bp 
19817 \newline
19818 \InsetSpace ~
19819 \InsetSpace ~
19820 \InsetSpace ~
19821 \InsetSpace ~
19822 add\InsetSpace ~
19823 \InsetSpace ~
19824 a,#0xfc\InsetSpace ~
19825 \InsetSpace ~
19826 \InsetSpace ~
19827 \InsetSpace ~
19828 \InsetSpace ~
19829 ;calculate pointer
19830  to the rightmost parameter
19831 \newline
19832 \InsetSpace ~
19833 \InsetSpace ~
19834 \InsetSpace ~
19835 \InsetSpace ~
19836 mov\InsetSpace ~
19837 \InsetSpace ~
19838 r1,a 
19839 \newline
19840 \InsetSpace ~
19841 \InsetSpace ~
19842 \InsetSpace ~
19843 \InsetSpace ~
19844 mov\InsetSpace ~
19845 \InsetSpace ~
19846 a,@r0
19847 \newline
19848 \InsetSpace ~
19849 \InsetSpace ~
19850 \InsetSpace ~
19851 \InsetSpace ~
19852 add\InsetSpace ~
19853 \InsetSpace ~
19854 a,@r1
19855 \newline
19856 \InsetSpace ~
19857 \InsetSpace ~
19858 \InsetSpace ~
19859 \InsetSpace ~
19860 add\InsetSpace ~
19861 \InsetSpace ~
19862 a,r2\InsetSpace ~
19863 \InsetSpace ~
19864 \InsetSpace ~
19865 \InsetSpace ~
19866 \InsetSpace ~
19867 \InsetSpace ~
19868 \InsetSpace ~
19869 \InsetSpace ~
19870 ;calculate the
19871  result (= sum of all three parameters)
19872 \newline
19873 \InsetSpace ~
19874 \InsetSpace ~
19875 \InsetSpace ~
19876 \InsetSpace ~
19877 mov\InsetSpace ~
19878 \InsetSpace ~
19879 dpl,a\InsetSpace ~
19880 \InsetSpace ~
19881 \InsetSpace ~
19882 \InsetSpace ~
19883 \InsetSpace ~
19884 \InsetSpace ~
19885 \InsetSpace ~
19886 ;return value goes into dptr
19887  (cast into int)
19888 \newline
19889 \InsetSpace ~
19890 \InsetSpace ~
19891 \InsetSpace ~
19892 \InsetSpace ~
19893 mov\InsetSpace ~
19894 \InsetSpace ~
19895 dph,#0x00 
19896 \newline
19897 \InsetSpace ~
19898 \InsetSpace ~
19899 \InsetSpace ~
19900 \InsetSpace ~
19901 mov\InsetSpace ~
19902 \InsetSpace ~
19903 sp,_bp 
19904 \newline
19905 \InsetSpace ~
19906 \InsetSpace ~
19907 \InsetSpace ~
19908 \InsetSpace ~
19909 pop\InsetSpace ~
19910 \InsetSpace ~
19911 _bp 
19912 \newline
19913 \InsetSpace ~
19914 \InsetSpace ~
19915 \InsetSpace ~
19916 \InsetSpace ~
19917 ret
19918 \end_layout
19919
19920 \begin_layout Standard
19921 The compiling and linking procedure remains the same, however note the extra
19922  entry & exit linkage required for the assembler code, _bp is the stack
19923  frame pointer and is used to compute the offset into the stack for parameters
19924  and local variables.
19925 \begin_inset VSpace bigskip
19926 \end_inset
19927
19928
19929 \end_layout
19930
19931 \begin_layout Section
19932 int (16 bit)
19933 \begin_inset LatexCommand index
19934 name "int (16 bit)"
19935
19936 \end_inset
19937
19938  and long (32 bit)
19939 \begin_inset LatexCommand index
19940 name "long (32 bit)"
19941
19942 \end_inset
19943
19944  Support
19945 \end_layout
19946
19947 \begin_layout Standard
19948 For signed & unsigned int (16 bit) and long (32 bit) variables, division,
19949  multiplication and modulus operations are implemented by support routines.
19950  These support routines are all developed in ANSI-C to facilitate porting
19951  to other MCUs, although some model specific assembler optimizations are
19952  used.
19953  The following files contain the described routines, all of them can be
19954  found in <installdir>/share/sdcc/lib.
19955 \newline
19956
19957 \end_layout
19958
19959 \begin_layout Standard
19960 \align center
19961 \begin_inset Tabular
19962 <lyxtabular version="3" rows="11" columns="2">
19963 <features>
19964 <column alignment="left" valignment="top" leftline="true" width="0">
19965 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
19966 <row topline="true" bottomline="true">
19967 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19968 \begin_inset Text
19969
19970 \begin_layout Standard
19971
19972 \series bold
19973 Function
19974 \end_layout
19975
19976 \end_inset
19977 </cell>
19978 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19979 \begin_inset Text
19980
19981 \begin_layout Standard
19982
19983 \series bold
19984 Description
19985 \end_layout
19986
19987 \end_inset
19988 </cell>
19989 </row>
19990 <row topline="true">
19991 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19992 \begin_inset Text
19993
19994 \begin_layout Standard
19995 _mulint.c 
19996 \end_layout
19997
19998 \end_inset
19999 </cell>
20000 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20001 \begin_inset Text
20002
20003 \begin_layout Standard
20004 16 bit multiplication
20005 \end_layout
20006
20007 \end_inset
20008 </cell>
20009 </row>
20010 <row topline="true">
20011 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20012 \begin_inset Text
20013
20014 \begin_layout Standard
20015 _divsint.c 
20016 \end_layout
20017
20018 \end_inset
20019 </cell>
20020 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20021 \begin_inset Text
20022
20023 \begin_layout Standard
20024  signed 16 bit division (calls _divuint)
20025 \end_layout
20026
20027 \end_inset
20028 </cell>
20029 </row>
20030 <row topline="true">
20031 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20032 \begin_inset Text
20033
20034 \begin_layout Standard
20035 _divuint.c 
20036 \end_layout
20037
20038 \end_inset
20039 </cell>
20040 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20041 \begin_inset Text
20042
20043 \begin_layout Standard
20044  unsigned 16 bit division
20045 \end_layout
20046
20047 \end_inset
20048 </cell>
20049 </row>
20050 <row topline="true">
20051 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20052 \begin_inset Text
20053
20054 \begin_layout Standard
20055 _modsint.c
20056 \end_layout
20057
20058 \end_inset
20059 </cell>
20060 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20061 \begin_inset Text
20062
20063 \begin_layout Standard
20064 signed 16 bit modulus (calls _moduint)
20065 \end_layout
20066
20067 \end_inset
20068 </cell>
20069 </row>
20070 <row topline="true">
20071 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20072 \begin_inset Text
20073
20074 \begin_layout Standard
20075 _moduint.c
20076 \end_layout
20077
20078 \end_inset
20079 </cell>
20080 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20081 \begin_inset Text
20082
20083 \begin_layout Standard
20084 unsigned 16 bit modulus
20085 \end_layout
20086
20087 \end_inset
20088 </cell>
20089 </row>
20090 <row topline="true">
20091 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20092 \begin_inset Text
20093
20094 \begin_layout Standard
20095 _mullong.c
20096 \end_layout
20097
20098 \end_inset
20099 </cell>
20100 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20101 \begin_inset Text
20102
20103 \begin_layout Standard
20104 32 bit multiplication
20105 \end_layout
20106
20107 \end_inset
20108 </cell>
20109 </row>
20110 <row topline="true">
20111 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20112 \begin_inset Text
20113
20114 \begin_layout Standard
20115 _divslong.c 
20116 \end_layout
20117
20118 \end_inset
20119 </cell>
20120 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20121 \begin_inset Text
20122
20123 \begin_layout Standard
20124  signed 32 division (calls _divulong)
20125 \end_layout
20126
20127 \end_inset
20128 </cell>
20129 </row>
20130 <row topline="true">
20131 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20132 \begin_inset Text
20133
20134 \begin_layout Standard
20135 _divulong.c 
20136 \end_layout
20137
20138 \end_inset
20139 </cell>
20140 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20141 \begin_inset Text
20142
20143 \begin_layout Standard
20144 unsigned 32 division
20145 \end_layout
20146
20147 \end_inset
20148 </cell>
20149 </row>
20150 <row topline="true">
20151 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20152 \begin_inset Text
20153
20154 \begin_layout Standard
20155 _modslong.c
20156 \end_layout
20157
20158 \end_inset
20159 </cell>
20160 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20161 \begin_inset Text
20162
20163 \begin_layout Standard
20164  signed 32 bit modulus (calls _modulong)
20165 \end_layout
20166
20167 \end_inset
20168 </cell>
20169 </row>
20170 <row topline="true" bottomline="true">
20171 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20172 \begin_inset Text
20173
20174 \begin_layout Standard
20175 _modulong.c
20176 \end_layout
20177
20178 \end_inset
20179 </cell>
20180 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20181 \begin_inset Text
20182
20183 \begin_layout Standard
20184 unsigned 32 bit modulus
20185 \end_layout
20186
20187 \end_inset
20188 </cell>
20189 </row>
20190 </lyxtabular>
20191
20192 \end_inset
20193
20194
20195 \newline
20196
20197 \end_layout
20198
20199 \begin_layout Standard
20200 Since they are compiled as 
20201 \emph on
20202 non-reentrant
20203 \emph default
20204
20205 \begin_inset LatexCommand index
20206 name "reentrant"
20207
20208 \end_inset
20209
20210 , interrupt
20211 \begin_inset LatexCommand index
20212 name "interrupt"
20213
20214 \end_inset
20215
20216  service routines should not do any of the above operations.
20217  If this is unavoidable then the above routines will need to be compiled
20218  with the 
20219 \emph on
20220 -
20221 \begin_inset ERT
20222 status collapsed
20223
20224 \begin_layout Standard
20225
20226
20227 \backslash
20228 /
20229 \end_layout
20230
20231 \end_inset
20232
20233 -stack-auto
20234 \begin_inset LatexCommand index
20235 name "-\\/-stack-auto"
20236
20237 \end_inset
20238
20239
20240 \emph default
20241  option, after which the source program will have to be compiled with 
20242 \emph on
20243 -
20244 \begin_inset ERT
20245 status collapsed
20246
20247 \begin_layout Standard
20248
20249
20250 \backslash
20251 /
20252 \end_layout
20253
20254 \end_inset
20255
20256 -int-long-reent
20257 \begin_inset LatexCommand index
20258 name "-\\/-int-long-reent"
20259
20260 \end_inset
20261
20262
20263 \emph default
20264  option.
20265  Notice that you don't have to call these routines directly.
20266  The compiler will use them automatically every time an integer operation
20267  is required.
20268 \end_layout
20269
20270 \begin_layout Section
20271 Floating Point Support
20272 \begin_inset LatexCommand index
20273 name "Floating point support"
20274
20275 \end_inset
20276
20277
20278 \end_layout
20279
20280 \begin_layout Standard
20281 SDCC supports IEEE (single precision 4 bytes) floating point numbers.
20282  The floating point support routines are derived from gcc's floatlib.c and
20283  consist of the following routines:
20284 \newline
20285
20286 \end_layout
20287
20288 \begin_layout Standard
20289 \align center
20290
20291 \size footnotesize
20292 \begin_inset Tabular
20293 <lyxtabular version="3" rows="17" columns="2">
20294 <features>
20295 <column alignment="left" valignment="top" leftline="true" width="0">
20296 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
20297 <row topline="true" bottomline="true">
20298 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20299 \begin_inset Text
20300
20301 \begin_layout Standard
20302
20303 \family roman
20304 \series medium
20305 \shape up
20306 \size normal
20307 \emph off
20308 \bar no
20309 \noun off
20310 \color none
20311 Function 
20312 \end_layout
20313
20314 \end_inset
20315 </cell>
20316 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20317 \begin_inset Text
20318
20319 \begin_layout Standard
20320 Description
20321 \end_layout
20322
20323 \end_inset
20324 </cell>
20325 </row>
20326 <row topline="true">
20327 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20328 \begin_inset Text
20329
20330 \begin_layout Standard
20331
20332 \family roman
20333 \series medium
20334 \shape up
20335 \size normal
20336 \emph off
20337 \bar no
20338 \noun off
20339 \color none
20340 _fsadd.c
20341 \end_layout
20342
20343 \end_inset
20344 </cell>
20345 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20346 \begin_inset Text
20347
20348 \begin_layout Standard
20349
20350 \family roman
20351 \series medium
20352 \shape up
20353 \size normal
20354 \emph off
20355 \bar no
20356 \noun off
20357 \color none
20358 add floating point numbers
20359 \end_layout
20360
20361 \end_inset
20362 </cell>
20363 </row>
20364 <row topline="true">
20365 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20366 \begin_inset Text
20367
20368 \begin_layout Standard
20369
20370 \family roman
20371 \series medium
20372 \shape up
20373 \size normal
20374 \emph off
20375 \bar no
20376 \noun off
20377 \color none
20378 _fssub.c 
20379 \end_layout
20380
20381 \end_inset
20382 </cell>
20383 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20384 \begin_inset Text
20385
20386 \begin_layout Standard
20387
20388 \family roman
20389 \series medium
20390 \shape up
20391 \size normal
20392 \emph off
20393 \bar no
20394 \noun off
20395 \color none
20396 subtract floating point numbers 
20397 \end_layout
20398
20399 \end_inset
20400 </cell>
20401 </row>
20402 <row topline="true">
20403 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20404 \begin_inset Text
20405
20406 \begin_layout Standard
20407
20408 \family roman
20409 \series medium
20410 \shape up
20411 \size normal
20412 \emph off
20413 \bar no
20414 \noun off
20415 \color none
20416 _fsdiv.c 
20417 \end_layout
20418
20419 \end_inset
20420 </cell>
20421 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20422 \begin_inset Text
20423
20424 \begin_layout Standard
20425
20426 \family roman
20427 \series medium
20428 \shape up
20429 \size normal
20430 \emph off
20431 \bar no
20432 \noun off
20433 \color none
20434 divide floating point numbers 
20435 \end_layout
20436
20437 \end_inset
20438 </cell>
20439 </row>
20440 <row topline="true">
20441 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20442 \begin_inset Text
20443
20444 \begin_layout Standard
20445
20446 \family roman
20447 \series medium
20448 \shape up
20449 \size normal
20450 \emph off
20451 \bar no
20452 \noun off
20453 \color none
20454 _fsmul.c 
20455 \end_layout
20456
20457 \end_inset
20458 </cell>
20459 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20460 \begin_inset Text
20461
20462 \begin_layout Standard
20463
20464 \family roman
20465 \series medium
20466 \shape up
20467 \size normal
20468 \emph off
20469 \bar no
20470 \noun off
20471 \color none
20472 multiply floating point numbers 
20473 \end_layout
20474
20475 \end_inset
20476 </cell>
20477 </row>
20478 <row topline="true">
20479 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20480 \begin_inset Text
20481
20482 \begin_layout Standard
20483
20484 \family roman
20485 \series medium
20486 \shape up
20487 \size normal
20488 \emph off
20489 \bar no
20490 \noun off
20491 \color none
20492 _fs2uchar.c
20493 \end_layout
20494
20495 \end_inset
20496 </cell>
20497 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20498 \begin_inset Text
20499
20500 \begin_layout Standard
20501
20502 \family roman
20503 \series medium
20504 \shape up
20505 \size normal
20506 \emph off
20507 \bar no
20508 \noun off
20509 \color none
20510 convert floating point to unsigned char
20511 \end_layout
20512
20513 \end_inset
20514 </cell>
20515 </row>
20516 <row topline="true">
20517 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20518 \begin_inset Text
20519
20520 \begin_layout Standard
20521
20522 \family roman
20523 \series medium
20524 \shape up
20525 \size normal
20526 \emph off
20527 \bar no
20528 \noun off
20529 \color none
20530 _fs2char.c
20531 \end_layout
20532
20533 \end_inset
20534 </cell>
20535 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20536 \begin_inset Text
20537
20538 \begin_layout Standard
20539
20540 \family roman
20541 \series medium
20542 \shape up
20543 \size normal
20544 \emph off
20545 \bar no
20546 \noun off
20547 \color none
20548 convert floating point to signed char
20549 \end_layout
20550
20551 \end_inset
20552 </cell>
20553 </row>
20554 <row topline="true">
20555 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20556 \begin_inset Text
20557
20558 \begin_layout Standard
20559
20560 \family roman
20561 \series medium
20562 \shape up
20563 \size normal
20564 \emph off
20565 \bar no
20566 \noun off
20567 \color none
20568 _fs2uint.c
20569 \end_layout
20570
20571 \end_inset
20572 </cell>
20573 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20574 \begin_inset Text
20575
20576 \begin_layout Standard
20577
20578 \family roman
20579 \series medium
20580 \shape up
20581 \size normal
20582 \emph off
20583 \bar no
20584 \noun off
20585 \color none
20586 convert floating point to unsigned int
20587 \end_layout
20588
20589 \end_inset
20590 </cell>
20591 </row>
20592 <row topline="true">
20593 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20594 \begin_inset Text
20595
20596 \begin_layout Standard
20597
20598 \family roman
20599 \series medium
20600 \shape up
20601 \size normal
20602 \emph off
20603 \bar no
20604 \noun off
20605 \color none
20606 _fs2int.c
20607 \end_layout
20608
20609 \end_inset
20610 </cell>
20611 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20612 \begin_inset Text
20613
20614 \begin_layout Standard
20615
20616 \family roman
20617 \series medium
20618 \shape up
20619 \size normal
20620 \emph off
20621 \bar no
20622 \noun off
20623 \color none
20624 convert floating point to signed int
20625 \end_layout
20626
20627 \end_inset
20628 </cell>
20629 </row>
20630 <row topline="true">
20631 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20632 \begin_inset Text
20633
20634 \begin_layout Standard
20635
20636 \family roman
20637 \series medium
20638 \shape up
20639 \size normal
20640 \emph off
20641 \bar no
20642 \noun off
20643 \color none
20644 _fs2ulong.
20645 \family default
20646 \series default
20647 \shape default
20648 \size default
20649 \emph default
20650 \bar default
20651 \noun default
20652 c
20653 \end_layout
20654
20655 \end_inset
20656 </cell>
20657 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20658 \begin_inset Text
20659
20660 \begin_layout Standard
20661
20662 \family roman
20663 \series medium
20664 \shape up
20665 \size normal
20666 \emph off
20667 \bar no
20668 \noun off
20669 \color none
20670 convert floating point to unsigned long
20671 \end_layout
20672
20673 \end_inset
20674 </cell>
20675 </row>
20676 <row topline="true">
20677 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20678 \begin_inset Text
20679
20680 \begin_layout Standard
20681
20682 \family roman
20683 \series medium
20684 \shape up
20685 \size normal
20686 \emph off
20687 \bar no
20688 \noun off
20689 \color none
20690 _fs2long.c
20691 \end_layout
20692
20693 \end_inset
20694 </cell>
20695 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20696 \begin_inset Text
20697
20698 \begin_layout Standard
20699
20700 \family roman
20701 \series medium
20702 \shape up
20703 \size normal
20704 \emph off
20705 \bar no
20706 \noun off
20707 \color none
20708 convert floating point to signed long
20709 \end_layout
20710
20711 \end_inset
20712 </cell>
20713 </row>
20714 <row topline="true">
20715 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20716 \begin_inset Text
20717
20718 \begin_layout Standard
20719
20720 \family roman
20721 \series medium
20722 \shape up
20723 \size normal
20724 \emph off
20725 \bar no
20726 \noun off
20727 \color none
20728 _uchar2fs.c
20729 \end_layout
20730
20731 \end_inset
20732 </cell>
20733 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20734 \begin_inset Text
20735
20736 \begin_layout Standard
20737
20738 \family roman
20739 \series medium
20740 \shape up
20741 \size normal
20742 \emph off
20743 \bar no
20744 \noun off
20745 \color none
20746 convert unsigned char to floating point
20747 \end_layout
20748
20749 \end_inset
20750 </cell>
20751 </row>
20752 <row topline="true">
20753 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20754 \begin_inset Text
20755
20756 \begin_layout Standard
20757
20758 \family roman
20759 \series medium
20760 \shape up
20761 \size normal
20762 \emph off
20763 \bar no
20764 \noun off
20765 \color none
20766 _char2fs.c
20767 \end_layout
20768
20769 \end_inset
20770 </cell>
20771 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20772 \begin_inset Text
20773
20774 \begin_layout Standard
20775
20776 \family roman
20777 \series medium
20778 \shape up
20779 \size normal
20780 \emph off
20781 \bar no
20782 \noun off
20783 \color none
20784 convert char to floating point number
20785 \end_layout
20786
20787 \end_inset
20788 </cell>
20789 </row>
20790 <row topline="true">
20791 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20792 \begin_inset Text
20793
20794 \begin_layout Standard
20795
20796 \family roman
20797 \series medium
20798 \shape up
20799 \size normal
20800 \emph off
20801 \bar no
20802 \noun off
20803 \color none
20804 _uint2fs.c
20805 \end_layout
20806
20807 \end_inset
20808 </cell>
20809 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20810 \begin_inset Text
20811
20812 \begin_layout Standard
20813
20814 \family roman
20815 \series medium
20816 \shape up
20817 \size normal
20818 \emph off
20819 \bar no
20820 \noun off
20821 \color none
20822 convert unsigned int to floating point
20823 \end_layout
20824
20825 \end_inset
20826 </cell>
20827 </row>
20828 <row topline="true">
20829 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20830 \begin_inset Text
20831
20832 \begin_layout Standard
20833
20834 \family roman
20835 \series medium
20836 \shape up
20837 \size normal
20838 \emph off
20839 \bar no
20840 \noun off
20841 \color none
20842 _int2fs.c
20843 \end_layout
20844
20845 \end_inset
20846 </cell>
20847 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20848 \begin_inset Text
20849
20850 \begin_layout Standard
20851
20852 \family roman
20853 \series medium
20854 \shape up
20855 \size normal
20856 \emph off
20857 \bar no
20858 \noun off
20859 \color none
20860 convert int to floating point numbers
20861 \end_layout
20862
20863 \end_inset
20864 </cell>
20865 </row>
20866 <row topline="true">
20867 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20868 \begin_inset Text
20869
20870 \begin_layout Standard
20871
20872 \family roman
20873 \series medium
20874 \shape up
20875 \size normal
20876 \emph off
20877 \bar no
20878 \noun off
20879 \color none
20880 _ulong2fs.c
20881 \end_layout
20882
20883 \end_inset
20884 </cell>
20885 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20886 \begin_inset Text
20887
20888 \begin_layout Standard
20889
20890 \family roman
20891 \series medium
20892 \shape up
20893 \size normal
20894 \emph off
20895 \bar no
20896 \noun off
20897 \color none
20898 convert unsigned long to floating point number
20899 \end_layout
20900
20901 \end_inset
20902 </cell>
20903 </row>
20904 <row topline="true" bottomline="true">
20905 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20906 \begin_inset Text
20907
20908 \begin_layout Standard
20909
20910 \family roman
20911 \series medium
20912 \shape up
20913 \size normal
20914 \emph off
20915 \bar no
20916 \noun off
20917 \color none
20918 _long2fs.c
20919 \end_layout
20920
20921 \end_inset
20922 </cell>
20923 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20924 \begin_inset Text
20925
20926 \begin_layout Standard
20927
20928 \family roman
20929 \series medium
20930 \shape up
20931 \size normal
20932 \emph off
20933 \bar no
20934 \noun off
20935 \color none
20936 convert long to floating point number
20937 \end_layout
20938
20939 \end_inset
20940 </cell>
20941 </row>
20942 </lyxtabular>
20943
20944 \end_inset
20945
20946
20947 \newline
20948
20949 \end_layout
20950
20951 \begin_layout Standard
20952 These support routines are developed in ANSI-C so there is room for space
20953  and speed improvement
20954 \begin_inset Foot
20955 status open
20956
20957 \begin_layout Standard
20958 These floating point routines (
20959 \emph on
20960 not
20961 \emph default
20962  sinf(), cosf(), ...) for the mcs51 are implemented in assembler.
20963  
20964 \end_layout
20965
20966 \end_inset
20967
20968 .
20969  Note if all these routines are used simultaneously the data space might
20970  overflow.
20971  For serious floating point usage the large model might be needed.
20972  Also notice that you don't have to call this routines directly.
20973  The compiler will use them automatically every time a floating point operation
20974  is required.
20975 \begin_inset VSpace bigskip
20976 \end_inset
20977
20978
20979 \end_layout
20980
20981 \begin_layout Section
20982 Library Routines
20983 \begin_inset LatexCommand index
20984 name "Libraries"
20985
20986 \end_inset
20987
20988
20989 \end_layout
20990
20991 \begin_layout Standard
20992
20993 \emph on
20994 <pending: this is messy and incomplete - a little more information is in
20995  sdcc/doc/libdoc.txt
20996 \emph default
20997  >
20998 \end_layout
20999
21000 \begin_layout Subsection
21001 Compiler support routines (_gptrget, _mulint etc.)
21002 \end_layout
21003
21004 \begin_layout Subsection
21005 Stdclib functions (puts, printf, strcat etc.)
21006 \end_layout
21007
21008 \begin_layout Subsubsection
21009 <stdio.h>
21010 \end_layout
21011
21012 \begin_layout Paragraph
21013 getchar(), putchar()
21014 \end_layout
21015
21016 \begin_layout Standard
21017 \begin_inset LatexCommand index
21018 name "<stdio.h>"
21019
21020 \end_inset
21021
21022 As usual on embedded systems you have to provide your own 
21023 \family typewriter
21024 getchar()
21025 \begin_inset LatexCommand index
21026 name "getchar()"
21027
21028 \end_inset
21029
21030
21031 \family default
21032  and 
21033 \family typewriter
21034 putchar()
21035 \begin_inset LatexCommand index
21036 name "putchar()"
21037
21038 \end_inset
21039
21040
21041 \family default
21042  routines.
21043  SDCC does not know whether the system connects to a serial line with or
21044  without handshake, LCD, keyboard or other device.
21045  And whether a 
21046 \family typewriter
21047 lf
21048 \family default
21049  to 
21050 \family typewriter
21051 crlf
21052 \family default
21053  conversion within 
21054 \family typewriter
21055 putchar()
21056 \family default
21057  is intended.
21058  You'll find examples for serial routines f.e.
21059  in sdcc/device/lib.
21060  For the mcs51 this minimalistic polling 
21061 \family typewriter
21062 putchar()
21063 \family default
21064  routine might be a start:
21065 \end_layout
21066
21067 \begin_layout Verse
21068
21069 \family typewriter
21070 void putchar (char c) { 
21071 \newline
21072 \InsetSpace ~
21073 \InsetSpace ~
21074 \InsetSpace ~
21075 \InsetSpace ~
21076 while (!TI)\InsetSpace ~
21077 \InsetSpace ~
21078 \InsetSpace ~
21079  /* assumes UART is initialized */
21080 \newline
21081 \InsetSpace ~
21082 \InsetSpace ~
21083 \InsetSpace ~
21084 \InsetSpace ~
21085 \InsetSpace ~
21086 \InsetSpace ~
21087 \InsetSpace ~
21088 \InsetSpace ~
21089 ;
21090 \newline
21091 \InsetSpace ~
21092 \InsetSpace ~
21093 \InsetSpace ~
21094 \InsetSpace ~
21095 TI
21096  = 0;
21097 \newline
21098 \InsetSpace ~
21099 \InsetSpace ~
21100 \InsetSpace ~
21101 \InsetSpace ~
21102 SBUF = c;
21103 \newline
21104 }
21105 \end_layout
21106
21107 \begin_layout Paragraph
21108 printf()
21109 \end_layout
21110
21111 \begin_layout Standard
21112 The default 
21113 \family typewriter
21114 printf()
21115 \begin_inset LatexCommand index
21116 name "printf()"
21117
21118 \end_inset
21119
21120
21121 \family default
21122  implementation in 
21123 \family typewriter
21124 printf_large.c
21125 \family default
21126  does not support float
21127 \begin_inset LatexCommand index
21128 name "Floating point support"
21129
21130 \end_inset
21131
21132  (except on ds390), only <NO FLOAT>
21133 \begin_inset LatexCommand index
21134 name "<NO FLOAT>"
21135
21136 \end_inset
21137
21138
21139 \begin_inset LatexCommand index
21140 name "printf floating point support"
21141
21142 \end_inset
21143
21144  will be printed instead of the value.
21145  To enable floating point output, recompile it with the option 
21146 \emph on
21147 -
21148 \begin_inset ERT
21149 status collapsed
21150
21151 \begin_layout Standard
21152
21153
21154 \backslash
21155 /
21156 \end_layout
21157
21158 \end_inset
21159
21160 DUSE_FLOATS=1
21161 \begin_inset LatexCommand index
21162 name "USE\\_FLOATS"
21163
21164 \end_inset
21165
21166
21167 \emph default
21168  on the command line.
21169  Use 
21170 \emph on
21171 -
21172 \begin_inset ERT
21173 status open
21174
21175 \begin_layout Standard
21176
21177
21178 \backslash
21179 /
21180 \end_layout
21181
21182 \end_inset
21183
21184 -model-large
21185 \begin_inset LatexCommand index
21186 name "-\\/-model-large"
21187
21188 \end_inset
21189
21190
21191 \emph default
21192  for the mcs51 port, since this uses a lot of memory.
21193  To enable float support for the pic16 targets, see 
21194 \begin_inset LatexCommand ref
21195 reference "sub:pic16Libraries"
21196
21197 \end_inset
21198
21199 .
21200 \end_layout
21201
21202 \begin_layout Standard
21203 If you're short on code memory you might want to use 
21204 \family typewriter
21205 printf_small()
21206 \begin_inset LatexCommand index
21207 name "printf\\_small()"
21208
21209 \end_inset
21210
21211
21212 \family default
21213  
21214 \emph on
21215 instead
21216 \emph default
21217  of 
21218 \family typewriter
21219 printf().
21220
21221 \family default
21222  For the mcs51 there additionally are assembly versions 
21223 \family typewriter
21224 printf_tiny()
21225 \begin_inset LatexCommand index
21226 name "printf\\_tiny() (mcs51)"
21227
21228 \end_inset
21229
21230
21231 \family default
21232  (subset of printf using less than 270 bytes) and 
21233 \family typewriter
21234 printf_fast()
21235 \begin_inset LatexCommand index
21236 name "printf\\_fast() (mcs51)"
21237
21238 \end_inset
21239
21240
21241 \family default
21242  and 
21243 \family typewriter
21244 printf_fast_f()
21245 \begin_inset LatexCommand index
21246 name "printf\\_fast\\_f() (mcs51)"
21247
21248 \end_inset
21249
21250
21251 \family default
21252  (floating-point aware version of printf_fast) which should fit the requirements
21253  of many embedded systems (printf_fast() can be customized by unsetting
21254  #defines to 
21255 \emph on
21256 not
21257 \emph default
21258  support long variables and field widths).
21259  Be sure to use only one of these printf options within a project.
21260 \newline
21261
21262 \end_layout
21263
21264 \begin_layout Standard
21265 Feature matrix of different 
21266 \emph on
21267 printf
21268 \emph default
21269  options on mcs51.
21270 \end_layout
21271
21272 \begin_layout Standard
21273 \begin_inset Tabular
21274 <lyxtabular version="3" rows="14" columns="7">
21275 <features islongtable="true">
21276 <column alignment="left" valignment="middle" leftline="true" width="14col%">
21277 <column alignment="center" valignment="top" leftline="true" width="0">
21278 <column alignment="center" valignment="top" leftline="true" width="12col%">
21279 <column alignment="center" valignment="top" leftline="true" width="10col%">
21280 <column alignment="center" valignment="top" leftline="true" width="0">
21281 <column alignment="center" valignment="top" leftline="true" rightline="true" width="12col%">
21282 <column alignment="center" valignment="top" rightline="true" width="0">
21283 <row topline="true" bottomline="true" endhead="true">
21284 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21285 \begin_inset Text
21286
21287 \begin_layout Standard
21288
21289 \series bold
21290 \size large
21291 mcs51
21292 \end_layout
21293
21294 \end_inset
21295 </cell>
21296 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21297 \begin_inset Text
21298
21299 \begin_layout Standard
21300 printf
21301 \begin_inset LatexCommand index
21302 name "printf()"
21303
21304 \end_inset
21305
21306
21307 \end_layout
21308
21309 \end_inset
21310 </cell>
21311 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21312 \begin_inset Text
21313
21314 \begin_layout Standard
21315 printf 
21316 \size scriptsize
21317 USE_FLOATS=1
21318 \end_layout
21319
21320 \end_inset
21321 </cell>
21322 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21323 \begin_inset Text
21324
21325 \begin_layout Standard
21326 printf_small
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_fast
21336 \end_layout
21337
21338 \end_inset
21339 </cell>
21340 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21341 \begin_inset Text
21342
21343 \begin_layout Standard
21344 printf_fast_f
21345 \end_layout
21346
21347 \end_inset
21348 </cell>
21349 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21350 \begin_inset Text
21351
21352 \begin_layout Standard
21353 printf_tiny
21354 \end_layout
21355
21356 \end_inset
21357 </cell>
21358 </row>
21359 <row topline="true" endhead="true">
21360 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21361 \begin_inset Text
21362
21363 \begin_layout Standard
21364 filename
21365 \end_layout
21366
21367 \end_inset
21368 </cell>
21369 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21370 \begin_inset Text
21371
21372 \begin_layout Standard
21373
21374 \size scriptsize
21375 printf_large.c
21376 \end_layout
21377
21378 \end_inset
21379 </cell>
21380 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21381 \begin_inset Text
21382
21383 \begin_layout Standard
21384
21385 \size scriptsize
21386 printf_large.c
21387 \end_layout
21388
21389 \end_inset
21390 </cell>
21391 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21392 \begin_inset Text
21393
21394 \begin_layout Standard
21395
21396 \size scriptsize
21397 printfl.c
21398 \end_layout
21399
21400 \end_inset
21401 </cell>
21402 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21403 \begin_inset Text
21404
21405 \begin_layout Standard
21406
21407 \size scriptsize
21408 printf_fast.c
21409 \end_layout
21410
21411 \end_inset
21412 </cell>
21413 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21414 \begin_inset Text
21415
21416 \begin_layout Standard
21417
21418 \size scriptsize
21419 printf_fast_f.c
21420 \end_layout
21421
21422 \end_inset
21423 </cell>
21424 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21425 \begin_inset Text
21426
21427 \begin_layout Standard
21428
21429 \size scriptsize
21430 printf_tiny.c
21431 \end_layout
21432
21433 \end_inset
21434 </cell>
21435 </row>
21436 <row topline="true" endhead="true">
21437 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21438 \begin_inset Text
21439
21440 \begin_layout Standard
21441 \begin_inset Quotes sld
21442 \end_inset
21443
21444 Hello World
21445 \begin_inset Quotes srd
21446 \end_inset
21447
21448  size
21449 \end_layout
21450
21451 \begin_layout Standard
21452 small / large
21453 \end_layout
21454
21455 \end_inset
21456 </cell>
21457 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21458 \begin_inset Text
21459
21460 \begin_layout Standard
21461 1.7k / 2.4k
21462 \end_layout
21463
21464 \end_inset
21465 </cell>
21466 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21467 \begin_inset Text
21468
21469 \begin_layout Standard
21470 4.3k / 5.6k
21471 \end_layout
21472
21473 \end_inset
21474 </cell>
21475 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21476 \begin_inset Text
21477
21478 \begin_layout Standard
21479 1.2k / 1.8k
21480 \end_layout
21481
21482 \end_inset
21483 </cell>
21484 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21485 \begin_inset Text
21486
21487 \begin_layout Standard
21488 1.3k / 1.3k
21489 \end_layout
21490
21491 \end_inset
21492 </cell>
21493 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21494 \begin_inset Text
21495
21496 \begin_layout Standard
21497 1.9k / 1.9k
21498 \end_layout
21499
21500 \end_inset
21501 </cell>
21502 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21503 \begin_inset Text
21504
21505 \begin_layout Standard
21506 0.44k / 0.44k
21507 \end_layout
21508
21509 \end_inset
21510 </cell>
21511 </row>
21512 <row topline="true" endhead="true">
21513 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21514 \begin_inset Text
21515
21516 \begin_layout Standard
21517 code size
21518 \end_layout
21519
21520 \begin_layout Standard
21521 small / large
21522 \end_layout
21523
21524 \end_inset
21525 </cell>
21526 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21527 \begin_inset Text
21528
21529 \begin_layout Standard
21530 1.4k / 2.0k
21531 \end_layout
21532
21533 \end_inset
21534 </cell>
21535 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21536 \begin_inset Text
21537
21538 \begin_layout Standard
21539 2.8k / 3.7k
21540 \end_layout
21541
21542 \end_inset
21543 </cell>
21544 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21545 \begin_inset Text
21546
21547 \begin_layout Standard
21548 0.45k / 0.47k (+ _ltoa)
21549 \end_layout
21550
21551 \end_inset
21552 </cell>
21553 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21554 \begin_inset Text
21555
21556 \begin_layout Standard
21557 1.2k / 1.2k
21558 \end_layout
21559
21560 \end_inset
21561 </cell>
21562 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21563 \begin_inset Text
21564
21565 \begin_layout Standard
21566 1.6k / 1.6k
21567 \end_layout
21568
21569 \end_inset
21570 </cell>
21571 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21572 \begin_inset Text
21573
21574 \begin_layout Standard
21575 0.26k / 0.26k
21576 \end_layout
21577
21578 \end_inset
21579 </cell>
21580 </row>
21581 <row topline="true">
21582 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21583 \begin_inset Text
21584
21585 \begin_layout Standard
21586 formats
21587 \end_layout
21588
21589 \end_inset
21590 </cell>
21591 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21592 \begin_inset Text
21593
21594 \begin_layout Standard
21595 cdi
21596 \emph on
21597 o
21598 \emph default
21599 psux
21600 \end_layout
21601
21602 \end_inset
21603 </cell>
21604 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21605 \begin_inset Text
21606
21607 \begin_layout Standard
21608
21609 \family roman
21610 \series medium
21611 \shape up
21612 \size normal
21613 \emph off
21614 \bar no
21615 \noun off
21616 \color none
21617 cd
21618 \family default
21619 \series default
21620 \shape default
21621 \size default
21622 \emph default
21623 \bar default
21624 \noun default
21625 f
21626 \family roman
21627 \series medium
21628 \shape up
21629 \size normal
21630 \emph off
21631 \bar no
21632 \noun off
21633 i
21634 \family default
21635 \series default
21636 \shape default
21637 \size default
21638 \emph on
21639 \bar default
21640 \noun default
21641 o
21642 \family roman
21643 \series medium
21644 \shape up
21645 \size normal
21646 \emph off
21647 \bar no
21648 \noun off
21649 psux
21650 \end_layout
21651
21652 \end_inset
21653 </cell>
21654 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21655 \begin_inset Text
21656
21657 \begin_layout Standard
21658 c
21659 \family roman
21660 \series medium
21661 \shape up
21662 \size normal
21663 \emph off
21664 \bar no
21665 \noun off
21666 \color none
21667 d
21668 \family default
21669 \series default
21670 \shape default
21671 \size default
21672 \emph on
21673 \bar default
21674 \noun default
21675 o
21676 \family roman
21677 \series medium
21678 \shape up
21679 \size normal
21680 \emph off
21681 \bar no
21682 \noun off
21683 s
21684 \family default
21685 \series default
21686 \shape default
21687 \size default
21688 \emph default
21689 \bar default
21690 \noun default
21691 x
21692 \end_layout
21693
21694 \end_inset
21695 </cell>
21696 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21697 \begin_inset Text
21698
21699 \begin_layout Standard
21700 cdsux
21701 \end_layout
21702
21703 \end_inset
21704 </cell>
21705 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21706 \begin_inset Text
21707
21708 \begin_layout Standard
21709 cdfsux
21710 \end_layout
21711
21712 \end_inset
21713 </cell>
21714 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21715 \begin_inset Text
21716
21717 \begin_layout Standard
21718 cdsux
21719 \end_layout
21720
21721 \end_inset
21722 </cell>
21723 </row>
21724 <row topline="true">
21725 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21726 \begin_inset Text
21727
21728 \begin_layout Standard
21729 long (32 bit) support
21730 \end_layout
21731
21732 \end_inset
21733 </cell>
21734 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21735 \begin_inset Text
21736
21737 \begin_layout Standard
21738 x
21739 \end_layout
21740
21741 \end_inset
21742 </cell>
21743 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21744 \begin_inset Text
21745
21746 \begin_layout Standard
21747 x
21748 \end_layout
21749
21750 \end_inset
21751 </cell>
21752 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21753 \begin_inset Text
21754
21755 \begin_layout Standard
21756 x
21757 \end_layout
21758
21759 \end_inset
21760 </cell>
21761 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21762 \begin_inset Text
21763
21764 \begin_layout Standard
21765 x
21766 \end_layout
21767
21768 \end_inset
21769 </cell>
21770 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21771 \begin_inset Text
21772
21773 \begin_layout Standard
21774
21775 \family roman
21776 \series medium
21777 \shape up
21778 \size normal
21779 \emph off
21780 \bar no
21781 \noun off
21782 \color none
21783 x
21784 \end_layout
21785
21786 \end_inset
21787 </cell>
21788 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21789 \begin_inset Text
21790
21791 \begin_layout Standard
21792 -
21793 \end_layout
21794
21795 \end_inset
21796 </cell>
21797 </row>
21798 <row topline="true">
21799 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21800 \begin_inset Text
21801
21802 \begin_layout Standard
21803 byte arguments on stack
21804 \end_layout
21805
21806 \end_inset
21807 </cell>
21808 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21809 \begin_inset Text
21810
21811 \begin_layout Standard
21812 b
21813 \end_layout
21814
21815 \end_inset
21816 </cell>
21817 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21818 \begin_inset Text
21819
21820 \begin_layout Standard
21821 b
21822 \end_layout
21823
21824 \end_inset
21825 </cell>
21826 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21827 \begin_inset Text
21828
21829 \begin_layout Standard
21830 -
21831 \end_layout
21832
21833 \end_inset
21834 </cell>
21835 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21836 \begin_inset Text
21837
21838 \begin_layout Standard
21839 -
21840 \end_layout
21841
21842 \end_inset
21843 </cell>
21844 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21845 \begin_inset Text
21846
21847 \begin_layout Standard
21848 -
21849 \end_layout
21850
21851 \end_inset
21852 </cell>
21853 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21854 \begin_inset Text
21855
21856 \begin_layout Standard
21857 -
21858 \end_layout
21859
21860 \end_inset
21861 </cell>
21862 </row>
21863 <row topline="true">
21864 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21865 \begin_inset Text
21866
21867 \begin_layout Standard
21868 float format
21869 \begin_inset LatexCommand index
21870 name "Floating point support"
21871
21872 \end_inset
21873
21874
21875 \end_layout
21876
21877 \end_inset
21878 </cell>
21879 <cell alignment="center" valignment="top" topline="true" leftline="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" usebox="none">
21889 \begin_inset Text
21890
21891 \begin_layout Standard
21892 %f
21893 \end_layout
21894
21895 \end_inset
21896 </cell>
21897 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21898 \begin_inset Text
21899
21900 \begin_layout Standard
21901 -
21902 \end_layout
21903
21904 \end_inset
21905 </cell>
21906 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21907 \begin_inset Text
21908
21909 \begin_layout Standard
21910 -
21911 \end_layout
21912
21913 \end_inset
21914 </cell>
21915 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21916 \begin_inset Text
21917
21918 \begin_layout Standard
21919 %f
21920 \begin_inset Foot
21921 status collapsed
21922
21923 \begin_layout Standard
21924 Range limited to +/- 4294967040, precision limited to 8 digits past decimal
21925 \end_layout
21926
21927 \end_inset
21928
21929
21930 \end_layout
21931
21932 \end_inset
21933 </cell>
21934 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21935 \begin_inset Text
21936
21937 \begin_layout Standard
21938 -
21939 \end_layout
21940
21941 \end_inset
21942 </cell>
21943 </row>
21944 <row topline="true">
21945 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21946 \begin_inset Text
21947
21948 \begin_layout Standard
21949 float formats %e %g
21950 \end_layout
21951
21952 \end_inset
21953 </cell>
21954 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21955 \begin_inset Text
21956
21957 \begin_layout Standard
21958 -
21959 \end_layout
21960
21961 \end_inset
21962 </cell>
21963 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21964 \begin_inset Text
21965
21966 \begin_layout Standard
21967 -
21968 \end_layout
21969
21970 \end_inset
21971 </cell>
21972 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21973 \begin_inset Text
21974
21975 \begin_layout Standard
21976 -
21977 \end_layout
21978
21979 \end_inset
21980 </cell>
21981 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21982 \begin_inset Text
21983
21984 \begin_layout Standard
21985 -
21986 \end_layout
21987
21988 \end_inset
21989 </cell>
21990 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21991 \begin_inset Text
21992
21993 \begin_layout Standard
21994 -
21995 \end_layout
21996
21997 \end_inset
21998 </cell>
21999 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22000 \begin_inset Text
22001
22002 \begin_layout Standard
22003 -
22004 \end_layout
22005
22006 \end_inset
22007 </cell>
22008 </row>
22009 <row topline="true" bottomline="true">
22010 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22011 \begin_inset Text
22012
22013 \begin_layout Standard
22014 field width
22015 \end_layout
22016
22017 \end_inset
22018 </cell>
22019 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22020 \begin_inset Text
22021
22022 \begin_layout Standard
22023 x
22024 \end_layout
22025
22026 \end_inset
22027 </cell>
22028 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22029 \begin_inset Text
22030
22031 \begin_layout Standard
22032 x
22033 \end_layout
22034
22035 \end_inset
22036 </cell>
22037 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22038 \begin_inset Text
22039
22040 \begin_layout Standard
22041 -
22042 \end_layout
22043
22044 \end_inset
22045 </cell>
22046 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22047 \begin_inset Text
22048
22049 \begin_layout Standard
22050 x
22051 \end_layout
22052
22053 \end_inset
22054 </cell>
22055 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22056 \begin_inset Text
22057
22058 \begin_layout Standard
22059 x
22060 \end_layout
22061
22062 \end_inset
22063 </cell>
22064 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22065 \begin_inset Text
22066
22067 \begin_layout Standard
22068 -
22069 \end_layout
22070
22071 \end_inset
22072 </cell>
22073 </row>
22074 <row bottomline="true">
22075 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22076 \begin_inset Text
22077
22078 \begin_layout Standard
22079 string speed
22080 \begin_inset Foot
22081 status collapsed
22082
22083 \begin_layout Standard
22084 Execution time of printf("%s%c%s%c%c%c", "Hello", ' ', "World", '!', '
22085 \backslash
22086 r', '
22087 \backslash
22088 n'); standard 8051 @ 22.1184 MHz, empty putchar()
22089 \end_layout
22090
22091 \end_inset
22092
22093 ,
22094 \end_layout
22095
22096 \begin_layout Standard
22097 small / large
22098 \end_layout
22099
22100 \end_inset
22101 </cell>
22102 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22103 \begin_inset Text
22104
22105 \begin_layout Standard
22106 1.52 / 2.59 ms
22107 \end_layout
22108
22109 \end_inset
22110 </cell>
22111 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22112 \begin_inset Text
22113
22114 \begin_layout Standard
22115 1.53 / 2.62 ms
22116 \end_layout
22117
22118 \end_inset
22119 </cell>
22120 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22121 \begin_inset Text
22122
22123 \begin_layout Standard
22124 0.92 / 0.93 ms
22125 \end_layout
22126
22127 \end_inset
22128 </cell>
22129 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22130 \begin_inset Text
22131
22132 \begin_layout Standard
22133 0.45 / 0.45 ms
22134 \end_layout
22135
22136 \end_inset
22137 </cell>
22138 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22139 \begin_inset Text
22140
22141 \begin_layout Standard
22142 0.46 / 0.46 ms
22143 \end_layout
22144
22145 \end_inset
22146 </cell>
22147 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22148 \begin_inset Text
22149
22150 \begin_layout Standard
22151 0.45 / 0.45 ms
22152 \end_layout
22153
22154 \end_inset
22155 </cell>
22156 </row>
22157 <row bottomline="true">
22158 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22159 \begin_inset Text
22160
22161 \begin_layout Standard
22162 int speed
22163 \begin_inset Foot
22164 status collapsed
22165
22166 \begin_layout Standard
22167 Execution time of printf("%d", -12345); standard 8051 @ 22.1184 MHz, empty
22168  putchar()
22169 \end_layout
22170
22171 \end_inset
22172
22173 ,
22174 \end_layout
22175
22176 \begin_layout Standard
22177 small / large
22178 \end_layout
22179
22180 \end_inset
22181 </cell>
22182 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22183 \begin_inset Text
22184
22185 \begin_layout Standard
22186 3.01 / 3.61 ms
22187 \end_layout
22188
22189 \end_inset
22190 </cell>
22191 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22192 \begin_inset Text
22193
22194 \begin_layout Standard
22195 3.01 / 3.61 ms
22196 \end_layout
22197
22198 \end_inset
22199 </cell>
22200 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22201 \begin_inset Text
22202
22203 \begin_layout Standard
22204 3.51 / 18.13 ms
22205 \end_layout
22206
22207 \end_inset
22208 </cell>
22209 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22210 \begin_inset Text
22211
22212 \begin_layout Standard
22213 0.22 / 0.22 ms
22214 \end_layout
22215
22216 \end_inset
22217 </cell>
22218 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22219 \begin_inset Text
22220
22221 \begin_layout Standard
22222 0.23 / 0.23 ms
22223 \end_layout
22224
22225 \end_inset
22226 </cell>
22227 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22228 \begin_inset Text
22229
22230 \begin_layout Standard
22231 0.25 / 0.25 ms
22232 \begin_inset Foot
22233 status collapsed
22234
22235 \begin_layout Standard
22236 printf_tiny integer speed is data dependent, worst case is 0.33 ms
22237 \end_layout
22238
22239 \end_inset
22240
22241
22242 \end_layout
22243
22244 \end_inset
22245 </cell>
22246 </row>
22247 <row bottomline="true">
22248 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22249 \begin_inset Text
22250
22251 \begin_layout Standard
22252 long speed
22253 \begin_inset Foot
22254 status collapsed
22255
22256 \begin_layout Standard
22257 Execution time of printf("%ld", -123456789); standard 8051 @ 22.1184 MHz,
22258  empty putchar()
22259 \end_layout
22260
22261 \end_inset
22262
22263 ,
22264 \end_layout
22265
22266 \begin_layout Standard
22267 small / large
22268 \end_layout
22269
22270 \end_inset
22271 </cell>
22272 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22273 \begin_inset Text
22274
22275 \begin_layout Standard
22276 5.37 / 6.31 ms
22277 \end_layout
22278
22279 \end_inset
22280 </cell>
22281 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22282 \begin_inset Text
22283
22284 \begin_layout Standard
22285 5.37 / 6.31 ms
22286 \end_layout
22287
22288 \end_inset
22289 </cell>
22290 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22291 \begin_inset Text
22292
22293 \begin_layout Standard
22294 8.71 / 40.65 ms
22295 \end_layout
22296
22297 \end_inset
22298 </cell>
22299 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22300 \begin_inset Text
22301
22302 \begin_layout Standard
22303 0.40 / 0.40 ms
22304 \end_layout
22305
22306 \end_inset
22307 </cell>
22308 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22309 \begin_inset Text
22310
22311 \begin_layout Standard
22312 0.40 / 0.40 ms
22313 \end_layout
22314
22315 \end_inset
22316 </cell>
22317 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22318 \begin_inset Text
22319
22320 \begin_layout Standard
22321 -
22322 \end_layout
22323
22324 \end_inset
22325 </cell>
22326 </row>
22327 <row bottomline="true">
22328 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22329 \begin_inset Text
22330
22331 \begin_layout Standard
22332 float speed
22333 \begin_inset Foot
22334 status collapsed
22335
22336 \begin_layout Standard
22337 Execution time of printf("%.3f", -12345.678); standard 8051 @ 22.1184 MHz,
22338  empty putchar()
22339 \end_layout
22340
22341 \end_inset
22342
22343 ,
22344 \end_layout
22345
22346 \begin_layout Standard
22347 small / large
22348 \end_layout
22349
22350 \end_inset
22351 </cell>
22352 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22353 \begin_inset Text
22354
22355 \begin_layout Standard
22356 -
22357 \end_layout
22358
22359 \end_inset
22360 </cell>
22361 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22362 \begin_inset Text
22363
22364 \begin_layout Standard
22365 7.49 / 22.47 ms
22366 \end_layout
22367
22368 \end_inset
22369 </cell>
22370 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22371 \begin_inset Text
22372
22373 \begin_layout Standard
22374 -
22375 \end_layout
22376
22377 \end_inset
22378 </cell>
22379 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22380 \begin_inset Text
22381
22382 \begin_layout Standard
22383 -
22384 \end_layout
22385
22386 \end_inset
22387 </cell>
22388 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22389 \begin_inset Text
22390
22391 \begin_layout Standard
22392 1.04 / 1.04 ms
22393 \end_layout
22394
22395 \end_inset
22396 </cell>
22397 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22398 \begin_inset Text
22399
22400 \begin_layout Standard
22401 -
22402 \end_layout
22403
22404 \end_inset
22405 </cell>
22406 </row>
22407 </lyxtabular>
22408
22409 \end_inset
22410
22411
22412 \end_layout
22413
22414 \begin_layout Subsubsection
22415 <malloc.h>
22416 \begin_inset LatexCommand index
22417 name "malloc.h"
22418
22419 \end_inset
22420
22421
22422 \end_layout
22423
22424 \begin_layout Standard
22425 As of SDCC 2.6.2 you no longer need to call an initialization routine before
22426  using dynamic memory allocation
22427 \begin_inset LatexCommand index
22428 name "dynamic memory allocation (malloc)"
22429
22430 \end_inset
22431
22432  and a default heap
22433 \begin_inset LatexCommand index
22434 name "heap (malloc)"
22435
22436 \end_inset
22437
22438  space of 1024 bytes is provided for malloc to allocate memory from.
22439  If you need a different heap size you need to recompile _heap.c with the
22440  required size defined in HEAP_SIZE.
22441  It is recommended to make a copy of this file into your project directory
22442  and compile it there with:
22443 \end_layout
22444
22445 \begin_layout Verse
22446
22447 \family typewriter
22448 sdcc -c _heap.c -D HEAD_SIZE=2048
22449 \end_layout
22450
22451 \begin_layout Standard
22452 And then link it with:
22453 \end_layout
22454
22455 \begin_layout Verse
22456
22457 \family typewriter
22458 sdcc main.rel _heap.rel
22459 \end_layout
22460
22461 \begin_layout Subsection
22462 Math functions (sinf, powf, sqrtf etc.)
22463 \end_layout
22464
22465 \begin_layout Subsubsection
22466 <math.h>
22467 \end_layout
22468
22469 \begin_layout Standard
22470 See definitions in file <math.h>.
22471 \end_layout
22472
22473 \begin_layout Subsection
22474 Other libraries
22475 \end_layout
22476
22477 \begin_layout Standard
22478 Libraries
22479 \begin_inset LatexCommand index
22480 name "Libraries"
22481
22482 \end_inset
22483
22484  included in SDCC should have a license at least as liberal as the GNU Lesser
22485  General Public License
22486 \begin_inset LatexCommand index
22487 name "GNU Lesser General Public License, LGPL"
22488
22489 \end_inset
22490
22491  
22492 \emph on
22493 LGPL
22494 \emph default
22495 .
22496 \end_layout
22497
22498 \begin_layout Standard
22499 \begin_inset Note Note
22500 status collapsed
22501
22502 \begin_layout Standard
22503 license statements for the libraries are missing.
22504  sdcc/device/lib/ser_ir.c
22505 \end_layout
22506
22507 \begin_layout Standard
22508 or _decdptr f.e.
22509  come with a GPL (as opposed to LGPL) License - this will not be liberal
22510  enough for many embedded programmers.
22511 \end_layout
22512
22513 \end_inset
22514
22515
22516 \end_layout
22517
22518 \begin_layout Standard
22519 If you have ported some library or want to share experience about some code
22520  which f.e.
22521  falls into any of these categories Busses (I
22522 \begin_inset Formula $^{\textrm{2}}$
22523 \end_inset
22524
22525 C, CAN, Ethernet, Profibus, Modbus, USB, SPI, JTAG ...), Media (IDE, Memory
22526  cards, eeprom, flash...), En-/Decryption, Remote debugging, Realtime kernel,
22527  Keyboard, LCD, RTC, FPGA, PID then the sdcc-user mailing list 
22528 \begin_inset LatexCommand url
22529 target "http://sourceforge.net/mail/?group_id=599"
22530
22531 \end_inset
22532
22533 \InsetSpace ~
22534 would certainly like to hear about it.
22535 \end_layout
22536
22537 \begin_layout Standard
22538 Programmers coding for embedded systems are not especially famous for being
22539  enthusiastic, so don't expect a big hurray but as the mailing list is searchabl
22540 e these references are very valuable.
22541  Let's help to create a climate where information is shared.
22542 \begin_inset VSpace bigskip
22543 \end_inset
22544
22545
22546 \end_layout
22547
22548 \begin_layout Section
22549 Memory Models
22550 \end_layout
22551
22552 \begin_layout Subsection
22553 MCS51 Memory Models
22554 \begin_inset LatexCommand index
22555 name "Memory model"
22556
22557 \end_inset
22558
22559
22560 \begin_inset LatexCommand index
22561 name "MCS51 memory model"
22562
22563 \end_inset
22564
22565
22566 \end_layout
22567
22568 \begin_layout Subsubsection
22569 Small, Medium and Large
22570 \end_layout
22571
22572 \begin_layout Standard
22573 SDCC allows three memory models for MCS51 code, 
22574 \shape slanted
22575 small, medium
22576 \shape default
22577  and 
22578 \shape slanted
22579 large
22580 \shape default
22581 .
22582  Modules compiled with different memory models should 
22583 \emph on
22584 never
22585 \emph default
22586  be combined together or the results would be unpredictable.
22587  The library routines supplied with the compiler are compiled as small,
22588  medium and large.
22589  The compiled library modules are contained in separate directories as small,
22590  medium and large so that you can link to the appropriate set.
22591 \end_layout
22592
22593 \begin_layout Standard
22594 When the medium or large model is used all variables declared without a
22595  storage class will be allocated into the external ram, this includes all
22596  parameters and local variables (for non-reentrant
22597 \begin_inset LatexCommand index
22598 name "reentrant"
22599
22600 \end_inset
22601
22602  functions).
22603  When the small model is used variables without storage class are allocated
22604  in the internal ram.
22605 \end_layout
22606
22607 \begin_layout Standard
22608 Judicious usage of the processor specific storage classes
22609 \begin_inset LatexCommand index
22610 name "Storage class"
22611
22612 \end_inset
22613
22614  and the 'reentrant' function type will yield much more efficient code,
22615  than using the large model.
22616  Several optimizations are disabled when the program is compiled using the
22617  large model, it is therefore recommended that the small model be used unless
22618  absolutely required.
22619 \end_layout
22620
22621 \begin_layout Subsubsection
22622 External Stack
22623 \begin_inset LatexCommand label
22624 name "sub:External-Stack"
22625
22626 \end_inset
22627
22628
22629 \begin_inset LatexCommand index
22630 name "stack"
22631
22632 \end_inset
22633
22634
22635 \begin_inset LatexCommand index
22636 name "External stack (mcs51)"
22637
22638 \end_inset
22639
22640
22641 \end_layout
22642
22643 \begin_layout Standard
22644 The external stack (-
22645 \begin_inset ERT
22646 status collapsed
22647
22648 \begin_layout Standard
22649
22650
22651 \backslash
22652 /
22653 \end_layout
22654
22655 \end_inset
22656
22657 -xstack option
22658 \begin_inset LatexCommand index
22659 name "-\\/-xstack"
22660
22661 \end_inset
22662
22663 ) is located in pdata
22664 \begin_inset LatexCommand index
22665 name "pdata (mcs51, ds390 storage class)"
22666
22667 \end_inset
22668
22669  memory (usually at the start of the external ram segment) and uses all
22670  unused space in pdata (max.
22671  256 bytes).
22672  When -
22673 \begin_inset ERT
22674 status collapsed
22675
22676 \begin_layout Standard
22677
22678
22679 \backslash
22680 /
22681 \end_layout
22682
22683 \end_inset
22684
22685 -xstack option is used to compile the program, the parameters and local
22686  variables
22687 \begin_inset LatexCommand index
22688 name "local variables"
22689
22690 \end_inset
22691
22692  of all reentrant functions are allocated in this area.
22693  This option is provided for programs with large stack space requirements.
22694  When used with the -
22695 \begin_inset ERT
22696 status collapsed
22697
22698 \begin_layout Standard
22699
22700
22701 \backslash
22702 /
22703 \end_layout
22704
22705 \end_inset
22706
22707 -stack-auto
22708 \begin_inset LatexCommand index
22709 name "-\\/-stack-auto"
22710
22711 \end_inset
22712
22713  option, all parameters and local variables are allocated on the external
22714  stack (note: support libraries will need to be recompiled with the same
22715  options.
22716  There is a predefined target in the library makefile).
22717 \end_layout
22718
22719 \begin_layout Standard
22720 The compiler outputs the higher order address byte of the external ram segment
22721  into port P2
22722 \begin_inset LatexCommand index
22723 name "P2 (mcs51 sfr)"
22724
22725 \end_inset
22726
22727  (see also section 
22728 \begin_inset LatexCommand ref
22729 reference "sub:MCS51-variants"
22730
22731 \end_inset
22732
22733 ), therefore when using the External Stack option, this port 
22734 \emph on
22735 may not
22736 \emph default
22737  be used by the application program.
22738 \end_layout
22739
22740 \begin_layout Subsection
22741 DS390 Memory Model
22742 \begin_inset LatexCommand index
22743 name "Memory model"
22744
22745 \end_inset
22746
22747
22748 \begin_inset LatexCommand index
22749 name "DS390 memory model"
22750
22751 \end_inset
22752
22753
22754 \end_layout
22755
22756 \begin_layout Standard
22757 The only model supported is Flat 24
22758 \begin_inset LatexCommand index
22759 name "Flat 24 (DS390 memory model)"
22760
22761 \end_inset
22762
22763 .
22764  This generates code for the 24 bit contiguous addressing mode of the Dallas
22765  DS80C390 part.
22766  In this mode, up to four meg of external RAM or code space can be directly
22767  addressed.
22768  See the data sheets at www.dalsemi.com for further information on this part.
22769 \newline
22770
22771 \newline
22772 Note
22773  that the compiler does not generate any code to place the processor into
22774  24 bitmode (although 
22775 \emph on
22776 tinibios
22777 \emph default
22778  in the ds390 libraries will do that for you).
22779  If you don't use 
22780 \emph on
22781 tinibios
22782 \emph default
22783
22784 \begin_inset LatexCommand index
22785 name "Tinibios (DS390)"
22786
22787 \end_inset
22788
22789 , the boot loader or similar code must ensure that the processor is in 24
22790  bit contiguous addressing mode before calling the SDCC startup code.
22791 \newline
22792
22793 \newline
22794 Like
22795  the 
22796 \emph on
22797 -
22798 \begin_inset ERT
22799 status collapsed
22800
22801 \begin_layout Standard
22802
22803
22804 \backslash
22805 /
22806 \end_layout
22807
22808 \end_inset
22809
22810 -model-large
22811 \emph default
22812  option, variables will by default be placed into the XDATA segment.
22813  
22814 \newline
22815
22816 \newline
22817 Segments may be placed anywhere in the 4 meg address space using the usual
22818  -
22819 \begin_inset ERT
22820 status collapsed
22821
22822 \begin_layout Standard
22823
22824
22825 \backslash
22826 /
22827 \end_layout
22828
22829 \end_inset
22830
22831 -*-loc options.
22832  Note that if any segments are located above 64K, the -r flag must be passed
22833  to the linker to generate the proper segment relocations, and the Intel
22834  HEX output format must be used.
22835  The -r flag can be passed to the linker by using the option 
22836 \emph on
22837 -Wl-r
22838 \emph default
22839  on the SDCC command line.
22840  However, currently the linker can not handle code segments > 64k.
22841 \end_layout
22842
22843 \begin_layout Section
22844 Pragmas
22845 \begin_inset LatexCommand label
22846 name "sec:Pragmas"
22847
22848 \end_inset
22849
22850
22851 \begin_inset LatexCommand index
22852 name "Pragmas"
22853
22854 \end_inset
22855
22856
22857 \end_layout
22858
22859 \begin_layout Standard
22860 Pragmas are used to turn on and/or off certain compiler options.
22861  Some of them are closely related to corresponding command-line options
22862  (see section 
22863 \begin_inset LatexCommand vref
22864 reference "sec:Command-Line-Options"
22865
22866 \end_inset
22867
22868 ).
22869 \newline
22870 Pragmas should be placed before and/or after a function, placing pragmas
22871  inside a function body could have unpredictable results.
22872 \newline
22873
22874 \newline
22875 SDCC supports the
22876  following #pragma directives:
22877 \end_layout
22878
22879 \begin_layout Itemize
22880
22881 \series bold
22882 save
22883 \series default
22884
22885 \begin_inset LatexCommand index
22886 name "\\#pragma save"
22887
22888 \end_inset
22889
22890  - this will save most current options to the save/restore stack.
22891  See #pragma\InsetSpace ~
22892 restore.
22893 \end_layout
22894
22895 \begin_layout Itemize
22896
22897 \series bold
22898 restore
22899 \series default
22900
22901 \begin_inset LatexCommand index
22902 name "\\#pragma restore"
22903
22904 \end_inset
22905
22906  - will restore saved options from the last save.
22907  saves & restores can be nested.
22908  SDCC uses a save/restore stack: save pushes current options to the stack,
22909  restore pulls current options from the stack.
22910  See #pragma\InsetSpace ~
22911 save.
22912 \newline
22913
22914 \end_layout
22915
22916 \begin_layout Itemize
22917
22918 \series bold
22919 callee_saves
22920 \series default
22921
22922 \begin_inset LatexCommand index
22923 name "\\#pragma callee\\_saves"
22924
22925 \end_inset
22926
22927
22928 \begin_inset LatexCommand index
22929 name "function prologue"
22930
22931 \end_inset
22932
22933  function1[,function2[,function3...]] 
22934 \begin_inset LatexCommand label
22935 name "ite:callee_saves-function1[,function2[,function3...]]--"
22936
22937 \end_inset
22938
22939 - The compiler by default uses a caller saves convention for register saving
22940  across function calls, however this can cause unnecessary register pushing
22941  and popping
22942 \begin_inset LatexCommand index
22943 name "push/pop"
22944
22945 \end_inset
22946
22947  when calling small functions from larger functions.
22948  This option can be used to switch off the register saving convention for
22949  the function names specified.
22950  The compiler will not save registers when calling these functions, extra
22951  code need to be manually inserted at the entry and exit for these functions
22952  to save and restore the registers used by these functions, this can SUBSTANTIAL
22953 LY reduce code and improve run time performance of the generated code.
22954  In the future the compiler (with inter procedural analysis) may be able
22955  to determine the appropriate scheme to use for each function call.
22956  If -
22957 \begin_inset ERT
22958 status collapsed
22959
22960 \begin_layout Standard
22961
22962
22963 \backslash
22964 /
22965 \end_layout
22966
22967 \end_inset
22968
22969 -callee-saves command line option is used (see page 
22970 \begin_inset LatexCommand vpageref
22971 reference "lyx:--callee-saves-function1[,function2][,function3]..."
22972
22973 \end_inset
22974
22975 ), the function names specified in #pragma\InsetSpace ~
22976 callee_saves
22977 \begin_inset LatexCommand index
22978 name "\\#pragma callee\\_saves"
22979
22980 \end_inset
22981
22982  is appended to the list of functions specified in the command line.
22983 \end_layout
22984
22985 \begin_layout Itemize
22986
22987 \series bold
22988 exclude
22989 \series default
22990
22991 \begin_inset LatexCommand index
22992 name "\\#pragma exclude"
22993
22994 \end_inset
22995
22996  none | {acc[,b[,dpl[,dph]]] - The exclude pragma disables the generation
22997  of pairs of push/pop
22998 \begin_inset LatexCommand index
22999 name "push/pop"
23000
23001 \end_inset
23002
23003  instructions in 
23004 \emph on
23005 I
23006 \emph default
23007 nterrupt
23008 \begin_inset LatexCommand index
23009 name "interrupt"
23010
23011 \end_inset
23012
23013  
23014 \emph on
23015 S
23016 \emph default
23017 ervice 
23018 \emph on
23019 R
23020 \emph default
23021 outines.
23022  The directive should be placed immediately before the ISR function definition
23023  and it affects ALL ISR functions following it.
23024  To enable the normal register saving for ISR functions use #pragma\InsetSpace ~
23025 exclude\InsetSpace ~
23026 none
23027 \begin_inset LatexCommand index
23028 name "\\#pragma exclude"
23029
23030 \end_inset
23031
23032 .
23033  See also the related keyword _naked
23034 \begin_inset LatexCommand index
23035 name "\\_naked"
23036
23037 \end_inset
23038
23039
23040 \begin_inset LatexCommand index
23041 name "\\_\\_naked"
23042
23043 \end_inset
23044
23045 .
23046 \end_layout
23047
23048 \begin_layout Itemize
23049
23050 \series bold
23051 less_pedantic
23052 \series default
23053
23054 \begin_inset LatexCommand index
23055 name "pedantic"
23056
23057 \end_inset
23058
23059
23060 \begin_inset LatexCommand index
23061 name "\\#pragma less\\_pedantic"
23062
23063 \end_inset
23064
23065  
23066 \begin_inset LatexCommand label
23067 name "ite:less_pedantic"
23068
23069 \end_inset
23070
23071 - the compiler will not warn you anymore for obvious mistakes, you're on
23072  your own now ;-( .
23073  See also the command line option -
23074 \begin_inset ERT
23075 status collapsed
23076
23077 \begin_layout Standard
23078
23079
23080 \backslash
23081 /
23082 \end_layout
23083
23084 \end_inset
23085
23086 -less-pedantic 
23087 \begin_inset LatexCommand vpageref
23088 reference "lyx:--less-pedantic"
23089
23090 \end_inset
23091
23092 .
23093  
23094 \newline
23095 More specifically, the following warnings will be disabled: 
23096 \shape italic
23097 comparison is always [true/false] due to limited range of data type
23098 \shape default
23099  (94); 
23100 \shape italic
23101 overflow in implicit constant conversion
23102 \shape default
23103  (158); [the (in)famous] 
23104 \shape italic
23105 conditional flow changed by optimizer: so said EVELYN the modified DOG
23106 \shape default
23107  (110); 
23108 \shape italic
23109 function '[function name]' must return value
23110 \shape default
23111  (59).
23112  
23113 \newline
23114 Furthermore, warnings of less importance (of PEDANTIC and INFO warning
23115  level) are disabled, too, namely: 
23116 \shape italic
23117 constant value '[
23118 \begin_inset Note Note
23119 status collapsed
23120
23121 \begin_layout Standard
23122 dunno what comes here - this warning appears to be unused altogether
23123 \end_layout
23124
23125 \end_inset
23126
23127 ]', out of range
23128 \shape default
23129  (81); 
23130 \shape italic
23131 [left/right] shifting more than size of object changed to zero
23132 \shape default
23133  (116); 
23134 \shape italic
23135 unreachable code
23136 \shape default
23137  (126); 
23138 \shape italic
23139 integer overflow in expression
23140 \shape default
23141  (165); 
23142 \shape italic
23143 unmatched #pragma save and #pragma restore
23144 \shape default
23145  (170); 
23146 \shape italic
23147 comparison of 'signed char' with 'unsigned char' requires promotion to int
23148 \shape default
23149  (185); 
23150 \shape italic
23151 ISO C90 does not support flexible array members
23152 \shape default
23153  (187); 
23154 \shape italic
23155 extended stack by [number] bytes for compiler temp(s) :in function '[function\InsetSpace ~
23156 nam
23157 e]':\InsetSpace ~
23158 [
23159 \begin_inset Note Note
23160 status collapsed
23161
23162 \begin_layout Standard
23163 appears to be always blank - what was supposed to be here?
23164 \end_layout
23165
23166 \end_inset
23167
23168 ]
23169 \shape default
23170  (114); 
23171 \shape italic
23172 function '[function name]', # edges [number] , # nodes [number] , cyclomatic
23173  complexity [number]
23174 \shape default
23175  (121).
23176 \end_layout
23177
23178 \begin_layout Itemize
23179
23180 \series bold
23181 disable_warning
23182 \series default
23183  <nnnn>
23184 \begin_inset LatexCommand index
23185 name "\\#pragma disable\\_warning"
23186
23187 \end_inset
23188
23189  - the compiler will not warn you anymore about warning number <nnnn>.
23190 \end_layout
23191
23192 \begin_layout Itemize
23193
23194 \series bold
23195 nogcse
23196 \series default
23197
23198 \begin_inset LatexCommand index
23199 name "\\#pragma nogcse"
23200
23201 \end_inset
23202
23203  - will stop global common subexpression elimination.
23204 \end_layout
23205
23206 \begin_layout Itemize
23207
23208 \series bold
23209 noinduction
23210 \series default
23211
23212 \begin_inset LatexCommand index
23213 name "\\#pragma noinduction"
23214
23215 \end_inset
23216
23217  - will stop loop induction optimizations.
23218 \end_layout
23219
23220 \begin_layout Itemize
23221
23222 \series bold
23223 noinvariant
23224 \series default
23225
23226 \begin_inset LatexCommand index
23227 name "\\#pragma noinvariant"
23228
23229 \end_inset
23230
23231  - will not do loop invariant optimizations.
23232  For more details see Loop Invariants in section
23233 \begin_inset LatexCommand ref
23234 reference "sub:Loop-Optimizations"
23235
23236 \end_inset
23237
23238 .
23239 \end_layout
23240
23241 \begin_layout Itemize
23242
23243 \series bold
23244 noiv
23245 \series default
23246
23247 \begin_inset LatexCommand index
23248 name "\\#pragma noiv"
23249
23250 \end_inset
23251
23252  - Do not generate interrupt
23253 \begin_inset LatexCommand index
23254 name "interrupt"
23255
23256 \end_inset
23257
23258  vector table
23259 \begin_inset LatexCommand index
23260 name "interrupt vector table"
23261
23262 \end_inset
23263
23264  entries for all ISR functions defined after the pragma.
23265  This is useful in cases where the interrupt vector table must be defined
23266  manually, or when there is a secondary, manually defined interrupt vector
23267  table (e.g.
23268  for the autovector feature of the Cypress EZ-USB FX2).
23269  More elegantly this can be achieved by omitting the optional interrupt
23270  number after the interrupt keyword, see section 
23271 \begin_inset LatexCommand ref
23272 reference "sub:Interrupt-Service-Routines"
23273
23274 \end_inset
23275
23276 \InsetSpace ~
23277 about interrupts.
23278 \end_layout
23279
23280 \begin_layout Itemize
23281
23282 \series bold
23283 nojtbound
23284 \series default
23285
23286 \begin_inset LatexCommand index
23287 name "\\#pragma nojtbound"
23288
23289 \end_inset
23290
23291  - will not generate code for boundary value checking, when switch statements
23292  are turned into jump-tables (dangerous).
23293  For more details see section 
23294 \begin_inset LatexCommand ref
23295 reference "sub:'switch'-Statements"
23296
23297 \end_inset
23298
23299 .
23300 \end_layout
23301
23302 \begin_layout Itemize
23303
23304 \series bold
23305 noloopreverse
23306 \series default
23307
23308 \begin_inset LatexCommand index
23309 name "\\#pragma noloopreverse"
23310
23311 \end_inset
23312
23313  - Will not do loop reversal optimization
23314 \end_layout
23315
23316 \begin_layout Itemize
23317
23318 \series bold
23319 nooverlay
23320 \series default
23321
23322 \begin_inset LatexCommand index
23323 name "\\#pragma nooverlay"
23324
23325 \end_inset
23326
23327  - the compiler will not overlay the parameters and local variables of a
23328  function.
23329 \end_layout
23330
23331 \begin_layout Itemize
23332
23333 \series bold
23334 stackauto
23335 \series default
23336
23337 \begin_inset LatexCommand index
23338 name "\\#pragma stackauto"
23339
23340 \end_inset
23341
23342 - See option -
23343 \begin_inset ERT
23344 status collapsed
23345
23346 \begin_layout Standard
23347
23348
23349 \backslash
23350 /
23351 \end_layout
23352
23353 \end_inset
23354
23355 -stack-auto
23356 \begin_inset LatexCommand index
23357 name "-\\/-stack-auto"
23358
23359 \end_inset
23360
23361  and section 
23362 \begin_inset LatexCommand ref
23363 reference "sec:Parameters-and-Local-Variables"
23364
23365 \end_inset
23366
23367  Parameters and Local Variables.
23368 \end_layout
23369
23370 \begin_layout Itemize
23371
23372 \series bold
23373 opt_code_speed
23374 \series default
23375  
23376 \begin_inset LatexCommand index
23377 name "\\#pragma opt\\_code\\_speed"
23378
23379 \end_inset
23380
23381 - The compiler will optimize code generation towards fast code, possibly
23382  at the expense of code size.
23383  Currently this has little effect.
23384 \end_layout
23385
23386 \begin_layout Itemize
23387
23388 \series bold
23389 opt_code_size
23390 \series default
23391  
23392 \begin_inset LatexCommand index
23393 name "\\#pragma opt\\_code\\_size"
23394
23395 \end_inset
23396
23397 - The compiler will optimize code generation towards compact code, possibly
23398  at the expense of code speed.
23399  Currently this has little effect.
23400 \end_layout
23401
23402 \begin_layout Itemize
23403
23404 \series bold
23405 opt_code_balanced
23406 \series default
23407  
23408 \begin_inset LatexCommand index
23409 name "\\#pragma opt\\_code\\_balanced"
23410
23411 \end_inset
23412
23413 - The compiler will attempt to generate code that is both compact and fast,
23414  as long as meeting one goal is not a detriment to the other (this is the
23415  default).
23416  
23417 \end_layout
23418
23419 \begin_layout Itemize
23420
23421 \series bold
23422 std_sdcc89
23423 \series default
23424  
23425 \begin_inset LatexCommand index
23426 name "\\#pragma std\\_sdcc89"
23427
23428 \end_inset
23429
23430 - Generally follow the C89 standard, but allow SDCC features that conflict
23431  with the standard (default).
23432 \end_layout
23433
23434 \begin_layout Itemize
23435
23436 \series bold
23437 std_c89
23438 \series default
23439  
23440 \begin_inset LatexCommand index
23441 name "\\#pragma std\\_c89"
23442
23443 \end_inset
23444
23445 - Follow the C89 standard and disable SDCC features that conflict with the
23446  standard.
23447 \end_layout
23448
23449 \begin_layout Itemize
23450
23451 \series bold
23452 std_sdcc99
23453 \series default
23454  
23455 \begin_inset LatexCommand index
23456 name "\\#pragma std\\_sdcc99"
23457
23458 \end_inset
23459
23460 - Generally follow the C99 standard, but allow SDCC features that conflict
23461  with the standard (incomplete support).
23462 \end_layout
23463
23464 \begin_layout Itemize
23465
23466 \series bold
23467 std_c99
23468 \series default
23469  
23470 \begin_inset LatexCommand index
23471 name "\\#pragma std\\_c99"
23472
23473 \end_inset
23474
23475 - Follow the C99 standard and disable SDCC features that conflict with the
23476  standard (incomplete support).
23477 \end_layout
23478
23479 \begin_layout Itemize
23480
23481 \series bold
23482 codeseg
23483 \series default
23484  <name>
23485 \begin_inset LatexCommand index
23486 name "\\#pragma codeseg"
23487
23488 \end_inset
23489
23490 - Use this name (max.
23491  8 characters) for the code segment.
23492  See option -
23493 \begin_inset ERT
23494 status collapsed
23495
23496 \begin_layout Standard
23497
23498
23499 \backslash
23500 /
23501 \end_layout
23502
23503 \end_inset
23504
23505 -codeseg.
23506 \end_layout
23507
23508 \begin_layout Itemize
23509
23510 \series bold
23511 constseg
23512 \series default
23513  <name>
23514 \begin_inset LatexCommand index
23515 name "\\#pragma constseg"
23516
23517 \end_inset
23518
23519 - Use this name (max.
23520  8 characters) for the const segment.
23521  See option -
23522 \begin_inset ERT
23523 status collapsed
23524
23525 \begin_layout Standard
23526
23527
23528 \backslash
23529 /
23530 \end_layout
23531
23532 \end_inset
23533
23534 -constseg.
23535 \end_layout
23536
23537 \begin_layout Standard
23538 The preprocessor SDCPP
23539 \begin_inset LatexCommand index
23540 name "sdcpp (preprocessor)"
23541
23542 \end_inset
23543
23544  supports the following #pragma directives:
23545 \end_layout
23546
23547 \begin_layout Itemize
23548
23549 \series bold
23550 pedantic_parse_number
23551 \series default
23552
23553 \begin_inset LatexCommand index
23554 name "pedantic"
23555
23556 \end_inset
23557
23558
23559 \begin_inset LatexCommand index
23560 name "\\#pragma pedantic\\_parse\\_number"
23561
23562 \end_inset
23563
23564  (+ | -) 
23565 \begin_inset LatexCommand label
23566 name "ite:pedantic_parse_number"
23567
23568 \end_inset
23569
23570 - Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed
23571  properly and the macro LO_B(3) gets expanded.
23572  Default is off.
23573  See also the -
23574 \begin_inset ERT
23575 status collapsed
23576
23577 \begin_layout Standard
23578
23579
23580 \backslash
23581 /
23582 \end_layout
23583
23584 \end_inset
23585
23586 -pedantic-parse-number command line option 
23587 \begin_inset LatexCommand vpageref
23588 reference "lyx:-pedantic-parse-number"
23589
23590 \end_inset
23591
23592 .
23593  
23594 \newline
23595 Below is an example on how to use this pragma.
23596  
23597 \emph on
23598 Note: this functionality is not in conformance with standard!
23599 \end_layout
23600
23601 \begin_layout Verse
23602
23603 \family typewriter
23604 #pragma pedantic_parse_number +
23605 \begin_inset LatexCommand index
23606 name "\\#pragma pedantic\\_parse\\_number"
23607
23608 \end_inset
23609
23610
23611 \newline
23612
23613 \newline
23614 #define LO_B(x) ((x) & 0xff)
23615 \newline
23616
23617 \newline
23618 unsigned char foo(void)
23619 \newline
23620 {
23621 \newline
23622 \InsetSpace ~
23623 \InsetSpace ~
23624 \InsetSpace ~
23625 unsigned char c=0xfe-LO_B(3)
23626 ;
23627 \newline
23628
23629 \newline
23630 \InsetSpace ~
23631 \InsetSpace ~
23632 \InsetSpace ~
23633 return c;
23634 \newline
23635 }
23636 \newline
23637
23638 \end_layout
23639
23640 \begin_layout Itemize
23641
23642 \series bold
23643 preproc_asm
23644 \series default
23645
23646 \begin_inset LatexCommand index
23647 name "\\#pragma preproc\\_asm"
23648
23649 \end_inset
23650
23651  (+ | -) - switch _asm _endasm block preprocessing on / off.
23652  Default is on.
23653  You use this pragma to define multilines of assembly code.
23654  This will prevent the preprocessor from changing the formatting required
23655  by assembly code.
23656  Below is an example on how to use this pragma.
23657 \end_layout
23658
23659 \begin_layout Verse
23660
23661 \family typewriter
23662 #pragma preproc_asm -
23663 \begin_inset LatexCommand index
23664 name "\\#pragma preproc\\_asm"
23665
23666 \end_inset
23667
23668
23669 \newline
23670 #define MYDELAY _asm
23671 \newline
23672 \InsetSpace ~
23673 \InsetSpace ~
23674 \InsetSpace ~
23675 nop ;my assembly comment...
23676 \newline
23677 \InsetSpace ~
23678 \InsetSpace ~
23679 \InsetSpace ~
23680 nop
23681 \newline
23682 \InsetSpace ~
23683 \InsetSpace ~
23684 \InsetSpace ~
23685 nop
23686 \newline
23687 _endasm
23688 \newline
23689 #pragma preproc_asm
23690  +
23691 \newline
23692
23693 \newline
23694 void foo (void) 
23695 \newline
23696
23697 \newline
23698 \InsetSpace ~
23699 \InsetSpace ~
23700 \InsetSpace ~
23701  ...
23702  
23703 \newline
23704 \InsetSpace ~
23705 \InsetSpace ~
23706 \InsetSpace ~
23707  MYDELAY;
23708 \newline
23709 \InsetSpace ~
23710 \InsetSpace ~
23711 \InsetSpace ~
23712  ...
23713  
23714 \newline
23715
23716 \newline
23717
23718 \end_layout
23719
23720 \begin_layout Itemize
23721
23722 \series bold
23723 sdcc_hash
23724 \series default
23725
23726 \begin_inset LatexCommand index
23727 name "\\#pragma sdcc\\_hash"
23728
23729 \end_inset
23730
23731  (+ | -) - Allow "naked" hash in macro definition, for example:
23732 \newline
23733
23734 \family typewriter
23735 #define DIR_LO(x) #(x & 0xff)
23736 \family default
23737
23738 \newline
23739 Default is off.
23740  Below is an example on how to use this pragma.
23741 \end_layout
23742
23743 \begin_layout Verse
23744
23745 \family typewriter
23746 #pragma preproc_asm +
23747 \newline
23748 #pragma sdcc_hash +
23749 \begin_inset LatexCommand index
23750 name "\\#pragma sdcc\\_hash"
23751
23752 \end_inset
23753
23754
23755 \newline
23756
23757 \newline
23758 #define ROMCALL(x) 
23759 \backslash
23760
23761 \newline
23762 \InsetSpace ~
23763 \InsetSpace ~
23764 \InsetSpace ~
23765 mov R6_B3, #(x & 0xff) 
23766 \backslash
23767
23768 \newline
23769 \InsetSpace ~
23770 \InsetSpace ~
23771 \InsetSpace ~
23772 mov R7_B3, #((x >> 8) & 0xff) 
23773 \backslash
23774
23775 \newline
23776 \InsetSpace ~
23777 \InsetSpace ~
23778 \InsetSpace ~
23779 lcall __romcall
23780 \newline
23781
23782 \newline
23783 ...
23784 \newline
23785 _asm
23786 \newline
23787 ROMCALL(72)
23788 \newline
23789 _endasm;
23790 \newline
23791 ...
23792 \newline
23793
23794 \end_layout
23795
23796 \begin_layout Standard
23797 Some of the pragmas are intended to be used to turn-on or off certain optimizati
23798 ons which might cause the compiler to generate extra stack and/or data space
23799  to store compiler generated temporary variables.
23800  This usually happens in large functions.
23801  Pragma directives should be used as shown in the following example, they
23802  are used to control options and optimizations for a given function.
23803  
23804 \end_layout
23805
23806 \begin_layout Verse
23807
23808 \family typewriter
23809 #pragma save
23810 \begin_inset LatexCommand index
23811 name "\\#pragma save"
23812
23813 \end_inset
23814
23815  \InsetSpace ~
23816 \InsetSpace ~
23817 \InsetSpace ~
23818 \InsetSpace ~
23819 \InsetSpace ~
23820 \InsetSpace ~
23821 \InsetSpace ~
23822 /* save the current settings */ 
23823 \newline
23824 #pragma nogcse
23825 \begin_inset LatexCommand index
23826 name "\\#pragma nogcse"
23827
23828 \end_inset
23829
23830  \InsetSpace ~
23831 \InsetSpace ~
23832 \InsetSpace ~
23833 \InsetSpace ~
23834 \InsetSpace ~
23835 /* turnoff global subexpression elimination */ 
23836 \newline
23837 #pragma noinduction
23838 \begin_inset LatexCommand index
23839 name "\\#pragma noinduction"
23840
23841 \end_inset
23842
23843  /* turn off induction optimizations */ 
23844 \newline
23845 int foo () 
23846 \newline
23847
23848 \newline
23849 \InsetSpace ~
23850  \InsetSpace ~
23851  ...
23852  
23853 \newline
23854 \InsetSpace ~
23855  \InsetSpace ~
23856  /* large code */ 
23857 \newline
23858 \InsetSpace ~
23859  \InsetSpace ~
23860  ...
23861  
23862 \newline
23863
23864 \newline
23865 #pragma restore
23866 \begin_inset LatexCommand index
23867 name "\\#pragma restore"
23868
23869 \end_inset
23870
23871  /* turn the optimizations back on */
23872 \end_layout
23873
23874 \begin_layout Standard
23875 The compiler will generate a warning message when extra space is allocated.
23876  It is strongly recommended that the save and restore pragmas be used when
23877  changing options for a function.
23878 \newline
23879
23880 \newline
23881
23882 \newline
23883
23884 \end_layout
23885
23886 \begin_layout Section
23887 Defines Created by the Compiler
23888 \end_layout
23889
23890 \begin_layout Standard
23891 The compiler creates the following #defines
23892 \begin_inset LatexCommand index
23893 name "\\#defines"
23894
23895 \end_inset
23896
23897
23898 \begin_inset LatexCommand index
23899 name "Defines created by the compiler"
23900
23901 \end_inset
23902
23903 :
23904 \newline
23905
23906 \end_layout
23907
23908 \begin_layout Standard
23909 \begin_inset Tabular
23910 <lyxtabular version="3" rows="15" columns="2">
23911 <features>
23912 <column alignment="left" valignment="top" leftline="true" width="3in">
23913 <column alignment="left" valignment="top" leftline="true" rightline="true" width="3in">
23914 <row topline="true" bottomline="true">
23915 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23916 \begin_inset Text
23917
23918 \begin_layout Standard
23919
23920 \series bold
23921 #define
23922 \end_layout
23923
23924 \end_inset
23925 </cell>
23926 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23927 \begin_inset Text
23928
23929 \begin_layout Standard
23930
23931 \series bold
23932 Description
23933 \end_layout
23934
23935 \end_inset
23936 </cell>
23937 </row>
23938 <row topline="true">
23939 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23940 \begin_inset Text
23941
23942 \begin_layout Standard
23943 SDCC
23944 \begin_inset LatexCommand index
23945 name "SDCC"
23946
23947 \end_inset
23948
23949  
23950 \end_layout
23951
23952 \end_inset
23953 </cell>
23954 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23955 \begin_inset Text
23956
23957 \begin_layout Standard
23958 Always defined.
23959  Since version 2.5.6 the version number as an int (ex.
23960  256)
23961 \end_layout
23962
23963 \end_inset
23964 </cell>
23965 </row>
23966 <row topline="true">
23967 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23968 \begin_inset Text
23969
23970 \begin_layout Standard
23971 SDCC_mcs51
23972 \begin_inset LatexCommand index
23973 name "SDCC\\_mcs51"
23974
23975 \end_inset
23976
23977  or SDCC_ds390
23978 \begin_inset LatexCommand index
23979 name "SDCC\\_ds390"
23980
23981 \end_inset
23982
23983  or SDCC_z80
23984 \begin_inset LatexCommand index
23985 name "SDCC\\_z80"
23986
23987 \end_inset
23988
23989 , etc.
23990 \end_layout
23991
23992 \end_inset
23993 </cell>
23994 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23995 \begin_inset Text
23996
23997 \begin_layout Standard
23998 depending on the model used (e.g.: -mds390)
23999 \end_layout
24000
24001 \end_inset
24002 </cell>
24003 </row>
24004 <row topline="true">
24005 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24006 \begin_inset Text
24007
24008 \begin_layout Standard
24009 __mcs51
24010 \begin_inset LatexCommand index
24011 name "\\_\\_mcs51"
24012
24013 \end_inset
24014
24015 , __ds390
24016 \begin_inset LatexCommand index
24017 name "\\_\\_ds390"
24018
24019 \end_inset
24020
24021 , __hc08
24022 \begin_inset LatexCommand index
24023 name "\\_\\_hc08"
24024
24025 \end_inset
24026
24027 , __z80
24028 \begin_inset LatexCommand index
24029 name "\\_\\_z80"
24030
24031 \end_inset
24032
24033 , etc
24034 \end_layout
24035
24036 \end_inset
24037 </cell>
24038 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24039 \begin_inset Text
24040
24041 \begin_layout Standard
24042 depending on the model used (e.g.
24043  -mz80)
24044 \end_layout
24045
24046 \end_inset
24047 </cell>
24048 </row>
24049 <row topline="true">
24050 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24051 \begin_inset Text
24052
24053 \begin_layout Standard
24054 SDCC_STACK_AUTO
24055 \begin_inset LatexCommand index
24056 name "SDCC\\_STACK\\_AUTO"
24057
24058 \end_inset
24059
24060
24061 \end_layout
24062
24063 \end_inset
24064 </cell>
24065 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24066 \begin_inset Text
24067
24068 \begin_layout Standard
24069 when 
24070 \emph on
24071 -
24072 \begin_inset ERT
24073 status collapsed
24074
24075 \begin_layout Standard
24076
24077
24078 \backslash
24079 /
24080 \end_layout
24081
24082 \end_inset
24083
24084 -stack-auto
24085 \emph default
24086  option is used
24087 \end_layout
24088
24089 \end_inset
24090 </cell>
24091 </row>
24092 <row topline="true">
24093 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24094 \begin_inset Text
24095
24096 \begin_layout Standard
24097 SDCC_MODEL_SMALL
24098 \begin_inset LatexCommand index
24099 name "SDCC\\_MODEL\\_SMALL"
24100
24101 \end_inset
24102
24103
24104 \end_layout
24105
24106 \end_inset
24107 </cell>
24108 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24109 \begin_inset Text
24110
24111 \begin_layout Standard
24112 when 
24113 \emph on
24114 -
24115 \begin_inset ERT
24116 status collapsed
24117
24118 \begin_layout Standard
24119
24120
24121 \backslash
24122 /
24123 \end_layout
24124
24125 \end_inset
24126
24127 -model-small
24128 \emph default
24129  is used
24130 \end_layout
24131
24132 \end_inset
24133 </cell>
24134 </row>
24135 <row topline="true">
24136 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24137 \begin_inset Text
24138
24139 \begin_layout Standard
24140 SDCC_MODEL_MEDIUM
24141 \begin_inset LatexCommand index
24142 name "SDCC\\_MODEL\\_MEDIUM"
24143
24144 \end_inset
24145
24146
24147 \end_layout
24148
24149 \end_inset
24150 </cell>
24151 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24152 \begin_inset Text
24153
24154 \begin_layout Standard
24155 when 
24156 \emph on
24157 -
24158 \begin_inset ERT
24159 status collapsed
24160
24161 \begin_layout Standard
24162
24163
24164 \backslash
24165 /
24166 \end_layout
24167
24168 \end_inset
24169
24170 -model-medium
24171 \emph default
24172  is used
24173 \end_layout
24174
24175 \end_inset
24176 </cell>
24177 </row>
24178 <row topline="true">
24179 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24180 \begin_inset Text
24181
24182 \begin_layout Standard
24183 SDCC_MODEL_LARGE
24184 \begin_inset LatexCommand index
24185 name "SDCC\\_MODEL\\_LARGE"
24186
24187 \end_inset
24188
24189
24190 \end_layout
24191
24192 \end_inset
24193 </cell>
24194 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24195 \begin_inset Text
24196
24197 \begin_layout Standard
24198 when 
24199 \emph on
24200 -
24201 \begin_inset ERT
24202 status collapsed
24203
24204 \begin_layout Standard
24205
24206
24207 \backslash
24208 /
24209 \end_layout
24210
24211 \end_inset
24212
24213 -model-large
24214 \emph default
24215  is used
24216 \end_layout
24217
24218 \end_inset
24219 </cell>
24220 </row>
24221 <row topline="true">
24222 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24223 \begin_inset Text
24224
24225 \begin_layout Standard
24226 SDCC_USE_XSTACK
24227 \begin_inset LatexCommand index
24228 name "SDCC\\_USE\\_XSTACK"
24229
24230 \end_inset
24231
24232
24233 \end_layout
24234
24235 \end_inset
24236 </cell>
24237 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24238 \begin_inset Text
24239
24240 \begin_layout Standard
24241 when 
24242 \emph on
24243 -
24244 \begin_inset ERT
24245 status collapsed
24246
24247 \begin_layout Standard
24248
24249
24250 \backslash
24251 /
24252 \end_layout
24253
24254 \end_inset
24255
24256 -xstack
24257 \emph default
24258  option is used
24259 \end_layout
24260
24261 \end_inset
24262 </cell>
24263 </row>
24264 <row topline="true">
24265 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24266 \begin_inset Text
24267
24268 \begin_layout Standard
24269 SDCC_STACK_TENBIT
24270 \begin_inset LatexCommand index
24271 name "SDCC\\_STACK\\_TENBIT"
24272
24273 \end_inset
24274
24275  
24276 \end_layout
24277
24278 \end_inset
24279 </cell>
24280 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24281 \begin_inset Text
24282
24283 \begin_layout Standard
24284 when 
24285 \emph on
24286 -mds390
24287 \emph default
24288  is used
24289 \end_layout
24290
24291 \end_inset
24292 </cell>
24293 </row>
24294 <row topline="true">
24295 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24296 \begin_inset Text
24297
24298 \begin_layout Standard
24299 SDCC_MODEL_FLAT24
24300 \begin_inset LatexCommand index
24301 name "SDCC\\_MODEL\\_FLAT24"
24302
24303 \end_inset
24304
24305
24306 \end_layout
24307
24308 \end_inset
24309 </cell>
24310 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24311 \begin_inset Text
24312
24313 \begin_layout Standard
24314 when 
24315 \emph on
24316 -mds390
24317 \emph default
24318  is used
24319 \end_layout
24320
24321 \end_inset
24322 </cell>
24323 </row>
24324 <row topline="true">
24325 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24326 \begin_inset Text
24327
24328 \begin_layout Standard
24329 SDCC_REVISION
24330 \begin_inset LatexCommand index
24331 name "SDCC\\_REVISION"
24332
24333 \end_inset
24334
24335
24336 \end_layout
24337
24338 \end_inset
24339 </cell>
24340 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24341 \begin_inset Text
24342
24343 \begin_layout Standard
24344 Always defined.
24345  SDCC svn revision number
24346 \end_layout
24347
24348 \end_inset
24349 </cell>
24350 </row>
24351 <row topline="true">
24352 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24353 \begin_inset Text
24354
24355 \begin_layout Standard
24356 SDCC_PARMS_IN_BANK1
24357 \begin_inset LatexCommand index
24358 name "SDCC\\_PARMS\\_IN\\_BANK1"
24359
24360 \end_inset
24361
24362
24363 \end_layout
24364
24365 \end_inset
24366 </cell>
24367 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24368 \begin_inset Text
24369
24370 \begin_layout Standard
24371 when 
24372 \emph on
24373 -
24374 \begin_inset ERT
24375 status collapsed
24376
24377 \begin_layout Standard
24378
24379
24380 \backslash
24381 /
24382 \end_layout
24383
24384 \end_inset
24385
24386 -parms-in-bank1
24387 \emph default
24388  is used
24389 \end_layout
24390
24391 \end_inset
24392 </cell>
24393 </row>
24394 <row topline="true">
24395 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24396 \begin_inset Text
24397
24398 \begin_layout Standard
24399 SDCC_FLOAT_REENT
24400 \begin_inset LatexCommand index
24401 name "SDCC\\_MODEL\\_FLAT24"
24402
24403 \end_inset
24404
24405
24406 \end_layout
24407
24408 \end_inset
24409 </cell>
24410 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24411 \begin_inset Text
24412
24413 \begin_layout Standard
24414 when 
24415 \emph on
24416 -
24417 \begin_inset ERT
24418 status collapsed
24419
24420 \begin_layout Standard
24421
24422
24423 \backslash
24424 /
24425 \end_layout
24426
24427 \end_inset
24428
24429 -float-reent
24430 \emph default
24431  is used
24432 \end_layout
24433
24434 \end_inset
24435 </cell>
24436 </row>
24437 <row topline="true" bottomline="true">
24438 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24439 \begin_inset Text
24440
24441 \begin_layout Standard
24442 SDCC_INT_LONG_REENT
24443 \begin_inset LatexCommand index
24444 name "SDCC\\_INT\\_LONG\\_REENT"
24445
24446 \end_inset
24447
24448
24449 \end_layout
24450
24451 \end_inset
24452 </cell>
24453 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24454 \begin_inset Text
24455
24456 \begin_layout Standard
24457 when 
24458 \emph on
24459 -
24460 \begin_inset ERT
24461 status collapsed
24462
24463 \begin_layout Standard
24464
24465
24466 \backslash
24467 /
24468 \end_layout
24469
24470 \end_inset
24471
24472 -int-long-reent
24473 \emph default
24474  is used
24475 \end_layout
24476
24477 \end_inset
24478 </cell>
24479 </row>
24480 </lyxtabular>
24481
24482 \end_inset
24483
24484
24485 \end_layout
24486
24487 \begin_layout Chapter
24488 Notes on supported Processors
24489 \end_layout
24490
24491 \begin_layout Section
24492 MCS51 variants
24493 \begin_inset LatexCommand label
24494 name "sub:MCS51-variants"
24495
24496 \end_inset
24497
24498
24499 \begin_inset LatexCommand index
24500 name "MCS51 variants"
24501
24502 \end_inset
24503
24504
24505 \end_layout
24506
24507 \begin_layout Standard
24508 MCS51 processors are available from many vendors and come in many different
24509  flavours.
24510  While they might differ considerably in respect to Special Function Registers
24511  the core MCS51 is usually not modified or is kept compatible.
24512  
24513 \end_layout
24514
24515 \begin_layout Subsection
24516 pdata access by SFR 
24517 \end_layout
24518
24519 \begin_layout Standard
24520 With the upcome of devices with internal xdata and flash memory devices
24521  using port P2
24522 \begin_inset LatexCommand index
24523 name "P2 (mcs51 sfr)"
24524
24525 \end_inset
24526
24527  as dedicated I/O port is becoming more popular.
24528  Switching the high byte for pdata
24529 \begin_inset LatexCommand index
24530 name "pdata (mcs51, ds390 storage class)"
24531
24532 \end_inset
24533
24534  access which was formerly done by port P2 is then achieved by a Special
24535  Function Register
24536 \begin_inset LatexCommand index
24537 name "sfr"
24538
24539 \end_inset
24540
24541 .
24542  In well-established MCS51 tradition the address of this 
24543 \emph on
24544 sfr
24545 \emph default
24546  is where the chip designers decided to put it.
24547  Needless to say that they didn't agree on a common name either.
24548  So that the startup code can correctly initialize xdata variables, you
24549  should define an sfr with the name _XPAGE
24550 \family typewriter
24551
24552 \begin_inset LatexCommand index
24553 name "\\_XPAGE (mcs51)"
24554
24555 \end_inset
24556
24557
24558 \family default
24559  at the appropriate location if the default, port P2, is not used for this.
24560  Some examples are:
24561 \end_layout
24562
24563 \begin_layout Verse
24564
24565 \family typewriter
24566 __sfr __at (0x85) _XPAGE; /* Ramtron VRS51 family a.k.a.
24567  MPAGE */
24568 \end_layout
24569
24570 \begin_layout Verse
24571
24572 \family typewriter
24573 __sfr __at (0x92) _XPAGE; /* Cypress EZ-USB family, Texas Instruments (Chipcon)
24574  a.k.a.
24575  MPAGE */
24576 \end_layout
24577
24578 \begin_layout Verse
24579
24580 \family typewriter
24581 __sfr __at (0x91) _XPAGE; /* Infineon (Siemens) C500 family a.k.a.
24582  XPAGE */
24583 \end_layout
24584
24585 \begin_layout Verse
24586
24587 \family typewriter
24588 __sfr __at (0xaf) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
24589  EMI0CN */
24590 \end_layout
24591
24592 \begin_layout Verse
24593
24594 \family typewriter
24595 __sfr __at (0xaa) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
24596  EMI0CN */
24597 \end_layout
24598
24599 \begin_layout Standard
24600 For more exotic implementations further customizations may be needed.
24601  See section 
24602 \begin_inset LatexCommand ref
24603 reference "sub:Startup-Code"
24604
24605 \end_inset
24606
24607  for other possibilities.
24608 \end_layout
24609
24610 \begin_layout Subsection
24611 Other Features available by SFR
24612 \end_layout
24613
24614 \begin_layout Standard
24615 Some MCS51 variants offer features like Double DPTR
24616 \begin_inset LatexCommand index
24617 name "DPTR"
24618
24619 \end_inset
24620
24621 , multiple DPTR, decrementing DPTR, 16x16 Multiply.
24622  These are currently not used for the MCS51 port.
24623  If you absolutely need them you can fall back to inline assembly or submit
24624  a patch to SDCC.
24625 \end_layout
24626
24627 \begin_layout Subsection
24628 Bankswitching
24629 \end_layout
24630
24631 \begin_layout Standard
24632 Bankswitching
24633 \begin_inset LatexCommand index
24634 name "Bankswitching"
24635
24636 \end_inset
24637
24638  (a.k.a.
24639  code banking
24640 \begin_inset LatexCommand index
24641 name "code banking"
24642
24643 \end_inset
24644
24645 ) is a technique to increase the code space above the 64k limit of the 8051.
24646 \end_layout
24647
24648 \begin_layout Subsubsection
24649 Hardware
24650 \end_layout
24651
24652 \begin_layout Standard
24653 \begin_inset Tabular
24654 <lyxtabular version="3" rows="3" columns="4">
24655 <features>
24656 <column alignment="center" valignment="top" width="0">
24657 <column alignment="center" valignment="top" leftline="true" width="0">
24658 <column alignment="center" valignment="top" leftline="true" width="0">
24659 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24660 <row topline="true" bottomline="true">
24661 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
24662 \begin_inset Text
24663
24664 \begin_layout Standard
24665 8000-FFFF
24666 \end_layout
24667
24668 \end_inset
24669 </cell>
24670 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24671 \begin_inset Text
24672
24673 \begin_layout Standard
24674 bank1
24675 \end_layout
24676
24677 \end_inset
24678 </cell>
24679 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24680 \begin_inset Text
24681
24682 \begin_layout Standard
24683 bank2
24684 \end_layout
24685
24686 \end_inset
24687 </cell>
24688 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24689 \begin_inset Text
24690
24691 \begin_layout Standard
24692 bank3
24693 \end_layout
24694
24695 \end_inset
24696 </cell>
24697 </row>
24698 <row topline="true" bottomline="true">
24699 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
24700 \begin_inset Text
24701
24702 \begin_layout Standard
24703 0000-7FFF
24704 \end_layout
24705
24706 \end_inset
24707 </cell>
24708 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24709 \begin_inset Text
24710
24711 \begin_layout Standard
24712 common
24713 \end_layout
24714
24715 \end_inset
24716 </cell>
24717 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
24718 \begin_inset Text
24719
24720 \begin_layout Standard
24721
24722 \end_layout
24723
24724 \end_inset
24725 </cell>
24726 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24727 \begin_inset Text
24728
24729 \begin_layout Standard
24730
24731 \end_layout
24732
24733 \end_inset
24734 </cell>
24735 </row>
24736 <row>
24737 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
24738 \begin_inset Text
24739
24740 \begin_layout Standard
24741 SiLabs C8051F120 example
24742 \end_layout
24743
24744 \end_inset
24745 </cell>
24746 <cell multicolumn="2" alignment="center" valignment="top" usebox="none">
24747 \begin_inset Text
24748
24749 \begin_layout Standard
24750
24751 \end_layout
24752
24753 \end_inset
24754 </cell>
24755 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24756 \begin_inset Text
24757
24758 \begin_layout Standard
24759
24760 \end_layout
24761
24762 \end_inset
24763 </cell>
24764 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24765 \begin_inset Text
24766
24767 \begin_layout Standard
24768
24769 \end_layout
24770
24771 \end_inset
24772 </cell>
24773 </row>
24774 </lyxtabular>
24775
24776 \end_inset
24777
24778
24779 \newline
24780
24781 \newline
24782 Usually the hardware uses some sfr (an output port or an internal sfr) to
24783  select a bank and put it in the banked area of the memory map.
24784  The selected bank usually becomes active immediately upon assignment to
24785  this sfr and when running inside a bank it will switch out this code it
24786  is currently running.
24787  Therefor you cannot jump or call directly from one bank to another and
24788  need to use a so-called trampoline in the common area.
24789  For SDCC an example trampoline is in crtbank.asm and you may need to change
24790  it to your 8051 derivative or schematic.
24791  The presented code is written for the C8051F120.
24792 \newline
24793
24794 \newline
24795 When calling a banked function
24796  SDCC will put the LSB of the functions address in register R0, the MSB
24797  in R1 and the bank in R2 and then call this trampoline 
24798 \emph on
24799 __sdcc_banked_call
24800 \emph default
24801 .
24802  The current selected bank is saved on the stack, the new bank is selected
24803  and an indirect jump is made.
24804  When the banked function returns it jumps to 
24805 \emph on
24806 __sdcc_banked_ret
24807 \emph default
24808  which restores the previous bank and returns to the caller.
24809 \end_layout
24810
24811 \begin_layout Subsubsection
24812 Software
24813 \end_layout
24814
24815 \begin_layout Standard
24816 When writing banked software using SDCC you need to use some special keywords
24817  and options.
24818  You also need to take over a bit of work from the linker.
24819 \newline
24820
24821 \newline
24822 To create a function
24823  that can be called from another bank it requires the keyword 
24824 \emph on
24825 banked
24826 \emph default
24827
24828 \begin_inset LatexCommand index
24829 name "banked"
24830
24831 \end_inset
24832
24833 .
24834  The caller must see this in the prototype of the callee and the callee
24835  needs it for a proper return.
24836  Called functions within the same bank as the caller do not need the 
24837 \emph on
24838 banked
24839 \emph default
24840  keyword nor do functions in the common area.
24841  Beware: SDCC does not know or check if functions are in the same bank.
24842  This is your responsibility!
24843 \newline
24844
24845 \newline
24846 Normally all functions you write end up in
24847  the segment CSEG.
24848  If you want a function explicitly to reside in the common area put it in
24849  segment HOME.
24850  This applies for instance to interrupt service routines as they should
24851  not be banked.
24852 \end_layout
24853
24854 \begin_layout Standard
24855 Functions that need to be in a switched bank must be put in a named segment.
24856  The name can be mostly anything up to eight characters (e.g.
24857  BANK1).
24858  To do this you either use -
24859 \begin_inset ERT
24860 status collapsed
24861
24862 \begin_layout Standard
24863
24864
24865 \backslash
24866 /
24867 \end_layout
24868
24869 \end_inset
24870
24871 -codeseg BANK1 (See 
24872 \begin_inset LatexCommand ref
24873 reference "lyx:-codeseg"
24874
24875 \end_inset
24876
24877 ) on the command line when compiling or #pragma codeseg BANK1 (See 
24878 \begin_inset LatexCommand ref
24879 reference "sec:Pragmas"
24880
24881 \end_inset
24882
24883 ) at the top of the C source file.
24884  The segment name always applies to the whole source file and generated
24885  object so functions for different banks need to be defined in different
24886  source files.
24887 \newline
24888
24889 \newline
24890 When linking your objects you need to tell the linker where
24891  to put your segments.
24892  To do this you use the following command line option to SDCC: -Wl-b BANK1=0x180
24893 00 (See 
24894 \begin_inset LatexCommand ref
24895 reference "lyx:-Wl option"
24896
24897 \end_inset
24898
24899 ).
24900  This sets the virtual start address of this segment.
24901  It sets the banknumber to 0x01 and maps the bank to 0x8000 and up.
24902  The linker will not check for overflows, again this is your responsibility.
24903 \end_layout
24904
24905 \begin_layout Standard
24906 \begin_inset VSpace bigskip
24907 \end_inset
24908
24909
24910 \end_layout
24911
24912 \begin_layout Section
24913 DS400 port
24914 \end_layout
24915
24916 \begin_layout Standard
24917 The DS80C400
24918 \begin_inset LatexCommand index
24919 name "DS80C400"
24920
24921 \end_inset
24922
24923
24924 \begin_inset LatexCommand index
24925 name "DS400"
24926
24927 \end_inset
24928
24929  microcontroller has a rich set of peripherals.
24930  In its built-in ROM library it includes functions to access some of the
24931  features, among them is a TCP stack with IP4 and IP6 support.
24932  Library headers (currently in beta status) and other files are provided
24933  at 
24934 \size footnotesize
24935
24936 \begin_inset LatexCommand url
24937 target "ftp://ftp.dalsemi.com/pub/tini/ds80c400/c_libraries/sdcc/index.html"
24938
24939 \end_inset
24940
24941 .
24942  
24943 \begin_inset VSpace bigskip
24944 \end_inset
24945
24946
24947 \end_layout
24948
24949 \begin_layout Section
24950 The Z80 and gbz80 port
24951 \end_layout
24952
24953 \begin_layout Standard
24954 SDCC can target both the Zilog Z80
24955 \begin_inset LatexCommand index
24956 name "Z80"
24957
24958 \end_inset
24959
24960  and the Nintendo Gameboy's Z80-like gbz80
24961 \begin_inset LatexCommand index
24962 name "gbz80 (GameBoy Z80)"
24963
24964 \end_inset
24965
24966 .
24967  The Z80 port is passed through the same 
24968 \emph on
24969 regressions tests
24970 \begin_inset LatexCommand index
24971 name "Regression test"
24972
24973 \end_inset
24974
24975
24976 \emph default
24977  (see section 
24978 \begin_inset LatexCommand ref
24979 reference "sec:Quality-control"
24980
24981 \end_inset
24982
24983 ) as the MCS51 and DS390 ports, so floating point support, support for long
24984  variables and bitfield support is fine.
24985  See mailing lists and forums about interrupt routines.
24986 \end_layout
24987
24988 \begin_layout Standard
24989 As always, the code is the authoritative reference - see z80/ralloc.c and
24990  z80/gen.c.
24991  The stack
24992 \begin_inset LatexCommand index
24993 name "Z80!stack"
24994
24995 \end_inset
24996
24997  frame is similar to that generated by the IAR Z80 compiler.
24998  IX is used as the base pointer, HL and IY are used as a temporary registers,
24999  and BC and DE are available for holding variables.
25000  Return values
25001 \begin_inset LatexCommand index
25002 name "Z80!return value"
25003
25004 \end_inset
25005
25006  for the Z80 port are stored in L (one byte), HL (two bytes), or DEHL (four
25007  bytes).
25008  The gbz80 port use the same set of registers for the return values, but
25009  in a different order of significance: E (one byte), DE (two bytes), or
25010  HLDE (four bytes).
25011 \begin_inset VSpace bigskip
25012 \end_inset
25013
25014
25015 \end_layout
25016
25017 \begin_layout Section
25018 The HC08 port
25019 \end_layout
25020
25021 \begin_layout Standard
25022 The port to the Freescale/Motorola HC08
25023 \begin_inset LatexCommand index
25024 name "HC08"
25025
25026 \end_inset
25027
25028  family has been added in October 2003, and is still undergoing some basic
25029  development.
25030  The code generator is complete, but the register allocation is still quite
25031  unoptimized.
25032  Some of the SDCC's standard C library functions have embedded non-HC08
25033  inline assembly and so are not yet usable.
25034 \end_layout
25035
25036 \begin_layout Standard
25037 The HC08 port passes the regression test suite (see section 
25038 \begin_inset LatexCommand ref
25039 reference "sec:Quality-control"
25040
25041 \end_inset
25042
25043 ).
25044 \begin_inset VSpace bigskip
25045 \end_inset
25046
25047
25048 \end_layout
25049
25050 \begin_layout Section
25051 The PIC14
25052 \begin_inset LatexCommand index
25053 name "PIC14"
25054
25055 \end_inset
25056
25057  port
25058 \end_layout
25059
25060 \begin_layout Standard
25061 The PIC14 port adds support for Microchip
25062 \begin_inset LatexCommand index
25063 name "Microchip"
25064
25065 \end_inset
25066
25067
25068 \begin_inset Formula $^{\text{TM}}$
25069 \end_inset
25070
25071  PIC
25072 \begin_inset LatexCommand index
25073 name "PIC14"
25074
25075 \end_inset
25076
25077
25078 \begin_inset Formula $^{\text{TM}}$
25079 \end_inset
25080
25081  MCUs with 14 bit wide instructions.
25082  This port is not yet mature and still lacks many features.
25083  However, it can work for simple code.
25084 \end_layout
25085
25086 \begin_layout Standard
25087 \noindent
25088 Currently supported devices include:
25089 \end_layout
25090
25091 \begin_layout Standard
25092 12F: 629, 635, 675, 683
25093 \end_layout
25094
25095 \begin_layout Standard
25096 16C: 432, 433
25097 \end_layout
25098
25099 \begin_layout Standard
25100 16C: 554, 557, 558
25101 \end_layout
25102
25103 \begin_layout Standard
25104 16C: 62, 620, 620a, 621, 621a, 622, 622a, 63a, 65b
25105 \end_layout
25106
25107 \begin_layout Standard
25108 16C: 71, 710, 711, 715, 717, 72, 73b, 745, 74b, 765, 770, 771, 773, 774,
25109  781, 782
25110 \end_layout
25111
25112 \begin_layout Standard
25113 16C: 925, 926
25114 \end_layout
25115
25116 \begin_layout Standard
25117 16CR: 620a, 73, 74, 76, 77
25118 \end_layout
25119
25120 \begin_layout Standard
25121 16F: 616, 627, 627a, 628, 628a, 630, 636, 639, 648, 648a, 676, 684, 685,
25122  687, 688, 689, 690
25123 \end_layout
25124
25125 \begin_layout Standard
25126 16F: 716, 72, 73, 737, 74, 747, 76, 767, 77, 777, 785
25127 \end_layout
25128
25129 \begin_layout Standard
25130 16F: 818, 819, 84, 84a, 87, 870, 871, 872, 873, 873a, 874, 874a, 876, 876a,
25131  877, 877a, 88, 886, 887
25132 \end_layout
25133
25134 \begin_layout Standard
25135 16F: 913, 914, 916, 917, 946
25136 \end_layout
25137
25138 \begin_layout Standard
25139 26HV: 626, 785
25140 \end_layout
25141
25142 \begin_layout Standard
25143 \noindent
25144 An up-to-date list of currently supported devices can be obtained via 
25145 \family typewriter
25146 sdcc -mpic14 -phelp foo.c
25147 \family default
25148  (foo.c must exist...).
25149 \end_layout
25150
25151 \begin_layout Subsection
25152 PIC Code Pages
25153 \begin_inset LatexCommand index
25154 name "code page (pic14)"
25155
25156 \end_inset
25157
25158  and Memory Banks
25159 \begin_inset LatexCommand index
25160 name "Memory bank (pic14)"
25161
25162 \end_inset
25163
25164
25165 \end_layout
25166
25167 \begin_layout Standard
25168 The linker organizes allocation for the code page and RAM banks.
25169  It does not have intimate knowledge of the code flow.
25170  It will put all the code section of a single .asm file into a single code
25171  page.
25172  In order to make use of multiple code pages, separate asm files must be
25173  used.
25174  The compiler assigns all 
25175 \emph on
25176 static
25177 \emph default
25178  functions of a single .c file into the same code page.
25179 \newline
25180
25181 \newline
25182 To get the best results,
25183  follow these guidelines:
25184 \end_layout
25185
25186 \begin_layout Enumerate
25187 Make local functions static, as non static functions require code page selection
25188  overhead.
25189 \newline
25190 Due to the way sdcc handles functions, place called functions prior
25191  to calling functions in the file wherever possible: Otherwise sdcc will
25192  insert unnecessary pagesel directives around the call, believing that the
25193  called function is externally defined.
25194 \end_layout
25195
25196 \begin_layout Enumerate
25197 For devices that have multiple code pages it is more efficient to use the
25198  same number of files as pages: Use up to 4 separate .c files for the 16F877,
25199  but only 2 files for the 16F874.
25200  This way the linker can put the code for each file into different code
25201  pages and there will be less page selection overhead.
25202 \end_layout
25203
25204 \begin_layout Enumerate
25205 And as for any 8 bit micro (especially for PIC14 as they have a very simple
25206  instruction set), use `unsigned char' wherever possible instead of `int'.
25207 \end_layout
25208
25209 \begin_layout Subsection
25210 Adding New Devices to the Port 
25211 \end_layout
25212
25213 \begin_layout Standard
25214 Adding support for a new 14
25215 \begin_inset ERT
25216 status open
25217
25218 \begin_layout Standard
25219
25220
25221 \backslash
25222 ,
25223 \end_layout
25224
25225 \end_inset
25226
25227 bit PIC MCU requires the following steps:
25228 \end_layout
25229
25230 \begin_layout Enumerate
25231 Create a new device description.
25232 \newline
25233 Each device is described in two files: pic16f*.h
25234  and pic16f*.c.
25235  These files primarily define SFRs, structs to access their bits, and symbolic
25236  configuration options.
25237  Both files can be generated from gputils' .inc files using the perl script
25238  
25239 \family typewriter
25240 support/scripts/inc2h.pl
25241 \family default
25242 .
25243  This file also contains further instructions on how to proceed.
25244 \end_layout
25245
25246 \begin_layout Enumerate
25247 Copy the .h file into SDCC's include path and either add the .c file to your
25248  project or copy it to 
25249 \family typewriter
25250 device/lib/pic/libdev
25251 \family default
25252 .
25253  Afterwards, rebuild and install the libraries.
25254 \end_layout
25255
25256 \begin_layout Enumerate
25257 Edit pic14devices.txt in SDCC's include path (
25258 \family typewriter
25259 device/include/pic/
25260 \family default
25261  in the source tree or 
25262 \family typewriter
25263 /usr/local/share/sdcc/include/pic
25264 \family default
25265  after installation).
25266 \newline
25267 You need to add a device specification here to make
25268  the memory layout (code banks, RAM, aliased memory regions, ...) known to
25269  the compiler.
25270  Probably you can copy and modify an existing entry.
25271  The file format is documented at the top of the file.
25272 \end_layout
25273
25274 \begin_layout Subsection
25275 Interrupt Code
25276 \end_layout
25277
25278 \begin_layout Standard
25279 For the interrupt function, use the keyword `__interrupt'
25280 \begin_inset LatexCommand index
25281 name "PIC14!interrupt"
25282
25283 \end_inset
25284
25285  with level number of 0 (PIC14 only has 1 interrupt so this number is only
25286  there to avoid a syntax error - it ought to be fixed).
25287  E.g.:
25288 \end_layout
25289
25290 \begin_layout Verse
25291
25292 \family typewriter
25293 void Intr(void) __interrupt 0
25294 \newline
25295 {
25296 \newline
25297 \InsetSpace ~
25298 \InsetSpace ~
25299 T0IF = 0; /* Clear timer interrupt */
25300 \newline
25301 }
25302 \end_layout
25303
25304 \begin_layout Subsection
25305 Linking and Assembling
25306 \end_layout
25307
25308 \begin_layout Standard
25309 For assembling you can use either GPUTILS'
25310 \begin_inset LatexCommand index
25311 name "gputils (pic tools)"
25312
25313 \end_inset
25314
25315  gpasm.exe or MPLAB's mpasmwin.exe.
25316  GPUTILS are available from 
25317 \begin_inset LatexCommand url
25318 target "http://sourceforge.net/projects/gputils"
25319
25320 \end_inset
25321
25322 .
25323  For linking you can use either GPUTILS' gplink or MPLAB's mplink.exe.
25324  If you use MPLAB and an interrupt function then the linker script file
25325  vectors section will need to be enlarged to link with mplink.
25326 \newline
25327
25328 \newline
25329 Here is a 
25330 \family typewriter
25331 Makefile
25332 \family default
25333  using GPUTILS:
25334 \end_layout
25335
25336 \begin_layout Verse
25337
25338 \family typewriter
25339 .c.o:
25340 \newline
25341 \InsetSpace ~
25342 \InsetSpace ~
25343 \InsetSpace ~
25344 \InsetSpace ~
25345 \InsetSpace ~
25346 \InsetSpace ~
25347 \InsetSpace ~
25348 \InsetSpace ~
25349 sdcc -V -mpic14 -p16f877 -c $< 
25350 \newline
25351
25352 \newline
25353 $(PRJ).hex: $(OBJS) 
25354 \newline
25355 \InsetSpace ~
25356 \InsetSpace ~
25357 \InsetSpace ~
25358 \InsetSpace ~
25359 \InsetSpace ~
25360 \InsetSpace ~
25361 \InsetSpace ~
25362 \InsetSpace ~
25363 gplink -m -s $(PRJ).lkr
25364  -o $(PRJ).hex $(OBJS) libsdcc.lib
25365 \end_layout
25366
25367 \begin_layout Standard
25368 Here is a 
25369 \family typewriter
25370 Makefile
25371 \family default
25372  using MPLAB:
25373 \end_layout
25374
25375 \begin_layout Verse
25376
25377 \family typewriter
25378 .c.o: 
25379 \newline
25380 \InsetSpace ~
25381 \InsetSpace ~
25382 \InsetSpace ~
25383 \InsetSpace ~
25384 \InsetSpace ~
25385 \InsetSpace ~
25386 \InsetSpace ~
25387 \InsetSpace ~
25388 sdcc -S -V -mpic14 -p16f877 $< 
25389 \newline
25390 \InsetSpace ~
25391 \InsetSpace ~
25392 \InsetSpace ~
25393 \InsetSpace ~
25394 \InsetSpace ~
25395 \InsetSpace ~
25396 \InsetSpace ~
25397 \InsetSpace ~
25398 mpasmwin /q /o $*.asm
25399 \newline
25400
25401 \newline
25402 $(PRJ).hex: $(OBJS)
25403  
25404 \newline
25405 \InsetSpace ~
25406 \InsetSpace ~
25407 \InsetSpace ~
25408 \InsetSpace ~
25409 \InsetSpace ~
25410 \InsetSpace ~
25411 \InsetSpace ~
25412 \InsetSpace ~
25413 mplink /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS) libsdcc.lib
25414 \end_layout
25415
25416 \begin_layout Standard
25417 Please note that indentations within a 
25418 \family typewriter
25419 Makefile
25420 \family default
25421  have to be done with a tabulator character.
25422 \end_layout
25423
25424 \begin_layout Subsection
25425 Command-Line Options
25426 \end_layout
25427
25428 \begin_layout Standard
25429 Besides the switches common to all SDCC backends, the PIC14 port accepts
25430  the following options (for an updated list see sdcc -
25431 \begin_inset ERT
25432 status collapsed
25433
25434 \begin_layout Standard
25435
25436
25437 \backslash
25438 /
25439 \end_layout
25440
25441 \end_inset
25442
25443 -help):
25444 \end_layout
25445
25446 \begin_layout Description
25447 -
25448 \begin_inset ERT
25449 status collapsed
25450
25451 \begin_layout Standard
25452
25453
25454 \backslash
25455 /
25456 \end_layout
25457
25458 \end_inset
25459
25460 -debug-xtra
25461 \begin_inset LatexCommand index
25462 name "PIC14!Options!-\\/-debug-extra"
25463
25464 \end_inset
25465
25466  emit debug info in assembly output
25467 \end_layout
25468
25469 \begin_layout Description
25470 -
25471 \begin_inset ERT
25472 status collapsed
25473
25474 \begin_layout Standard
25475
25476
25477 \backslash
25478 /
25479 \end_layout
25480
25481 \end_inset
25482
25483 -no-pcode-opt
25484 \begin_inset LatexCommand index
25485 name "PIC14!Options!-\\/-no-pcode-opt"
25486
25487 \end_inset
25488
25489  disable (slightly faulty) optimization on pCode
25490 \end_layout
25491
25492 \begin_layout Description
25493 -
25494 \begin_inset ERT
25495 status collapsed
25496
25497 \begin_layout Standard
25498
25499
25500 \backslash
25501 /
25502 \end_layout
25503
25504 \end_inset
25505
25506 -stack-loc
25507 \begin_inset LatexCommand index
25508 name "PIC14!Options!-\\/-stack-loc"
25509
25510 \end_inset
25511
25512  sets the lowest address of the argument passing stack (defaults to a suitably
25513  large shared databank to reduce BANKSEL overhead)
25514 \end_layout
25515
25516 \begin_layout Description
25517 -
25518 \begin_inset ERT
25519 status collapsed
25520
25521 \begin_layout Standard
25522
25523
25524 \backslash
25525 /
25526 \end_layout
25527
25528 \end_inset
25529
25530 -stack-size
25531 \begin_inset LatexCommand index
25532 name "PIC14!Options!-\\/-stack-size"
25533
25534 \end_inset
25535
25536  sets the size if the argument passing stack (default: 16, minimum: 4)
25537 \end_layout
25538
25539 \begin_layout Subsection
25540 Environment Variables
25541 \end_layout
25542
25543 \begin_layout Standard
25544 The PIC14 port recognizes the following environment variables:
25545 \end_layout
25546
25547 \begin_layout Description
25548 SDCC_PIC14_SPLIT_LOCALS If set and not empty, sdcc will allocate each temporary
25549  register (the ones called r0xNNNN) in a section of its own.
25550  By default (if this variable is unset), sdcc tries to cluster registers
25551  in sections in order to reduce the BANKSEL overhead when accessing them.
25552 \end_layout
25553
25554 \begin_layout Subsection
25555 The Library
25556 \end_layout
25557
25558 \begin_layout Standard
25559 The PIC14 library currently only contains support routines required by the
25560  compiler to implement multiplication, division, and floating point support.
25561  No libc-like replacement is available at the moment, though many of the
25562  common sdcc library sources (in 
25563 \family typewriter
25564 device/lib
25565 \family default
25566 ) should also compile with the PIC14 port.
25567 \end_layout
25568
25569 \begin_layout Subsubsection
25570 error: missing definition for symbol ``__gptrget1''
25571 \end_layout
25572
25573 \begin_layout Standard
25574 The PIC14 port uses library routines to provide more complex operations
25575  like multiplication, division/modulus and (generic) pointer dereferencing.
25576  In order to add these routines to your project, you must link with PIC14's
25577  
25578 \family typewriter
25579 libsdcc.lib
25580 \family default
25581 .
25582  For single source file projects this is done automatically, more complex
25583  projects must add 
25584 \family typewriter
25585 libsdcc.lib
25586 \family default
25587  to the linker's arguments.
25588  Make sure you also add an include path for the library (using the -I switch
25589  to the linker)!
25590 \end_layout
25591
25592 \begin_layout Subsubsection
25593 Processor mismatch in file ``XXX''.
25594 \end_layout
25595
25596 \begin_layout Standard
25597 This warning can usually be ignored due to the very good compatibility amongst
25598  14
25599 \begin_inset ERT
25600 status open
25601
25602 \begin_layout Standard
25603
25604
25605 \backslash
25606 ,
25607 \end_layout
25608
25609 \end_inset
25610
25611 bit PIC
25612 \begin_inset LatexCommand index
25613 name "PIC14"
25614
25615 \end_inset
25616
25617  devices.
25618 \end_layout
25619
25620 \begin_layout Standard
25621 You might also consider recompiling the library for your specific device
25622  by changing the ARCH=p16f877 (default target) entry in 
25623 \family typewriter
25624 device/lib/pic/Makefile.in
25625 \family default
25626  and 
25627 \family typewriter
25628 device/lib/pic/Makefile
25629 \family default
25630  to reflect your device.
25631  This might even improve performance for smaller devices as unnecessary
25632  BANKSELs might be removed.
25633 \end_layout
25634
25635 \begin_layout Subsection
25636 Known Bugs
25637 \end_layout
25638
25639 \begin_layout Subsubsection
25640 Function arguments
25641 \end_layout
25642
25643 \begin_layout Standard
25644 Functions with variable argument lists (like printf) are not yet supported.
25645  Similarly, taking the address of the first argument passed into a function
25646  does not work: It is currently passed in WREG and has no address...
25647 \end_layout
25648
25649 \begin_layout Subsubsection
25650 Regression tests fail
25651 \end_layout
25652
25653 \begin_layout Standard
25654 Though the small subset of regression tests in src/regression passes, SDCC
25655  regression test suite does not, indicating that there are still major bugs
25656  in the port.
25657  However, many smaller projects have successfully used SDCC in the past...
25658 \end_layout
25659
25660 \begin_layout Standard
25661
25662 \size footnotesize
25663
25664 \newpage
25665
25666 \end_layout
25667
25668 \begin_layout Section
25669 The PIC16
25670 \begin_inset LatexCommand index
25671 name "PIC16"
25672
25673 \end_inset
25674
25675  port
25676 \end_layout
25677
25678 \begin_layout Standard
25679 The PIC16 port adds support for Microchip
25680 \begin_inset LatexCommand index
25681 name "Microchip"
25682
25683 \end_inset
25684
25685
25686 \begin_inset Formula $^{\text{TM}}$
25687 \end_inset
25688
25689  PIC
25690 \begin_inset LatexCommand index
25691 name "PIC"
25692
25693 \end_inset
25694
25695
25696 \begin_inset Formula $^{\text{TM}}$
25697 \end_inset
25698
25699  MCUs with 16 bit wide instructions.
25700  Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx
25701 ; devices supported by the port include:
25702 \end_layout
25703
25704 \begin_layout Standard
25705 18F: 242, 248, 252, 258, 442, 448, 452, 458
25706 \end_layout
25707
25708 \begin_layout Standard
25709 18F: 1220, 1320
25710 \end_layout
25711
25712 \begin_layout Standard
25713 18F: 2220, 2221, 2320, 2321, 2331, 2410, 2420, 2423, 2431, 2450, 2455, 2480,
25714  24j10
25715 \end_layout
25716
25717 \begin_layout Standard
25718 18F: (2510,) 2515, 2520, 2523, 2525, 2550, 2580, 2585, 25j10, 2610, 2620,
25719  2680, 2682, 2685
25720 \end_layout
25721
25722 \begin_layout Standard
25723 18F: 4220, 4221, 4320, 4321, 4331, 4410, 4420, 4423, 4431, 4450, 4455, 4480,
25724  44j10
25725 \end_layout
25726
25727 \begin_layout Standard
25728 18F: 4510, 4515, 4520, 4523, 4525, 4550, 4580, 4585, 45j10, 4610, 4620,
25729  4680, 4682, 4685
25730 \end_layout
25731
25732 \begin_layout Standard
25733 18F: 6520, 6585, 6620, 6680, 66j60, 66j65, 6720, 67j60
25734 \end_layout
25735
25736 \begin_layout Standard
25737 18F: 8520, 8585, 8620, 8680, 86j60, 86j65, 8720, 87j60
25738 \end_layout
25739
25740 \begin_layout Standard
25741 18F: 96j60, 96j65, 97j60
25742 \end_layout
25743
25744 \begin_layout Standard
25745 \noindent
25746 An up-to-date list of supported devices is also available via '
25747 \family typewriter
25748 sdcc -mpic16 -plist
25749 \family default
25750 '.
25751 \end_layout
25752
25753 \begin_layout Subsection
25754 Global Options
25755 \end_layout
25756
25757 \begin_layout Standard
25758 PIC16 port supports the standard command line arguments as supposed, with
25759  the exception of certain cases that will be mentioned in the following
25760  list:
25761 \end_layout
25762
25763 \begin_layout Description
25764 -
25765 \begin_inset ERT
25766 status collapsed
25767
25768 \begin_layout Standard
25769
25770
25771 \backslash
25772 /
25773 \end_layout
25774
25775 \end_inset
25776
25777 -callee-saves
25778 \begin_inset LatexCommand index
25779 name "PIC16!Options!-\\/-callee-saves"
25780
25781 \end_inset
25782
25783  See -
25784 \begin_inset ERT
25785 status collapsed
25786
25787 \begin_layout Standard
25788
25789
25790 \backslash
25791 /
25792 \end_layout
25793
25794 \end_inset
25795
25796 -all-callee-saves
25797 \end_layout
25798
25799 \begin_layout Description
25800 -
25801 \begin_inset ERT
25802 status collapsed
25803
25804 \begin_layout Standard
25805
25806
25807 \backslash
25808 /
25809 \end_layout
25810
25811 \end_inset
25812
25813 -fommit-frame-pointer
25814 \begin_inset LatexCommand index
25815 name "PIC16!Options!-\\/-fommit-frame-pointer"
25816
25817 \end_inset
25818
25819  Frame pointer will be omitted when the function uses no local variables.
25820 \end_layout
25821
25822 \begin_layout Subsection
25823 Port Specific Options
25824 \begin_inset LatexCommand index
25825 name "Options PIC16"
25826
25827 \end_inset
25828
25829
25830 \end_layout
25831
25832 \begin_layout Standard
25833 The port specific options appear after the global options in the sdcc -
25834 \begin_inset ERT
25835 status collapsed
25836
25837 \begin_layout Standard
25838
25839
25840 \backslash
25841 /
25842 \end_layout
25843
25844 \end_inset
25845
25846 -help output.
25847 \end_layout
25848
25849 \begin_layout Subsubsection
25850 Code Generation Options
25851 \end_layout
25852
25853 \begin_layout Standard
25854 These options influence the generated assembler code.
25855 \end_layout
25856
25857 \begin_layout Description
25858 -
25859 \begin_inset ERT
25860 status collapsed
25861
25862 \begin_layout Standard
25863
25864
25865 \backslash
25866 /
25867 \end_layout
25868
25869 \end_inset
25870
25871 -pstack-model=[model] Used in conjunction with the command above.
25872  Defines the stack model to be used, valid stack models are:
25873 \end_layout
25874
25875 \begin_deeper
25876 \begin_layout List
25877 \labelwidthstring 00.00.0000
25878
25879 \emph on
25880 small
25881 \emph default
25882  Selects small stack model.
25883  8 bit stack and frame pointers.
25884  Supports 256 bytes stack size.
25885 \end_layout
25886
25887 \begin_layout List
25888 \labelwidthstring 00.00.0000
25889
25890 \emph on
25891 large
25892 \emph default
25893  Selects large stack model.
25894  16 bit stack and frame pointers.
25895  Supports 65536 bytes stack size.
25896 \end_layout
25897
25898 \end_deeper
25899 \begin_layout Description
25900 -
25901 \begin_inset ERT
25902 status collapsed
25903
25904 \begin_layout Standard
25905
25906
25907 \backslash
25908 /
25909 \end_layout
25910
25911 \end_inset
25912
25913 -pno-banksel Do not generate BANKSEL assembler directives.
25914 \end_layout
25915
25916 \begin_layout Description
25917 -
25918 \begin_inset ERT
25919 status collapsed
25920
25921 \begin_layout Standard
25922
25923
25924 \backslash
25925 /
25926 \end_layout
25927
25928 \end_inset
25929
25930 -extended Enable extended instruction set/literal offset addressing mode.
25931  Use with care!
25932 \end_layout
25933
25934 \begin_layout Subsubsection
25935 Optimization Options
25936 \end_layout
25937
25938 \begin_layout Description
25939 -
25940 \begin_inset ERT
25941 status collapsed
25942
25943 \begin_layout Standard
25944
25945
25946 \backslash
25947 /
25948 \end_layout
25949
25950 \end_inset
25951
25952 -obanksel=n Set optimization level for inserting BANKSELs.
25953 \newline
25954
25955 \end_layout
25956
25957 \begin_deeper
25958 \begin_layout List
25959 \labelwidthstring 00.00.0000
25960 0 no optimization
25961 \end_layout
25962
25963 \begin_layout List
25964 \labelwidthstring 00.00.0000
25965 1 checks previous used register and if it is the same then does not emit
25966  BANKSEL, accounts only for labels.
25967 \end_layout
25968
25969 \begin_layout List
25970 \labelwidthstring 00.00.0000
25971 2 tries to check the location of (even different) symbols and removes BANKSELs
25972  if they are in the same bank.
25973  
25974 \newline
25975
25976 \emph on
25977 Important: There might be problems if the linker script has data sections
25978  across bank borders!
25979 \end_layout
25980
25981 \end_deeper
25982 \begin_layout Description
25983 -
25984 \begin_inset ERT
25985 status collapsed
25986
25987 \begin_layout Standard
25988
25989
25990 \backslash
25991 /
25992 \end_layout
25993
25994 \end_inset
25995
25996 -denable-peeps Force the usage of peepholes.
25997  Use with care.
25998 \end_layout
25999
26000 \begin_layout Description
26001 -
26002 \begin_inset ERT
26003 status collapsed
26004
26005 \begin_layout Standard
26006
26007
26008 \backslash
26009 /
26010 \end_layout
26011
26012 \end_inset
26013
26014 -no-optimize-goto Do not use (conditional) BRA instead of GOTO.
26015 \end_layout
26016
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 -optimize-cmp Try to optimize some compares.
26032 \end_layout
26033
26034 \begin_layout Description
26035 -
26036 \begin_inset ERT
26037 status collapsed
26038
26039 \begin_layout Standard
26040
26041
26042 \backslash
26043 /
26044 \end_layout
26045
26046 \end_inset
26047
26048 -optimize-df Analyze the dataflow of the generated code and improve it.
26049 \end_layout
26050
26051 \begin_layout Subsubsection
26052 Assembling Options
26053 \end_layout
26054
26055 \begin_layout Description
26056 -
26057 \begin_inset ERT
26058 status collapsed
26059
26060 \begin_layout Standard
26061
26062
26063 \backslash
26064 /
26065 \end_layout
26066
26067 \end_inset
26068
26069 -asm= Sets the full path and name of an external assembler to call.
26070 \end_layout
26071
26072 \begin_layout Description
26073 -
26074 \begin_inset ERT
26075 status collapsed
26076
26077 \begin_layout Standard
26078
26079
26080 \backslash
26081 /
26082 \end_layout
26083
26084 \end_inset
26085
26086 -mplab-comp MPLAB
26087 \begin_inset LatexCommand index
26088 name "PIC16!MPLAB"
26089
26090 \end_inset
26091
26092  compatibility option.
26093  Currently only suppresses special gpasm directives.
26094 \end_layout
26095
26096 \begin_layout Subsubsection
26097 Linking Options
26098 \end_layout
26099
26100 \begin_layout Description
26101 -
26102 \begin_inset ERT
26103 status collapsed
26104
26105 \begin_layout Standard
26106
26107
26108 \backslash
26109 /
26110 \end_layout
26111
26112 \end_inset
26113
26114 -link= Sets the full path and name of an external linker to call.
26115 \end_layout
26116
26117 \begin_layout Description
26118 -
26119 \begin_inset ERT
26120 status collapsed
26121
26122 \begin_layout Standard
26123
26124
26125 \backslash
26126 /
26127 \end_layout
26128
26129 \end_inset
26130
26131 -preplace-udata-with=[kword] Replaces the default udata keyword for allocating
26132  unitialized data variables with [kword].
26133  Valid keywords are: "udata_acs", "udata_shr", "udata_ovr".
26134 \end_layout
26135
26136 \begin_layout Description
26137 -
26138 \begin_inset ERT
26139 status collapsed
26140
26141 \begin_layout Standard
26142
26143
26144 \backslash
26145 /
26146 \end_layout
26147
26148 \end_inset
26149
26150 -ivt-loc=n Place the interrupt vector table at address 
26151 \emph on
26152 n
26153 \emph default
26154 .
26155  Useful for bootloaders.
26156 \end_layout
26157
26158 \begin_layout Description
26159 -
26160 \begin_inset ERT
26161 status collapsed
26162
26163 \begin_layout Standard
26164
26165
26166 \backslash
26167 /
26168 \end_layout
26169
26170 \end_inset
26171
26172 -nodefaultlibs Do not link default libraries when linking.
26173 \end_layout
26174
26175 \begin_layout Description
26176 -
26177 \begin_inset ERT
26178 status collapsed
26179
26180 \begin_layout Standard
26181
26182
26183 \backslash
26184 /
26185 \end_layout
26186
26187 \end_inset
26188
26189 -use-crt= Use a custom run-time module instead of the defaults.
26190 \end_layout
26191
26192 \begin_layout Description
26193 -
26194 \begin_inset ERT
26195 status collapsed
26196
26197 \begin_layout Standard
26198
26199
26200 \backslash
26201 /
26202 \end_layout
26203
26204 \end_inset
26205
26206 -no-crt Don't link the default run-time modules
26207 \end_layout
26208
26209 \begin_layout Subsubsection
26210 Debugging Options
26211 \end_layout
26212
26213 \begin_layout Standard
26214 Debugging options enable extra debugging information in the output files.
26215 \end_layout
26216
26217 \begin_layout Description
26218 -
26219 \begin_inset ERT
26220 status collapsed
26221
26222 \begin_layout Standard
26223
26224
26225 \backslash
26226 /
26227 \end_layout
26228
26229 \end_inset
26230
26231 -debug-xtra Similar to -
26232 \begin_inset ERT
26233 status collapsed
26234
26235 \begin_layout Standard
26236
26237
26238 \backslash
26239 /
26240 \end_layout
26241
26242 \end_inset
26243
26244 -debug
26245 \begin_inset LatexCommand index
26246 name "-\\/-debug"
26247
26248 \end_inset
26249
26250 , but dumps more information.
26251 \end_layout
26252
26253 \begin_layout Description
26254 -
26255 \begin_inset ERT
26256 status collapsed
26257
26258 \begin_layout Standard
26259
26260
26261 \backslash
26262 /
26263 \end_layout
26264
26265 \end_inset
26266
26267 -debug-ralloc Force register allocator to dump <source>.d file with debugging
26268  information.
26269  <source> is the name of the file being compiled.
26270 \end_layout
26271
26272 \begin_layout Description
26273 -
26274 \begin_inset ERT
26275 status collapsed
26276
26277 \begin_layout Standard
26278
26279
26280 \backslash
26281 /
26282 \end_layout
26283
26284 \end_inset
26285
26286 -pcode-verbose Enable pcode debugging information in translation.
26287 \end_layout
26288
26289 \begin_layout Description
26290 -
26291 \begin_inset ERT
26292 status collapsed
26293
26294 \begin_layout Standard
26295
26296
26297 \backslash
26298 /
26299 \end_layout
26300
26301 \end_inset
26302
26303 -calltree Dump call tree in .calltree file.
26304 \end_layout
26305
26306 \begin_layout Description
26307 -
26308 \begin_inset ERT
26309 status collapsed
26310
26311 \begin_layout Standard
26312
26313
26314 \backslash
26315 /
26316 \end_layout
26317
26318 \end_inset
26319
26320 -gstack Trace push/pops for stack pointer overflow.
26321 \end_layout
26322
26323 \begin_layout Subsection
26324 Environment Variables
26325 \end_layout
26326
26327 \begin_layout Standard
26328 There is a number of environmental variables that can be used when running
26329  SDCC to enable certain optimizations or force a specific program behaviour.
26330  these variables are primarily for debugging purposes so they can be enabled/dis
26331 abled at will.
26332 \end_layout
26333
26334 \begin_layout Standard
26335 Currently there is only two such variables available:
26336 \end_layout
26337
26338 \begin_layout Description
26339 OPTIMIZE_BITFIELD_POINTER_GET When this variable exists, reading of structure
26340  bitfields is optimized by directly loading FSR0 with the address of the
26341  bitfield structure.
26342  Normally SDCC will cast the bitfield structure to a bitfield pointer and
26343  then load FSR0.
26344  This step saves data ram and code space for functions that make heavy use
26345  of bitfields.
26346  (i.e., 80 bytes of code space are saved when compiling malloc.c with this
26347  option).
26348  
26349 \end_layout
26350
26351 \begin_layout Description
26352 NO_REG_OPT Do not perform pCode registers optimization.
26353  This should be used for debugging purposes.
26354  If bugs in the pcode optimizer are found, users can benefit from temporarily
26355  disabling the optimizer until the bug is fixed.
26356 \end_layout
26357
26358 \begin_layout Subsection
26359 Preprocessor Macros
26360 \end_layout
26361
26362 \begin_layout Standard
26363 PIC16
26364 \begin_inset LatexCommand index
26365 name "PIC16"
26366
26367 \end_inset
26368
26369  port defines the following preprocessor macros while translating a source.
26370 \end_layout
26371
26372 \begin_layout Standard
26373 \align center
26374 \begin_inset Tabular
26375 <lyxtabular version="3" rows="6" columns="2">
26376 <features>
26377 <column alignment="center" valignment="top" leftline="true" width="0">
26378 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26379 <row topline="true" bottomline="true">
26380 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26381 \begin_inset Text
26382
26383 \begin_layout Standard
26384 Macro
26385 \end_layout
26386
26387 \end_inset
26388 </cell>
26389 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26390 \begin_inset Text
26391
26392 \begin_layout Standard
26393 Description
26394 \end_layout
26395
26396 \end_inset
26397 </cell>
26398 </row>
26399 <row topline="true">
26400 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26401 \begin_inset Text
26402
26403 \begin_layout Standard
26404 SDCC_pic16
26405 \end_layout
26406
26407 \end_inset
26408 </cell>
26409 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26410 \begin_inset Text
26411
26412 \begin_layout Standard
26413 Port identification
26414 \end_layout
26415
26416 \end_inset
26417 </cell>
26418 </row>
26419 <row topline="true">
26420 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26421 \begin_inset Text
26422
26423 \begin_layout Standard
26424 _
26425 \begin_inset ERT
26426 status collapsed
26427
26428 \begin_layout Standard
26429
26430
26431 \backslash
26432 /
26433 \end_layout
26434
26435 \end_inset
26436
26437 _pic16
26438 \end_layout
26439
26440 \end_inset
26441 </cell>
26442 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26443 \begin_inset Text
26444
26445 \begin_layout Standard
26446 Port identification (same as above)
26447 \end_layout
26448
26449 \end_inset
26450 </cell>
26451 </row>
26452 <row topline="true">
26453 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26454 \begin_inset Text
26455
26456 \begin_layout Standard
26457 pic18fxxxx
26458 \end_layout
26459
26460 \end_inset
26461 </cell>
26462 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26463 \begin_inset Text
26464
26465 \begin_layout Standard
26466 MCU Identification.
26467  
26468 \emph on
26469 xxxx
26470 \emph default
26471  is the microcontrol identification number, i.e.
26472  452, 6620, etc
26473 \end_layout
26474
26475 \end_inset
26476 </cell>
26477 </row>
26478 <row topline="true">
26479 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26480 \begin_inset Text
26481
26482 \begin_layout Standard
26483 _
26484 \begin_inset ERT
26485 status collapsed
26486
26487 \begin_layout Standard
26488
26489
26490 \backslash
26491 /
26492 \end_layout
26493
26494 \end_inset
26495
26496 _18Fxxxx
26497 \end_layout
26498
26499 \end_inset
26500 </cell>
26501 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26502 \begin_inset Text
26503
26504 \begin_layout Standard
26505 MCU Identification (same as above)
26506 \end_layout
26507
26508 \end_inset
26509 </cell>
26510 </row>
26511 <row topline="true" bottomline="true">
26512 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26513 \begin_inset Text
26514
26515 \begin_layout Standard
26516 STACK_MODEL_nnn
26517 \end_layout
26518
26519 \end_inset
26520 </cell>
26521 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26522 \begin_inset Text
26523
26524 \begin_layout Standard
26525 nnn = SMALL or LARGE respectively according to the stack model used
26526 \end_layout
26527
26528 \end_inset
26529 </cell>
26530 </row>
26531 </lyxtabular>
26532
26533 \end_inset
26534
26535
26536 \end_layout
26537
26538 \begin_layout Standard
26539 \noindent
26540 In addition the following macros are defined when calling assembler:
26541 \end_layout
26542
26543 \begin_layout Standard
26544 \align center
26545 \begin_inset Tabular
26546 <lyxtabular version="3" rows="4" columns="2">
26547 <features>
26548 <column alignment="center" valignment="top" leftline="true" width="0">
26549 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26550 <row topline="true" bottomline="true">
26551 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26552 \begin_inset Text
26553
26554 \begin_layout Standard
26555 Macro
26556 \end_layout
26557
26558 \end_inset
26559 </cell>
26560 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26561 \begin_inset Text
26562
26563 \begin_layout Standard
26564 Description
26565 \end_layout
26566
26567 \end_inset
26568 </cell>
26569 </row>
26570 <row topline="true">
26571 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26572 \begin_inset Text
26573
26574 \begin_layout Standard
26575 __18Fxxxx
26576 \end_layout
26577
26578 \end_inset
26579 </cell>
26580 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26581 \begin_inset Text
26582
26583 \begin_layout Standard
26584 MCU Identification.
26585  
26586 \emph on
26587 xxxx
26588 \emph default
26589  is the microcontrol identification number, i.e.
26590  452, 6620, etc
26591 \end_layout
26592
26593 \end_inset
26594 </cell>
26595 </row>
26596 <row topline="true">
26597 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26598 \begin_inset Text
26599
26600 \begin_layout Standard
26601 SDCC_MODEL_nnn
26602 \end_layout
26603
26604 \end_inset
26605 </cell>
26606 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26607 \begin_inset Text
26608
26609 \begin_layout Standard
26610 nnn = SMALL or LARGE respectively according to the memory model used for
26611  SDCC
26612 \end_layout
26613
26614 \end_inset
26615 </cell>
26616 </row>
26617 <row topline="true" bottomline="true">
26618 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26619 \begin_inset Text
26620
26621 \begin_layout Standard
26622 STACK_MODEL_nnn
26623 \end_layout
26624
26625 \end_inset
26626 </cell>
26627 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26628 \begin_inset Text
26629
26630 \begin_layout Standard
26631 nnn = SMALL or LARGE respectively according to the stack model used
26632 \end_layout
26633
26634 \end_inset
26635 </cell>
26636 </row>
26637 </lyxtabular>
26638
26639 \end_inset
26640
26641
26642 \end_layout
26643
26644 \begin_layout Subsection
26645 Directories
26646 \end_layout
26647
26648 \begin_layout Standard
26649 PIC16
26650 \begin_inset LatexCommand index
26651 name "PIC16"
26652
26653 \end_inset
26654
26655  port uses the following directories for searching header files and libraries.
26656 \end_layout
26657
26658 \begin_layout Standard
26659 \align center
26660 \begin_inset Tabular
26661 <lyxtabular version="3" rows="3" columns="4">
26662 <features>
26663 <column alignment="center" valignment="top" leftline="true" width="0">
26664 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26665 <column alignment="center" valignment="top" width="0">
26666 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26667 <row topline="true" bottomline="true">
26668 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26669 \begin_inset Text
26670
26671 \begin_layout Standard
26672 Directory
26673 \end_layout
26674
26675 \end_inset
26676 </cell>
26677 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26678 \begin_inset Text
26679
26680 \begin_layout Standard
26681 Description
26682 \end_layout
26683
26684 \end_inset
26685 </cell>
26686 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26687 \begin_inset Text
26688
26689 \begin_layout Standard
26690 Target
26691 \end_layout
26692
26693 \end_inset
26694 </cell>
26695 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26696 \begin_inset Text
26697
26698 \begin_layout Standard
26699 Command prefix
26700 \end_layout
26701
26702 \end_inset
26703 </cell>
26704 </row>
26705 <row topline="true">
26706 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26707 \begin_inset Text
26708
26709 \begin_layout Standard
26710 PREFIX/sdcc/include/pic16
26711 \end_layout
26712
26713 \end_inset
26714 </cell>
26715 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26716 \begin_inset Text
26717
26718 \begin_layout Standard
26719 PIC16 specific headers
26720 \end_layout
26721
26722 \end_inset
26723 </cell>
26724 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26725 \begin_inset Text
26726
26727 \begin_layout Standard
26728 Compiler
26729 \end_layout
26730
26731 \end_inset
26732 </cell>
26733 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26734 \begin_inset Text
26735
26736 \begin_layout Standard
26737 -I
26738 \end_layout
26739
26740 \end_inset
26741 </cell>
26742 </row>
26743 <row topline="true" bottomline="true">
26744 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26745 \begin_inset Text
26746
26747 \begin_layout Standard
26748 PREFIX/sdcc/lib/pic16
26749 \end_layout
26750
26751 \end_inset
26752 </cell>
26753 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26754 \begin_inset Text
26755
26756 \begin_layout Standard
26757 PIC16 specific libraries
26758 \end_layout
26759
26760 \end_inset
26761 </cell>
26762 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26763 \begin_inset Text
26764
26765 \begin_layout Standard
26766 Linker
26767 \end_layout
26768
26769 \end_inset
26770 </cell>
26771 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26772 \begin_inset Text
26773
26774 \begin_layout Standard
26775 -L
26776 \end_layout
26777
26778 \end_inset
26779 </cell>
26780 </row>
26781 </lyxtabular>
26782
26783 \end_inset
26784
26785
26786 \end_layout
26787
26788 \begin_layout Subsection
26789 Pragmas
26790 \begin_inset LatexCommand label
26791 name "sub:PIC16_Pragmas"
26792
26793 \end_inset
26794
26795
26796 \end_layout
26797
26798 \begin_layout Standard
26799 The PIC16
26800 \begin_inset LatexCommand index
26801 name "PIC16"
26802
26803 \end_inset
26804
26805  port currently supports the following pragmas:
26806 \end_layout
26807
26808 \begin_layout Description
26809 stack
26810 \begin_inset LatexCommand index
26811 name "PIC16!Pragmas!\\#pragma stack"
26812
26813 \end_inset
26814
26815  This forces the code generator to initialize the stack & frame pointers
26816  at a specific address.
26817  This is an ad hoc solution for cases where no STACK directive is available
26818  in the linker script or gplink is not instructed to create a stack section.
26819 \newline
26820 The
26821  stack pragma should be used only once in a project.
26822  Multiple pragmas may result in indeterminate behaviour of the program.
26823 \begin_inset Foot
26824 status open
26825
26826 \begin_layout Standard
26827 The old format (ie.
26828  #pragma stack 0x5ff) is deprecated and will cause the stack pointer to
26829  cross page boundaries (or even exceed the available data RAM) and crash
26830  the program.
26831  Make sure that stack does not cross page boundaries when using the SMALL
26832  stack model.
26833 \end_layout
26834
26835 \end_inset
26836
26837
26838 \newline
26839 The format is as follows:
26840 \newline
26841
26842 \end_layout
26843
26844 \begin_layout LyX-Code
26845 #pragma stack bottom_address [stack_size]
26846 \newline
26847
26848 \end_layout
26849
26850 \begin_layout Standard
26851
26852 \emph on
26853 bottom_address
26854 \emph default
26855  is the lower bound of the stack section.
26856  The stack pointer initially will point at address (bottom_address+stack_size-1).
26857 \end_layout
26858
26859 \begin_layout LyX-Code
26860 Example:
26861 \end_layout
26862
26863 \begin_layout LyX-Code
26864
26865 \end_layout
26866
26867 \begin_layout LyX-Code
26868 /* initializes stack of 100 bytes at RAM address 0x200 */
26869 \end_layout
26870
26871 \begin_layout LyX-Code
26872 #pragma stack 0x200 100
26873 \end_layout
26874
26875 \begin_layout Standard
26876 If the stack_size field is omitted then a stack is created with the default
26877  size of 64.
26878  This size might be enough for most programs, but its not enough for operations
26879  with deep function nesting or excessive stack usage.
26880 \end_layout
26881
26882 \begin_layout Description
26883 code
26884 \begin_inset LatexCommand index
26885 name "PIC16!Pragmas!\\#pragma code"
26886
26887 \end_inset
26888
26889  Force a function to a static FLASH address.
26890 \end_layout
26891
26892 \begin_layout LyX-Code
26893 Example:
26894 \end_layout
26895
26896 \begin_layout LyX-Code
26897
26898 \end_layout
26899
26900 \begin_layout LyX-Code
26901 /* place function test_func at 0x4000 */
26902 \end_layout
26903
26904 \begin_layout LyX-Code
26905 #pragma code test_func 0x4000
26906 \end_layout
26907
26908 \begin_layout LyX-Code
26909
26910 \end_layout
26911
26912 \begin_layout Description
26913 library instructs the linker to use a library module.
26914 \newline
26915 Usage:
26916 \end_layout
26917
26918 \begin_layout LyX-Code
26919 #pragma library module_name
26920 \end_layout
26921
26922 \begin_layout Standard
26923
26924 \emph on
26925 module_name
26926 \emph default
26927  can be any library or object file (including its path).
26928  Note that there are four reserved keywords which have special meaning.
26929  These are:
26930 \end_layout
26931
26932 \begin_layout Standard
26933 \align center
26934 \begin_inset Tabular
26935 <lyxtabular version="3" rows="6" columns="3">
26936 <features>
26937 <column alignment="center" valignment="top" leftline="true" width="0">
26938 <column alignment="block" valignment="top" leftline="true" width="20page%">
26939 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
26940 <row topline="true" bottomline="true">
26941 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26942 \begin_inset Text
26943
26944 \begin_layout Standard
26945 Keyword
26946 \end_layout
26947
26948 \end_inset
26949 </cell>
26950 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26951 \begin_inset Text
26952
26953 \begin_layout Standard
26954 Description
26955 \end_layout
26956
26957 \end_inset
26958 </cell>
26959 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26960 \begin_inset Text
26961
26962 \begin_layout Standard
26963 Module to link
26964 \end_layout
26965
26966 \end_inset
26967 </cell>
26968 </row>
26969 <row topline="true">
26970 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26971 \begin_inset Text
26972
26973 \begin_layout Standard
26974
26975 \series bold
26976 ignore
26977 \end_layout
26978
26979 \end_inset
26980 </cell>
26981 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26982 \begin_inset Text
26983
26984 \begin_layout Standard
26985 ignore all library pragmas
26986 \end_layout
26987
26988 \end_inset
26989 </cell>
26990 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26991 \begin_inset Text
26992
26993 \begin_layout Standard
26994
26995 \emph on
26996 (none)
26997 \end_layout
26998
26999 \end_inset
27000 </cell>
27001 </row>
27002 <row topline="true">
27003 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27004 \begin_inset Text
27005
27006 \begin_layout Standard
27007
27008 \series bold
27009 c
27010 \end_layout
27011
27012 \end_inset
27013 </cell>
27014 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27015 \begin_inset Text
27016
27017 \begin_layout Standard
27018 link the C library
27019 \end_layout
27020
27021 \end_inset
27022 </cell>
27023 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27024 \begin_inset Text
27025
27026 \begin_layout Standard
27027
27028 \emph on
27029 libc18f
27030 \emph default
27031 .lib
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 math
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 Math libarary
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 libm18f
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 io
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 I/O library
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 libio18f*
27100 \emph default
27101 .lib
27102 \end_layout
27103
27104 \end_inset
27105 </cell>
27106 </row>
27107 <row topline="true" bottomline="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 debug
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 debug 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 libdebug
27135 \emph default
27136 .lib
27137 \end_layout
27138
27139 \end_inset
27140 </cell>
27141 </row>
27142 </lyxtabular>
27143
27144 \end_inset
27145
27146
27147 \newline
27148 * is the device number, i.e.
27149  452 for PIC18F452 MCU.
27150 \end_layout
27151
27152 \begin_layout Standard
27153 \noindent
27154 This feature allows for linking with specific libraries without having to
27155  explicit name them in the command line.
27156  Note that the 
27157 \noun on
27158 ignore
27159 \noun default
27160  keyword will reject all modules specified by the library pragma.
27161 \end_layout
27162
27163 \begin_layout Description
27164 udata The pragma udata instructs the compiler to emit code so that linker
27165  will place a variable at a specific memory bank.
27166 \end_layout
27167
27168 \begin_layout LyX-Code
27169 Example:
27170 \end_layout
27171
27172 \begin_layout LyX-Code
27173
27174 \end_layout
27175
27176 \begin_layout LyX-Code
27177 /* places variable foo at bank2 */
27178 \end_layout
27179
27180 \begin_layout LyX-Code
27181 #pragma udata bank2 foo
27182 \end_layout
27183
27184 \begin_layout LyX-Code
27185 char foo;
27186 \end_layout
27187
27188 \begin_layout Standard
27189 In order for this pragma to work extra SECTION directives should be added
27190  in the .lkr script.
27191  In the following example a sample .lkr file is shown:
27192 \end_layout
27193
27194 \begin_layout LyX-Code
27195
27196 \end_layout
27197
27198 \begin_layout LyX-Code
27199 // Sample linker script for the PIC18F452 processor
27200 \end_layout
27201
27202 \begin_layout LyX-Code
27203 LIBPATH .
27204 \end_layout
27205
27206 \begin_layout LyX-Code
27207 CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
27208 \end_layout
27209
27210 \begin_layout LyX-Code
27211 CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
27212 \end_layout
27213
27214 \begin_layout LyX-Code
27215 CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
27216 \end_layout
27217
27218 \begin_layout LyX-Code
27219 CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
27220 \end_layout
27221
27222 \begin_layout LyX-Code
27223 CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
27224 \end_layout
27225
27226 \begin_layout LyX-Code
27227 CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
27228 \end_layout
27229
27230 \begin_layout LyX-Code
27231 ACCESSBANK NAME=accessram  START=0x0            END=0x7F
27232 \end_layout
27233
27234 \begin_layout LyX-Code
27235
27236 \end_layout
27237
27238 \begin_layout LyX-Code
27239 DATABANK   NAME=gpr0       START=0x80           END=0xFF
27240 \end_layout
27241
27242 \begin_layout LyX-Code
27243 DATABANK   NAME=gpr1       START=0x100          END=0x1FF
27244 \end_layout
27245
27246 \begin_layout LyX-Code
27247 DATABANK   NAME=gpr2       START=0x200          END=0x2FF
27248 \end_layout
27249
27250 \begin_layout LyX-Code
27251 DATABANK   NAME=gpr3       START=0x300          END=0x3FF
27252 \end_layout
27253
27254 \begin_layout LyX-Code
27255 DATABANK   NAME=gpr4       START=0x400          END=0x4FF
27256 \end_layout
27257
27258 \begin_layout LyX-Code
27259 DATABANK   NAME=gpr5       START=0x500          END=0x5FF
27260 \end_layout
27261
27262 \begin_layout LyX-Code
27263 ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED
27264 \end_layout
27265
27266 \begin_layout LyX-Code
27267
27268 \end_layout
27269
27270 \begin_layout LyX-Code
27271 SECTION    NAME=CONFIG     ROM=config
27272 \end_layout
27273
27274 \begin_layout LyX-Code
27275
27276 \end_layout
27277
27278 \begin_layout LyX-Code
27279 SECTION    NAME=bank0      RAM=gpr0       # these SECTION directives
27280 \end_layout
27281
27282 \begin_layout LyX-Code
27283 SECTION    NAME=bank1      RAM=gpr1       # should be added to link
27284 \end_layout
27285
27286 \begin_layout LyX-Code
27287 SECTION    NAME=bank2      RAM=gpr2       # section name 'bank?' with
27288 \end_layout
27289
27290 \begin_layout LyX-Code
27291 SECTION    NAME=bank3      RAM=gpr3       # a specific DATABANK name
27292 \end_layout
27293
27294 \begin_layout LyX-Code
27295 SECTION    NAME=bank4      RAM=gpr4
27296 \end_layout
27297
27298 \begin_layout LyX-Code
27299 SECTION    NAME=bank5      RAM=gpr5
27300 \end_layout
27301
27302 \begin_layout Standard
27303 The linker will recognise the section name set in the pragma statement and
27304  will position the variable at the memory bank set with the RAM field at
27305  the SECTION line in the linker script file.
27306 \end_layout
27307
27308 \begin_layout Subsection
27309 Header Files
27310 \begin_inset LatexCommand label
27311 name "sub:PIC16_Header-Files"
27312
27313 \end_inset
27314
27315
27316 \end_layout
27317
27318 \begin_layout Standard
27319 There is one main header file
27320 \begin_inset LatexCommand index
27321 name "PIC16!Header files"
27322
27323 \end_inset
27324
27325  that can be included to the source files using the pic16
27326 \begin_inset LatexCommand index
27327 name "PIC16"
27328
27329 \end_inset
27330
27331  port.
27332  That file is the 
27333 \series bold
27334 pic18fregs.h
27335 \series default
27336 .
27337  This header file contains the definitions for the processor special registers,
27338  so it is necessary if the source accesses them.
27339  It can be included by adding the following line in the beginning of the
27340  file:
27341 \end_layout
27342
27343 \begin_layout LyX-Code
27344 #include <pic18fregs.h>
27345 \end_layout
27346
27347 \begin_layout Standard
27348 The specific microcontroller is selected within the pic18fregs.h automatically,
27349  so the same source can be used with a variety of devices.
27350 \end_layout
27351
27352 \begin_layout Subsection
27353 Libraries
27354 \begin_inset LatexCommand label
27355 name "sub:pic16Libraries"
27356
27357 \end_inset
27358
27359
27360 \end_layout
27361
27362 \begin_layout Standard
27363 The libraries
27364 \begin_inset LatexCommand index
27365 name "PIC16!Libraries"
27366
27367 \end_inset
27368
27369  that PIC16
27370 \begin_inset LatexCommand index
27371 name "PIC16"
27372
27373 \end_inset
27374
27375  port depends on are the microcontroller device libraries which contain
27376  the symbol definitions for the microcontroller special function registers.
27377  These libraries have the format pic18fxxxx.lib, where 
27378 \emph on
27379 xxxx
27380 \emph default
27381  is the microcontroller identification number.
27382  The specific library is selected automatically by the compiler at link
27383  stage according to the selected device.
27384 \end_layout
27385
27386 \begin_layout Standard
27387 \noindent
27388 Libraries are created with gplib which is part of the gputils package 
27389 \begin_inset LatexCommand url
27390 target "http://sourceforge.net/projects/gputils"
27391
27392 \end_inset
27393
27394 .
27395 \end_layout
27396
27397 \begin_layout Subsubsection*
27398 Building the libraries
27399 \end_layout
27400
27401 \begin_layout Standard
27402 Before using SDCC/pic16 there are some libraries that need to be compiled.
27403  This process is done automatically if gputils are found at SDCC's compile
27404  time.
27405  Should you require to rebuild the pic16 libraries manually (e.g.
27406  in order to enable output of float values
27407 \begin_inset LatexCommand index
27408 name "Floating point support"
27409
27410 \end_inset
27411
27412  via 
27413 \family typewriter
27414 printf()
27415 \family default
27416 , see below), these are the steps required to do so under Linux or Mac OS
27417  X (cygwin might work as well, but is untested):
27418 \end_layout
27419
27420 \begin_layout LyX-Code
27421 cd device/lib/pic16
27422 \end_layout
27423
27424 \begin_layout LyX-Code
27425 ./configure.gnu
27426 \end_layout
27427
27428 \begin_layout LyX-Code
27429 cd ..
27430 \end_layout
27431
27432 \begin_layout LyX-Code
27433 make model-pic16
27434 \end_layout
27435
27436 \begin_layout LyX-Code
27437 su -c 'make install'     # install the libraries, you need the root password
27438 \end_layout
27439
27440 \begin_layout LyX-Code
27441 cd ../..
27442 \end_layout
27443
27444 \begin_layout Standard
27445 If you need to install the headers too, do:
27446 \end_layout
27447
27448 \begin_layout LyX-Code
27449 cd device/include
27450 \end_layout
27451
27452 \begin_layout LyX-Code
27453 su -c 'make install'     # install the headers, you need the root password
27454 \end_layout
27455
27456 \begin_layout Subsubsection*
27457 Output of float values via printf()
27458 \end_layout
27459
27460 \begin_layout Standard
27461 The library is normally built without support for displaying float values,
27462  only <NO FLOAT>
27463 \begin_inset LatexCommand index
27464 name "<NO FLOAT>"
27465
27466 \end_inset
27467
27468
27469 \begin_inset LatexCommand index
27470 name "printf floating point support"
27471
27472 \end_inset
27473
27474  will appear instead of the value.
27475  To change this, rebuild the library as stated above, but call 
27476 \family typewriter
27477 ./configure.gnu --enable-floats 
27478 \family default
27479 instead of just 
27480 \family typewriter
27481 ./configure.gnu
27482 \family default
27483 .
27484  Also make sure that at least 
27485 \family typewriter
27486 libc/stdio/vfprintf.c
27487 \family default
27488  is actually recompiled, e.g.
27489  by 
27490 \family typewriter
27491 touch
27492 \family default
27493 ing it after the 
27494 \family typewriter
27495 configure
27496 \family default
27497  run or deleting its 
27498 \family typewriter
27499 .o
27500 \family default
27501  file.
27502 \end_layout
27503
27504 \begin_layout Standard
27505 The more common appraoch of compiling 
27506 \family typewriter
27507 vfprintf.c
27508 \family default
27509  manually with 
27510 \family typewriter
27511 -DUSE_FLOATS=1
27512 \family default
27513  should also work, but is untested.
27514 \end_layout
27515
27516 \begin_layout Subsection
27517 Adding New Devices to the Port
27518 \end_layout
27519
27520 \begin_layout Standard
27521 Adding support for a new 16
27522 \begin_inset ERT
27523 status collapsed
27524
27525 \begin_layout Standard
27526
27527
27528 \backslash
27529 ,
27530 \end_layout
27531
27532 \end_inset
27533
27534 bit PIC MCU requires the following steps:
27535 \end_layout
27536
27537 \begin_layout Enumerate
27538 Create picDEVICE.c and picDEVICE.h from pDEVICE.inc using
27539 \newline
27540
27541 \family typewriter
27542 perl /path/to/sdcc/support/scripts/inc2h-pic16.pl /path/to/gputils/header/pDEVICE.
27543 inc
27544 \end_layout
27545
27546 \begin_layout Enumerate
27547
27548 \family typewriter
27549 mv picDEVICE.h /path/to/sdcc/device/include/pic16
27550 \end_layout
27551
27552 \begin_layout Enumerate
27553
27554 \family typewriter
27555 mv picDEVICE.c /path/to/sdcc/device/lib/pic16/libdev
27556 \end_layout
27557
27558 \begin_layout Enumerate
27559 Add DEVICE to 
27560 \family typewriter
27561 /path/to/sdcc/device/lib/pic16/pics.all
27562 \family default
27563
27564 \newline
27565 Note: No 18f prefix here!
27566 \end_layout
27567
27568 \begin_layout Enumerate
27569 Edit 
27570 \family typewriter
27571 /path/to/sdcc/device/include/pic16/adc.h
27572 \newline
27573
27574 \family default
27575 Add the new devices to the correct ADC style class (depending on the number
27576  of ADC channels).
27577 \newline
27578 Do not touch 
27579 \family typewriter
27580 adc.h
27581 \family default
27582  if the device does not offer any ADC at all.
27583 \end_layout
27584
27585 \begin_layout Enumerate
27586 Edit 
27587 \family typewriter
27588 /path/to/sdcc/device/include/pic16/pic18fregs.h
27589 \family default
27590
27591 \newline
27592 The file format is self-explanatory, just add
27593 \newline
27594
27595 \family typewriter
27596 #elif defined(picDEVICE)
27597 \newline
27598 #
27599 \begin_inset ERT
27600 status collapsed
27601
27602 \begin_layout Standard
27603
27604
27605 \backslash
27606  
27607 \backslash
27608  
27609 \end_layout
27610
27611 \end_inset
27612
27613 include <picDEVICE.h>
27614 \family default
27615
27616 \newline
27617 at the right place (keep the file sorted, please).
27618 \end_layout
27619
27620 \begin_layout Enumerate
27621 Edit 
27622 \family typewriter
27623 /path/to/sdcc/device/include/pic16devices.txt
27624 \newline
27625
27626 \family default
27627 Copy and modify an existing entry or create a new one and insert it at the
27628  correct place (keep the file sorted, please).
27629 \end_layout
27630
27631 \begin_layout Enumerate
27632 Add the device to 
27633 \family typewriter
27634 /path/to/sdcc/device/lib/pic16/libdev/Makefile.am
27635 \family default
27636
27637 \newline
27638 Copy an existing entry and adjust the device name.
27639 \end_layout
27640
27641 \begin_layout Enumerate
27642 Add the device to 
27643 \family typewriter
27644 /path/to/sdcc/device/lib/pic16/libio/Makefile.am
27645 \family default
27646
27647 \newline
27648 Copy the record from the 18f2220 and adjust the device name.
27649 \newline
27650 If the new device
27651  does not offer ADC, I
27652 \begin_inset Formula $^{\text{2}}$
27653 \end_inset
27654
27655 C, and/or (E)USART functionality as assumed by the library, remove the lines
27656  with references to 
27657 \family typewriter
27658 adc/*.c
27659 \family default
27660
27661 \family typewriter
27662 usart/*.c
27663 \family default
27664 , or 
27665 \family typewriter
27666 usart/*.c
27667 \family default
27668 , respectively.
27669 \end_layout
27670
27671 \begin_layout Enumerate
27672 Update 
27673 \family typewriter
27674 libdev/Makefile.in
27675 \family default
27676  and 
27677 \family typewriter
27678 libio/Makefile.in
27679 \family default
27680  using
27681 \newline
27682
27683 \family typewriter
27684 ./bootstrap.sh
27685 \family default
27686
27687 \newline
27688 in 
27689 \family typewriter
27690 /path/to/sdcc/device/lib/pic16
27691 \family default
27692 .
27693 \end_layout
27694
27695 \begin_layout Enumerate
27696 Recompile the pic16 libraries as described in 
27697 \begin_inset LatexCommand ref
27698 reference "sub:pic16Libraries"
27699
27700 \end_inset
27701
27702 .
27703 \end_layout
27704
27705 \begin_layout Subsection
27706 Memory Models
27707 \end_layout
27708
27709 \begin_layout Standard
27710 The following memory models are supported by the PIC16 port:
27711 \end_layout
27712
27713 \begin_layout Itemize
27714 small model
27715 \end_layout
27716
27717 \begin_layout Itemize
27718 large model
27719 \end_layout
27720
27721 \begin_layout Standard
27722 Memory model affects the default size of pointers within the source.
27723  The sizes are shown in the next table:
27724 \end_layout
27725
27726 \begin_layout Standard
27727 \align center
27728 \begin_inset Tabular
27729 <lyxtabular version="3" rows="3" columns="3">
27730 <features>
27731 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27732 <column alignment="center" valignment="top" leftline="true" width="0">
27733 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27734 <row topline="true" bottomline="true">
27735 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27736 \begin_inset Text
27737
27738 \begin_layout Standard
27739 Pointer sizes according to memory model
27740 \end_layout
27741
27742 \end_inset
27743 </cell>
27744 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27745 \begin_inset Text
27746
27747 \begin_layout Standard
27748 small model
27749 \end_layout
27750
27751 \end_inset
27752 </cell>
27753 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27754 \begin_inset Text
27755
27756 \begin_layout Standard
27757 large model
27758 \end_layout
27759
27760 \end_inset
27761 </cell>
27762 </row>
27763 <row topline="true" bottomline="true">
27764 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27765 \begin_inset Text
27766
27767 \begin_layout Standard
27768 code pointers
27769 \end_layout
27770
27771 \end_inset
27772 </cell>
27773 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27774 \begin_inset Text
27775
27776 \begin_layout Standard
27777 16-bits
27778 \end_layout
27779
27780 \end_inset
27781 </cell>
27782 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27783 \begin_inset Text
27784
27785 \begin_layout Standard
27786 24-bits
27787 \end_layout
27788
27789 \end_inset
27790 </cell>
27791 </row>
27792 <row topline="true" bottomline="true">
27793 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27794 \begin_inset Text
27795
27796 \begin_layout Standard
27797 data pointers
27798 \end_layout
27799
27800 \end_inset
27801 </cell>
27802 <cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
27803 \begin_inset Text
27804
27805 \begin_layout Standard
27806 16-bits
27807 \end_layout
27808
27809 \end_inset
27810 </cell>
27811 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27812 \begin_inset Text
27813
27814 \begin_layout Standard
27815 16-bits
27816 \end_layout
27817
27818 \end_inset
27819 </cell>
27820 </row>
27821 </lyxtabular>
27822
27823 \end_inset
27824
27825
27826 \end_layout
27827
27828 \begin_layout Standard
27829 It is advisable that all sources within a project are compiled with the
27830  same memory model.
27831  If one wants to override the default memory model, this can be done by
27832  declaring a pointer as 
27833 \series bold
27834 far
27835 \series default
27836  or 
27837 \series bold
27838 near
27839 \series default
27840 .
27841  Far selects large memory model's pointers, while near selects small memory
27842  model's pointers.
27843 \end_layout
27844
27845 \begin_layout Standard
27846 The standard device libraries (see 
27847 \begin_inset LatexCommand ref
27848 reference "sub:PIC16_Header-Files"
27849
27850 \end_inset
27851
27852 ) contain no reference to pointers, so they can be used with both memory
27853  models.
27854 \end_layout
27855
27856 \begin_layout Subsection
27857 Stack
27858 \end_layout
27859
27860 \begin_layout Standard
27861 The stack
27862 \begin_inset LatexCommand index
27863 name "PIC16!stack"
27864
27865 \end_inset
27866
27867  implementation for the PIC16 port uses two indirect registers, FSR1 and
27868  FSR2.
27869 \end_layout
27870
27871 \begin_layout Description
27872 FSR1 is assigned as stack pointer
27873 \end_layout
27874
27875 \begin_layout Description
27876 FSR2 is assigned as frame pointer
27877 \end_layout
27878
27879 \begin_layout Standard
27880 The following stack models are supported by the PIC16 port
27881 \end_layout
27882
27883 \begin_layout Itemize
27884
27885 \noun on
27886 small
27887 \noun default
27888  model
27889 \end_layout
27890
27891 \begin_layout Itemize
27892
27893 \noun on
27894 large
27895 \noun default
27896  model
27897 \end_layout
27898
27899 \begin_layout Standard
27900
27901 \noun on
27902 Small
27903 \noun default
27904  model means that only the FSRxL byte is used to access stack and frame,
27905  while 
27906 \emph on
27907 \noun on
27908 large
27909 \emph default
27910 \noun default
27911  uses both FSRxL and FSRxH registers.
27912  The following table shows the stack/frame pointers sizes according to stack
27913  model and the maximum space they can address:
27914 \end_layout
27915
27916 \begin_layout Standard
27917 \align center
27918 \begin_inset Tabular
27919 <lyxtabular version="3" rows="3" columns="3">
27920 <features>
27921 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27922 <column alignment="center" valignment="top" leftline="true" width="0">
27923 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27924 <row topline="true" bottomline="true">
27925 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27926 \begin_inset Text
27927
27928 \begin_layout Standard
27929 Stack & Frame pointer sizes according to stack model
27930 \end_layout
27931
27932 \end_inset
27933 </cell>
27934 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27935 \begin_inset Text
27936
27937 \begin_layout Standard
27938 small
27939 \end_layout
27940
27941 \end_inset
27942 </cell>
27943 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27944 \begin_inset Text
27945
27946 \begin_layout Standard
27947 large
27948 \end_layout
27949
27950 \end_inset
27951 </cell>
27952 </row>
27953 <row topline="true">
27954 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27955 \begin_inset Text
27956
27957 \begin_layout Standard
27958 Stack pointer FSR1
27959 \end_layout
27960
27961 \end_inset
27962 </cell>
27963 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27964 \begin_inset Text
27965
27966 \begin_layout Standard
27967 8-bits
27968 \end_layout
27969
27970 \end_inset
27971 </cell>
27972 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27973 \begin_inset Text
27974
27975 \begin_layout Standard
27976 16-bits
27977 \end_layout
27978
27979 \end_inset
27980 </cell>
27981 </row>
27982 <row topline="true" bottomline="true">
27983 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27984 \begin_inset Text
27985
27986 \begin_layout Standard
27987 Frame pointer FSR2
27988 \end_layout
27989
27990 \end_inset
27991 </cell>
27992 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27993 \begin_inset Text
27994
27995 \begin_layout Standard
27996 8-bits
27997 \end_layout
27998
27999 \end_inset
28000 </cell>
28001 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28002 \begin_inset Text
28003
28004 \begin_layout Standard
28005 16-bits
28006 \end_layout
28007
28008 \end_inset
28009 </cell>
28010 </row>
28011 </lyxtabular>
28012
28013 \end_inset
28014
28015
28016 \end_layout
28017
28018 \begin_layout Standard
28019 \noindent
28020
28021 \noun on
28022 Large 
28023 \noun default
28024 stack model is currently not working properly throughout the code generator.
28025  So its use is not advised.
28026  Also there are some other points that need special care:
28027 \newline
28028
28029 \end_layout
28030
28031 \begin_layout Enumerate
28032 Do not create stack sections with size more than one physical bank (that
28033  is 256 bytes)
28034 \end_layout
28035
28036 \begin_layout Enumerate
28037 Stack sections should no cross physical bank limits (i.e.
28038  #pragma stack 0x50 0x100)
28039 \end_layout
28040
28041 \begin_layout Standard
28042 These limitations are caused by the fact that only FSRxL is modified when
28043  using SMALL stack model, so no more than 256 bytes of stack can be used.
28044  This problem will disappear after LARGE model is fully implemented.
28045 \end_layout
28046
28047 \begin_layout Subsection
28048 Functions
28049 \end_layout
28050
28051 \begin_layout Standard
28052 In addition to the standard SDCC function keywords, PIC16
28053 \begin_inset LatexCommand index
28054 name "PIC16"
28055
28056 \end_inset
28057
28058  port makes available two more:
28059 \end_layout
28060
28061 \begin_layout Description
28062 wparam
28063 \begin_inset LatexCommand index
28064 name "PIC16!wparam"
28065
28066 \end_inset
28067
28068  Use the WREG to pass one byte of the first function argument.
28069  This improves speed but you may not use this for functions with arguments
28070  that are called via function pointers, otherwise the first byte of the
28071  first parameter will get lost.
28072  Usage:
28073 \end_layout
28074
28075 \begin_layout LyX-Code
28076 void func_wparam(int a) wparam
28077 \end_layout
28078
28079 \begin_layout LyX-Code
28080 {
28081 \end_layout
28082
28083 \begin_layout LyX-Code
28084     /* WREG hold the lower part of a */
28085 \end_layout
28086
28087 \begin_layout LyX-Code
28088     /* the high part of a is stored in FSR2+2 (or +3 for large stack model)
28089  */
28090 \end_layout
28091
28092 \begin_layout LyX-Code
28093 ...
28094 \end_layout
28095
28096 \begin_layout LyX-Code
28097 }
28098 \end_layout
28099
28100 \begin_layout Description
28101 shadowregs
28102 \begin_inset LatexCommand index
28103 name "PIC16!shadowregs"
28104
28105 \end_inset
28106
28107  When entering/exiting an ISR, it is possible to take advantage of the PIC18F
28108  hardware shadow registers which hold the values of WREG, STATUS and BSR
28109  registers.
28110  This can be done by adding the keyword 
28111 \emph on
28112 shadowregs
28113 \emph default
28114  before the 
28115 \emph on
28116 interrupt
28117 \emph default
28118  keyword in the function's header.
28119 \end_layout
28120
28121 \begin_layout LyX-Code
28122 void isr_shadow(void) shadowregs interrupt 1
28123 \end_layout
28124
28125 \begin_layout LyX-Code
28126 {
28127 \end_layout
28128
28129 \begin_layout LyX-Code
28130 ...
28131 \end_layout
28132
28133 \begin_layout LyX-Code
28134 }
28135 \end_layout
28136
28137 \begin_layout Standard
28138
28139 \emph on
28140 shadowregs
28141 \emph default
28142  instructs the code generator not to store/restore WREG, STATUS, BSR when
28143  entering/exiting the ISR.
28144 \end_layout
28145
28146 \begin_layout Subsection
28147 Function return values
28148 \end_layout
28149
28150 \begin_layout Standard
28151 Return values from functions are placed to the appropriate registers following
28152  a modified Microchip policy optimized for SDCC.
28153  The following table shows these registers:
28154 \end_layout
28155
28156 \begin_layout Standard
28157 \align center
28158 \begin_inset Tabular
28159 <lyxtabular version="3" rows="6" columns="2">
28160 <features>
28161 <column alignment="center" valignment="top" leftline="true" width="0">
28162 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28163 <row topline="true" bottomline="true">
28164 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28165 \begin_inset Text
28166
28167 \begin_layout Standard
28168 size
28169 \end_layout
28170
28171 \end_inset
28172 </cell>
28173 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28174 \begin_inset Text
28175
28176 \begin_layout Standard
28177 destination register
28178 \end_layout
28179
28180 \end_inset
28181 </cell>
28182 </row>
28183 <row topline="true">
28184 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28185 \begin_inset Text
28186
28187 \begin_layout Standard
28188 8 bits
28189 \end_layout
28190
28191 \end_inset
28192 </cell>
28193 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28194 \begin_inset Text
28195
28196 \begin_layout Standard
28197 WREG
28198 \end_layout
28199
28200 \end_inset
28201 </cell>
28202 </row>
28203 <row topline="true">
28204 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28205 \begin_inset Text
28206
28207 \begin_layout Standard
28208 16 bits
28209 \end_layout
28210
28211 \end_inset
28212 </cell>
28213 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28214 \begin_inset Text
28215
28216 \begin_layout Standard
28217 PRODL:WREG
28218 \end_layout
28219
28220 \end_inset
28221 </cell>
28222 </row>
28223 <row topline="true">
28224 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28225 \begin_inset Text
28226
28227 \begin_layout Standard
28228 24 bits
28229 \end_layout
28230
28231 \end_inset
28232 </cell>
28233 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28234 \begin_inset Text
28235
28236 \begin_layout Standard
28237 PRODH:PRODL:WREG
28238 \end_layout
28239
28240 \end_inset
28241 </cell>
28242 </row>
28243 <row topline="true">
28244 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28245 \begin_inset Text
28246
28247 \begin_layout Standard
28248 32 bits
28249 \end_layout
28250
28251 \end_inset
28252 </cell>
28253 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28254 \begin_inset Text
28255
28256 \begin_layout Standard
28257 FSR0L:PRODH:PRODL:WREG
28258 \end_layout
28259
28260 \end_inset
28261 </cell>
28262 </row>
28263 <row topline="true" bottomline="true">
28264 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28265 \begin_inset Text
28266
28267 \begin_layout Standard
28268 >32 bits
28269 \end_layout
28270
28271 \end_inset
28272 </cell>
28273 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28274 \begin_inset Text
28275
28276 \begin_layout Standard
28277 on stack, FSR0 points to the beginning
28278 \end_layout
28279
28280 \end_inset
28281 </cell>
28282 </row>
28283 </lyxtabular>
28284
28285 \end_inset
28286
28287
28288 \end_layout
28289
28290 \begin_layout Subsection
28291 Interrupts
28292 \end_layout
28293
28294 \begin_layout Standard
28295 An interrupt
28296 \begin_inset LatexCommand index
28297 name "PIC16!interrupt"
28298
28299 \end_inset
28300
28301  service routine (ISR) is declared using the 
28302 \emph on
28303 interrupt
28304 \emph default
28305  keyword.
28306 \end_layout
28307
28308 \begin_layout LyX-Code
28309 void isr(void) interrupt 
28310 \emph on
28311 n
28312 \end_layout
28313
28314 \begin_layout LyX-Code
28315 {
28316 \end_layout
28317
28318 \begin_layout LyX-Code
28319 ...
28320 \end_layout
28321
28322 \begin_layout LyX-Code
28323 }
28324 \end_layout
28325
28326 \begin_layout Standard
28327
28328 \emph on
28329 n
28330 \emph default
28331  is the interrupt number, which for PIC18F devices can be:
28332 \end_layout
28333
28334 \begin_layout Standard
28335 \align center
28336 \begin_inset Tabular
28337 <lyxtabular version="3" rows="4" columns="3">
28338 <features>
28339 <column alignment="center" valignment="top" leftline="true" width="0">
28340 <column alignment="center" valignment="top" leftline="true" width="0">
28341 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28342 <row topline="true" bottomline="true">
28343 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28344 \begin_inset Text
28345
28346 \begin_layout Standard
28347
28348 \emph on
28349 n
28350 \end_layout
28351
28352 \end_inset
28353 </cell>
28354 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28355 \begin_inset Text
28356
28357 \begin_layout Standard
28358 Interrupt Vector
28359 \end_layout
28360
28361 \end_inset
28362 </cell>
28363 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28364 \begin_inset Text
28365
28366 \begin_layout Standard
28367 Interrupt Vector Address
28368 \end_layout
28369
28370 \end_inset
28371 </cell>
28372 </row>
28373 <row topline="true">
28374 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28375 \begin_inset Text
28376
28377 \begin_layout Standard
28378 0
28379 \end_layout
28380
28381 \end_inset
28382 </cell>
28383 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28384 \begin_inset Text
28385
28386 \begin_layout Standard
28387 RESET vector
28388 \end_layout
28389
28390 \end_inset
28391 </cell>
28392 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28393 \begin_inset Text
28394
28395 \begin_layout Standard
28396 0x000000
28397 \end_layout
28398
28399 \end_inset
28400 </cell>
28401 </row>
28402 <row topline="true">
28403 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28404 \begin_inset Text
28405
28406 \begin_layout Standard
28407
28408 \family roman
28409 \series medium
28410 \shape up
28411 \size normal
28412 \emph off
28413 \bar no
28414 \noun off
28415 \color none
28416 1
28417 \end_layout
28418
28419 \end_inset
28420 </cell>
28421 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28422 \begin_inset Text
28423
28424 \begin_layout Standard
28425
28426 \family roman
28427 \series medium
28428 \shape up
28429 \size normal
28430 \emph off
28431 \bar no
28432 \noun off
28433 \color none
28434 HIGH priority interrupts
28435 \end_layout
28436
28437 \end_inset
28438 </cell>
28439 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28440 \begin_inset Text
28441
28442 \begin_layout Standard
28443 0x000008
28444 \end_layout
28445
28446 \end_inset
28447 </cell>
28448 </row>
28449 <row topline="true" bottomline="true">
28450 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28451 \begin_inset Text
28452
28453 \begin_layout Standard
28454 2
28455 \end_layout
28456
28457 \end_inset
28458 </cell>
28459 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28460 \begin_inset Text
28461
28462 \begin_layout Standard
28463 LOW priority interrupts
28464 \end_layout
28465
28466 \end_inset
28467 </cell>
28468 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28469 \begin_inset Text
28470
28471 \begin_layout Standard
28472 0x000018
28473 \end_layout
28474
28475 \end_inset
28476 </cell>
28477 </row>
28478 </lyxtabular>
28479
28480 \end_inset
28481
28482
28483 \end_layout
28484
28485 \begin_layout Standard
28486 When generating assembly code for ISR the code generator places a 
28487 \noun on
28488 goto 
28489 \noun default
28490 instruction at the 
28491 \emph on
28492 Interrupt Vector Address
28493 \emph default
28494  which points at the generated ISR.
28495  This single GOTO instruction is part of an automatically generated 
28496 \emph on
28497 interrupt entry point
28498 \emph default
28499  function.
28500  The actuall ISR code is placed as normally would in the code space.
28501  Upon interrupt request, the GOTO instruction is executed which jumps to
28502  the ISR code.
28503  When declaring interrupt functions as _naked this GOTO instruction is 
28504 \series bold
28505 not
28506 \series default
28507  generated.
28508  The whole interrupt functions is therefore placed at the Interrupt Vector
28509  Address of the specific interrupt.
28510  This is not a problem for the LOW priority interrupts, but it is a problem
28511  for the RESET and the HIGH priority interrupts because code may be written
28512  at the next interrupt's vector address and cause indeterminate program
28513  behaviour if that interrupt is raised.
28514 \begin_inset Foot
28515 status open
28516
28517 \begin_layout Standard
28518 This is not a problem when
28519 \end_layout
28520
28521 \begin_layout Enumerate
28522 this is a HIGH interrupt ISR and LOW interrupts are 
28523 \emph on
28524 disabled
28525 \emph default
28526  or not used.
28527 \end_layout
28528
28529 \begin_layout Enumerate
28530 when the ISR is small enough not to reach the next interrupt's vector address.
28531 \end_layout
28532
28533 \end_inset
28534
28535
28536 \end_layout
28537
28538 \begin_layout Standard
28539
28540 \emph on
28541 n
28542 \emph default
28543  may be omitted.
28544  This way a function is generated similar to an ISR, but it is not assigned
28545  to any interrupt.
28546 \end_layout
28547
28548 \begin_layout Standard
28549 When entering an interrupt, currently the PIC16
28550 \begin_inset LatexCommand index
28551 name "PIC16"
28552
28553 \end_inset
28554
28555  port automatically saves the following registers:
28556 \end_layout
28557
28558 \begin_layout Itemize
28559 WREG
28560 \end_layout
28561
28562 \begin_layout Itemize
28563 STATUS
28564 \end_layout
28565
28566 \begin_layout Itemize
28567 BSR
28568 \end_layout
28569
28570 \begin_layout Itemize
28571 PROD (PRODL and PRODH)
28572 \end_layout
28573
28574 \begin_layout Itemize
28575 FSR0 (FSR0L and FSR0H)
28576 \end_layout
28577
28578 \begin_layout Standard
28579 These registers are restored upon return from the interrupt routine.
28580 \begin_inset Foot
28581 status open
28582
28583 \begin_layout Standard
28584 NOTE that when the _naked attribute is specified for an interrupt routine,
28585  then NO registers are stored or restored.
28586 \end_layout
28587
28588 \end_inset
28589
28590
28591 \end_layout
28592
28593 \begin_layout Subsection
28594 Generic Pointers
28595 \end_layout
28596
28597 \begin_layout Standard
28598 Generic pointers are implemented in PIC16 port as 3-byte (24-bit) types.
28599  There are 3 types of generic pointers currently implemented data, code
28600  and eeprom pointers.
28601  They are differentiated by the value of the 7th and 6th bits of the upper
28602  byte:
28603 \end_layout
28604
28605 \begin_layout Standard
28606 \align center
28607 \begin_inset Tabular
28608 <lyxtabular version="3" rows="5" columns="5">
28609 <features>
28610 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28611 <column alignment="center" valignment="top" width="0">
28612 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28613 <column alignment="center" valignment="top" width="0">
28614 <column alignment="left" valignment="top" rightline="true" width="0">
28615 <row topline="true" bottomline="true">
28616 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28617 \begin_inset Text
28618
28619 \begin_layout Standard
28620 pointer type
28621 \end_layout
28622
28623 \end_inset
28624 </cell>
28625 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28626 \begin_inset Text
28627
28628 \begin_layout Standard
28629 7th bit
28630 \end_layout
28631
28632 \end_inset
28633 </cell>
28634 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28635 \begin_inset Text
28636
28637 \begin_layout Standard
28638 6th bit
28639 \end_layout
28640
28641 \end_inset
28642 </cell>
28643 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28644 \begin_inset Text
28645
28646 \begin_layout Standard
28647 rest of the pointer
28648 \end_layout
28649
28650 \end_inset
28651 </cell>
28652 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28653 \begin_inset Text
28654
28655 \begin_layout Standard
28656 description
28657 \end_layout
28658
28659 \end_inset
28660 </cell>
28661 </row>
28662 <row topline="true" bottomline="true">
28663 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28664 \begin_inset Text
28665
28666 \begin_layout Standard
28667 data 
28668 \end_layout
28669
28670 \end_inset
28671 </cell>
28672 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28673 \begin_inset Text
28674
28675 \begin_layout Standard
28676 1
28677 \end_layout
28678
28679 \end_inset
28680 </cell>
28681 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28682 \begin_inset Text
28683
28684 \begin_layout Standard
28685 0
28686 \end_layout
28687
28688 \end_inset
28689 </cell>
28690 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28691 \begin_inset Text
28692
28693 \begin_layout Standard
28694
28695 \family typewriter
28696 \shape slanted
28697 \emph on
28698 uuuuuu uuuuxxxx xxxxxxxx
28699 \end_layout
28700
28701 \end_inset
28702 </cell>
28703 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28704 \begin_inset Text
28705
28706 \begin_layout Standard
28707 a 12-bit data pointer in data RAM memory
28708 \end_layout
28709
28710 \end_inset
28711 </cell>
28712 </row>
28713 <row bottomline="true">
28714 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28715 \begin_inset Text
28716
28717 \begin_layout Standard
28718 code
28719 \end_layout
28720
28721 \end_inset
28722 </cell>
28723 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28724 \begin_inset Text
28725
28726 \begin_layout Standard
28727 0
28728 \end_layout
28729
28730 \end_inset
28731 </cell>
28732 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28733 \begin_inset Text
28734
28735 \begin_layout Standard
28736 0
28737 \end_layout
28738
28739 \end_inset
28740 </cell>
28741 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28742 \begin_inset Text
28743
28744 \begin_layout Standard
28745
28746 \family typewriter
28747 \shape slanted
28748 \emph on
28749 uxxxxx xxxxxxxx xxxxxxxx
28750 \end_layout
28751
28752 \end_inset
28753 </cell>
28754 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28755 \begin_inset Text
28756
28757 \begin_layout Standard
28758 a 21-bit code pointer in FLASH memory
28759 \end_layout
28760
28761 \end_inset
28762 </cell>
28763 </row>
28764 <row bottomline="true">
28765 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28766 \begin_inset Text
28767
28768 \begin_layout Standard
28769 eeprom
28770 \end_layout
28771
28772 \end_inset
28773 </cell>
28774 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28775 \begin_inset Text
28776
28777 \begin_layout Standard
28778 0
28779 \end_layout
28780
28781 \end_inset
28782 </cell>
28783 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28784 \begin_inset Text
28785
28786 \begin_layout Standard
28787 1
28788 \end_layout
28789
28790 \end_inset
28791 </cell>
28792 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28793 \begin_inset Text
28794
28795 \begin_layout Standard
28796
28797 \family typewriter
28798 \shape slanted
28799 \emph on
28800 uuuuuu uuuuuuxx xxxxxxxx
28801 \end_layout
28802
28803 \end_inset
28804 </cell>
28805 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28806 \begin_inset Text
28807
28808 \begin_layout Standard
28809 a 10-bit eeprom pointer in EEPROM memory
28810 \end_layout
28811
28812 \end_inset
28813 </cell>
28814 </row>
28815 <row bottomline="true">
28816 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28817 \begin_inset Text
28818
28819 \begin_layout Standard
28820 (unimplemented)
28821 \end_layout
28822
28823 \end_inset
28824 </cell>
28825 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28826 \begin_inset Text
28827
28828 \begin_layout Standard
28829 1
28830 \end_layout
28831
28832 \end_inset
28833 </cell>
28834 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28835 \begin_inset Text
28836
28837 \begin_layout Standard
28838 1
28839 \end_layout
28840
28841 \end_inset
28842 </cell>
28843 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28844 \begin_inset Text
28845
28846 \begin_layout Standard
28847
28848 \family typewriter
28849 \shape slanted
28850 \emph on
28851 xxxxxx xxxxxxxx xxxxxxxx
28852 \end_layout
28853
28854 \end_inset
28855 </cell>
28856 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28857 \begin_inset Text
28858
28859 \begin_layout Standard
28860 unimplemented pointer type
28861 \end_layout
28862
28863 \end_inset
28864 </cell>
28865 </row>
28866 </lyxtabular>
28867
28868 \end_inset
28869
28870
28871 \end_layout
28872
28873 \begin_layout Standard
28874 \noindent
28875 Generic pointer are read and written with a set of library functions which
28876  read/write 1, 2, 3, 4 bytes.
28877 \end_layout
28878
28879 \begin_layout Subsection
28880 PIC16 C Libraries
28881 \end_layout
28882
28883 \begin_layout Subsubsection
28884 Standard I/O Streams
28885 \end_layout
28886
28887 \begin_layout Standard
28888 In the 
28889 \emph on
28890 stdio.h
28891 \emph default
28892  the type FILE is defined as:
28893 \end_layout
28894
28895 \begin_layout LyX-Code
28896 typedef char * FILE;
28897 \end_layout
28898
28899 \begin_layout Standard
28900 This type is the stream type implemented I/O in the PIC18F devices.
28901  Also the standard input and output streams are declared in stdio.h:
28902 \end_layout
28903
28904 \begin_layout LyX-Code
28905 extern FILE * stdin;
28906 \end_layout
28907
28908 \begin_layout LyX-Code
28909 extern FILE * stdout;
28910 \end_layout
28911
28912 \begin_layout Standard
28913 The FILE type is actually a generic pointer which defines one more type
28914  of generic pointers, the 
28915 \emph on
28916 stream
28917 \emph default
28918  pointer.
28919  This new type has the format:
28920 \end_layout
28921
28922 \begin_layout Standard
28923 \noindent
28924 \align center
28925 \begin_inset Tabular
28926 <lyxtabular version="3" rows="2" columns="7">
28927 <features>
28928 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28929 <column alignment="center" valignment="top" width="0">
28930 <column alignment="center" valignment="top" leftline="true" width="0">
28931 <column alignment="center" valignment="top" leftline="true" width="0">
28932 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28933 <column alignment="center" valignment="top" width="0">
28934 <column alignment="left" valignment="top" rightline="true" width="0">
28935 <row topline="true" bottomline="true">
28936 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28937 \begin_inset Text
28938
28939 \begin_layout Standard
28940 pointer type
28941 \end_layout
28942
28943 \end_inset
28944 </cell>
28945 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28946 \begin_inset Text
28947
28948 \begin_layout Standard
28949 <7:6>
28950 \end_layout
28951
28952 \end_inset
28953 </cell>
28954 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28955 \begin_inset Text
28956
28957 \begin_layout Standard
28958 <5>
28959 \end_layout
28960
28961 \end_inset
28962 </cell>
28963 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28964 \begin_inset Text
28965
28966 \begin_layout Standard
28967 <4>
28968 \end_layout
28969
28970 \end_inset
28971 </cell>
28972 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28973 \begin_inset Text
28974
28975 \begin_layout Standard
28976 <3:0>
28977 \end_layout
28978
28979 \end_inset
28980 </cell>
28981 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28982 \begin_inset Text
28983
28984 \begin_layout Standard
28985 rest of the pointer
28986 \end_layout
28987
28988 \end_inset
28989 </cell>
28990 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28991 \begin_inset Text
28992
28993 \begin_layout Standard
28994 descrption
28995 \end_layout
28996
28997 \end_inset
28998 </cell>
28999 </row>
29000 <row topline="true" bottomline="true">
29001 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29002 \begin_inset Text
29003
29004 \begin_layout Standard
29005 stream
29006 \end_layout
29007
29008 \end_inset
29009 </cell>
29010 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29011 \begin_inset Text
29012
29013 \begin_layout Standard
29014 00
29015 \end_layout
29016
29017 \end_inset
29018 </cell>
29019 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29020 \begin_inset Text
29021
29022 \begin_layout Standard
29023 1
29024 \end_layout
29025
29026 \end_inset
29027 </cell>
29028 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29029 \begin_inset Text
29030
29031 \begin_layout Standard
29032 0
29033 \end_layout
29034
29035 \end_inset
29036 </cell>
29037 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29038 \begin_inset Text
29039
29040 \begin_layout Standard
29041 nnnn
29042 \end_layout
29043
29044 \end_inset
29045 </cell>
29046 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29047 \begin_inset Text
29048
29049 \begin_layout Standard
29050
29051 \family typewriter
29052 \shape slanted
29053 \emph on
29054 uuuuuuuu uuuuuuuu
29055 \end_layout
29056
29057 \end_inset
29058 </cell>
29059 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29060 \begin_inset Text
29061
29062 \begin_layout Standard
29063 upper byte high nubble is 0x2n, the rest are zeroes
29064 \end_layout
29065
29066 \end_inset
29067 </cell>
29068 </row>
29069 </lyxtabular>
29070
29071 \end_inset
29072
29073
29074 \end_layout
29075
29076 \begin_layout Standard
29077 \noindent
29078 Currently implemented there are 3 types of streams defined:
29079 \end_layout
29080
29081 \begin_layout Standard
29082 \noindent
29083 \align center
29084 \begin_inset Tabular
29085 <lyxtabular version="3" rows="4" columns="4">
29086 <features>
29087 <column alignment="center" valignment="top" leftline="true" width="0">
29088 <column alignment="center" valignment="top" leftline="true" width="0">
29089 <column alignment="center" valignment="top" leftline="true" width="0">
29090 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29091 <row topline="true" bottomline="true">
29092 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29093 \begin_inset Text
29094
29095 \begin_layout Standard
29096 stream type
29097 \end_layout
29098
29099 \end_inset
29100 </cell>
29101 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29102 \begin_inset Text
29103
29104 \begin_layout Standard
29105 value
29106 \end_layout
29107
29108 \end_inset
29109 </cell>
29110 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29111 \begin_inset Text
29112
29113 \begin_layout Standard
29114 module
29115 \end_layout
29116
29117 \end_inset
29118 </cell>
29119 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29120 \begin_inset Text
29121
29122 \begin_layout Standard
29123 description
29124 \end_layout
29125
29126 \end_inset
29127 </cell>
29128 </row>
29129 <row topline="true">
29130 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29131 \begin_inset Text
29132
29133 \begin_layout Standard
29134 STREAM_USART
29135 \end_layout
29136
29137 \end_inset
29138 </cell>
29139 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29140 \begin_inset Text
29141
29142 \begin_layout Standard
29143
29144 \family typewriter
29145 0x200000UL
29146 \end_layout
29147
29148 \end_inset
29149 </cell>
29150 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29151 \begin_inset Text
29152
29153 \begin_layout Standard
29154 USART
29155 \end_layout
29156
29157 \end_inset
29158 </cell>
29159 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29160 \begin_inset Text
29161
29162 \begin_layout Standard
29163 Writes/Reads characters via the USART peripheral
29164 \end_layout
29165
29166 \end_inset
29167 </cell>
29168 </row>
29169 <row topline="true">
29170 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29171 \begin_inset Text
29172
29173 \begin_layout Standard
29174 STREAM_MSSP
29175 \end_layout
29176
29177 \end_inset
29178 </cell>
29179 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29180 \begin_inset Text
29181
29182 \begin_layout Standard
29183
29184 \family typewriter
29185 0x210000UL
29186 \end_layout
29187
29188 \end_inset
29189 </cell>
29190 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29191 \begin_inset Text
29192
29193 \begin_layout Standard
29194 MSSP
29195 \end_layout
29196
29197 \end_inset
29198 </cell>
29199 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29200 \begin_inset Text
29201
29202 \begin_layout Standard
29203 Writes/Reads characters via the MSSP peripheral
29204 \end_layout
29205
29206 \end_inset
29207 </cell>
29208 </row>
29209 <row topline="true" bottomline="true">
29210 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29211 \begin_inset Text
29212
29213 \begin_layout Standard
29214 STREAM_USER
29215 \end_layout
29216
29217 \end_inset
29218 </cell>
29219 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29220 \begin_inset Text
29221
29222 \begin_layout Standard
29223
29224 \family typewriter
29225 0x2f0000UL
29226 \end_layout
29227
29228 \end_inset
29229 </cell>
29230 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29231 \begin_inset Text
29232
29233 \begin_layout Standard
29234 (none)
29235 \end_layout
29236
29237 \end_inset
29238 </cell>
29239 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29240 \begin_inset Text
29241
29242 \begin_layout Standard
29243 Writes/Reads characters via used defined functions
29244 \end_layout
29245
29246 \end_inset
29247 </cell>
29248 </row>
29249 </lyxtabular>
29250
29251 \end_inset
29252
29253
29254 \end_layout
29255
29256 \begin_layout Standard
29257 \noindent
29258 The stream identifiers are declared as macros in the stdio.h header.
29259 \end_layout
29260
29261 \begin_layout Standard
29262 \noindent
29263 In the libc library there exist the functions that are used to write to
29264  each of the above streams.
29265  These are
29266 \end_layout
29267
29268 \begin_layout Description
29269 _
29270 \begin_inset ERT
29271 status collapsed
29272
29273 \begin_layout Standard
29274
29275
29276 \backslash
29277 /
29278 \end_layout
29279
29280 \end_inset
29281
29282 _stream_usart_putchar writes a character at the USART stream
29283 \end_layout
29284
29285 \begin_layout Description
29286 _
29287 \begin_inset ERT
29288 status collapsed
29289
29290 \begin_layout Standard
29291
29292
29293 \backslash
29294 /
29295 \end_layout
29296
29297 \end_inset
29298
29299 _stream_mssp_putchar writes a character at the MSSP stream
29300 \end_layout
29301
29302 \begin_layout Description
29303 putchar dummy function.
29304  This writes a character to a user specified manner.
29305 \end_layout
29306
29307 \begin_layout Standard
29308 In order to increase performance 
29309 \emph on
29310 putchar
29311 \emph default
29312  is declared in stdio.h as having its parameter in WREG (it has the wparam
29313  keyword).
29314  In stdio.h exists the macro PUTCHAR(arg) that defines the putchar function
29315  in a user-friendly way.
29316  
29317 \emph on
29318 arg
29319 \emph default
29320  is the name of the variable that holds the character to print.
29321  An example follows:
29322 \end_layout
29323
29324 \begin_layout LyX-Code
29325 #include <pic18fregs.h>
29326 \newline
29327 #include <stdio.h>
29328 \newline
29329
29330 \newline
29331 PUTCHAR( c )
29332 \end_layout
29333
29334 \begin_layout LyX-Code
29335 {
29336 \end_layout
29337
29338 \begin_layout LyX-Code
29339     PORTA = c;    /* dump character c to PORTA */
29340 \end_layout
29341
29342 \begin_layout LyX-Code
29343
29344 \newline
29345
29346 \newline
29347 void main(void)
29348 \end_layout
29349
29350 \begin_layout LyX-Code
29351 {
29352 \end_layout
29353
29354 \begin_layout LyX-Code
29355     stdout = STREAM_USER;    /* this is not necessary, since stdout points
29356 \end_layout
29357
29358 \begin_layout LyX-Code
29359                               * by default to STREAM_USER */
29360 \end_layout
29361
29362 \begin_layout LyX-Code
29363     printf (
29364 \begin_inset Quotes sld
29365 \end_inset
29366
29367 This is a printf test
29368 \backslash
29369 n
29370 \begin_inset Quotes srd
29371 \end_inset
29372
29373 );
29374 \end_layout
29375
29376 \begin_layout LyX-Code
29377 }
29378 \end_layout
29379
29380 \begin_layout LyX-Code
29381
29382 \end_layout
29383
29384 \begin_layout Subsubsection
29385 Printing functions
29386 \end_layout
29387
29388 \begin_layout Standard
29389 PIC16 contains an implementation of the printf-family of functions.
29390  There exist the following functions:
29391 \end_layout
29392
29393 \begin_layout LyX-Code
29394 extern unsigned int sprintf(char *buf, char *fmt, ...);
29395 \end_layout
29396
29397 \begin_layout LyX-Code
29398 extern unsigned int vsprintf(char *buf, char *fmt, va_list ap);
29399 \end_layout
29400
29401 \begin_layout LyX-Code
29402
29403 \end_layout
29404
29405 \begin_layout LyX-Code
29406 extern unsigned int printf(char *fmt, ...);
29407 \end_layout
29408
29409 \begin_layout LyX-Code
29410 extern unsigned int vprintf(char *fmt, va_lista ap);
29411 \end_layout
29412
29413 \begin_layout LyX-Code
29414
29415 \end_layout
29416
29417 \begin_layout LyX-Code
29418 extern unsigned int fprintf(FILE *fp, char *fmt, ...);
29419 \end_layout
29420
29421 \begin_layout LyX-Code
29422 extern unsigned int vfprintf(FILE *fp, char *fmt, va_list ap);
29423 \end_layout
29424
29425 \begin_layout Standard
29426 For sprintf and vsprintf 
29427 \emph on
29428 buf
29429 \emph default
29430  should normally be a data pointer where the resulting string will be placed.
29431  No range checking is done so the user should allocate the necessary buffer.
29432  For fprintf and vfprintf 
29433 \emph on
29434 fp
29435 \emph default
29436  should be a stream pointer (i.e.
29437  stdout, STREAM_MSSP, etc...).
29438 \end_layout
29439
29440 \begin_layout Subsubsection
29441 Signals
29442 \end_layout
29443
29444 \begin_layout Standard
29445 The PIC18F family of microcontrollers supports a number of interrupt sources.
29446  A list of these interrupts is shown in the following table:
29447 \end_layout
29448
29449 \begin_layout Standard
29450 \align center
29451 \begin_inset Tabular
29452 <lyxtabular version="3" rows="11" columns="4">
29453 <features>
29454 <column alignment="left" valignment="top" leftline="true" width="0">
29455 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29456 <column alignment="left" valignment="top" leftline="true" width="0">
29457 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29458 <row topline="true" bottomline="true">
29459 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29460 \begin_inset Text
29461
29462 \begin_layout Standard
29463 signal name
29464 \end_layout
29465
29466 \end_inset
29467 </cell>
29468 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29469 \begin_inset Text
29470
29471 \begin_layout Standard
29472 description
29473 \end_layout
29474
29475 \end_inset
29476 </cell>
29477 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29478 \begin_inset Text
29479
29480 \begin_layout Standard
29481 signal name
29482 \end_layout
29483
29484 \end_inset
29485 </cell>
29486 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29487 \begin_inset Text
29488
29489 \begin_layout Standard
29490 description
29491 \end_layout
29492
29493 \end_inset
29494 </cell>
29495 </row>
29496 <row topline="true">
29497 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29498 \begin_inset Text
29499
29500 \begin_layout Standard
29501 SIG_RB
29502 \end_layout
29503
29504 \end_inset
29505 </cell>
29506 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29507 \begin_inset Text
29508
29509 \begin_layout Standard
29510 PORTB change interrupt
29511 \end_layout
29512
29513 \end_inset
29514 </cell>
29515 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29516 \begin_inset Text
29517
29518 \begin_layout Standard
29519 SIG_EE
29520 \end_layout
29521
29522 \end_inset
29523 </cell>
29524 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29525 \begin_inset Text
29526
29527 \begin_layout Standard
29528 EEPROM/FLASH write complete interrupt
29529 \end_layout
29530
29531 \end_inset
29532 </cell>
29533 </row>
29534 <row topline="true">
29535 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29536 \begin_inset Text
29537
29538 \begin_layout Standard
29539 SIG_INT0
29540 \end_layout
29541
29542 \end_inset
29543 </cell>
29544 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29545 \begin_inset Text
29546
29547 \begin_layout Standard
29548 INT0 external interrupt
29549 \end_layout
29550
29551 \end_inset
29552 </cell>
29553 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29554 \begin_inset Text
29555
29556 \begin_layout Standard
29557 SIG_BCOL
29558 \end_layout
29559
29560 \end_inset
29561 </cell>
29562 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29563 \begin_inset Text
29564
29565 \begin_layout Standard
29566 Bus collision interrupt
29567 \end_layout
29568
29569 \end_inset
29570 </cell>
29571 </row>
29572 <row topline="true">
29573 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29574 \begin_inset Text
29575
29576 \begin_layout Standard
29577 SIG_INT1
29578 \end_layout
29579
29580 \end_inset
29581 </cell>
29582 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29583 \begin_inset Text
29584
29585 \begin_layout Standard
29586 INT1 external interrupt
29587 \end_layout
29588
29589 \end_inset
29590 </cell>
29591 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29592 \begin_inset Text
29593
29594 \begin_layout Standard
29595 SIG_LVD
29596 \end_layout
29597
29598 \end_inset
29599 </cell>
29600 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29601 \begin_inset Text
29602
29603 \begin_layout Standard
29604 Low voltage detect interrupt
29605 \end_layout
29606
29607 \end_inset
29608 </cell>
29609 </row>
29610 <row topline="true">
29611 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29612 \begin_inset Text
29613
29614 \begin_layout Standard
29615 SIG_INT2
29616 \end_layout
29617
29618 \end_inset
29619 </cell>
29620 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29621 \begin_inset Text
29622
29623 \begin_layout Standard
29624 INT2 external interrupt
29625 \end_layout
29626
29627 \end_inset
29628 </cell>
29629 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29630 \begin_inset Text
29631
29632 \begin_layout Standard
29633 SIG_PSP
29634 \end_layout
29635
29636 \end_inset
29637 </cell>
29638 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29639 \begin_inset Text
29640
29641 \begin_layout Standard
29642 Parallel slave port interrupt
29643 \end_layout
29644
29645 \end_inset
29646 </cell>
29647 </row>
29648 <row topline="true">
29649 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29650 \begin_inset Text
29651
29652 \begin_layout Standard
29653 SIG_CCP1
29654 \end_layout
29655
29656 \end_inset
29657 </cell>
29658 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29659 \begin_inset Text
29660
29661 \begin_layout Standard
29662 CCP1 module interrupt
29663 \end_layout
29664
29665 \end_inset
29666 </cell>
29667 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29668 \begin_inset Text
29669
29670 \begin_layout Standard
29671 SIG_AD
29672 \end_layout
29673
29674 \end_inset
29675 </cell>
29676 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29677 \begin_inset Text
29678
29679 \begin_layout Standard
29680 AD convertion complete interrupt
29681 \end_layout
29682
29683 \end_inset
29684 </cell>
29685 </row>
29686 <row topline="true">
29687 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29688 \begin_inset Text
29689
29690 \begin_layout Standard
29691 SIG_CCP2
29692 \end_layout
29693
29694 \end_inset
29695 </cell>
29696 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29697 \begin_inset Text
29698
29699 \begin_layout Standard
29700 CCP2 module interrupt
29701 \end_layout
29702
29703 \end_inset
29704 </cell>
29705 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29706 \begin_inset Text
29707
29708 \begin_layout Standard
29709 SIG_RC
29710 \end_layout
29711
29712 \end_inset
29713 </cell>
29714 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29715 \begin_inset Text
29716
29717 \begin_layout Standard
29718 USART receive interrupt
29719 \end_layout
29720
29721 \end_inset
29722 </cell>
29723 </row>
29724 <row topline="true">
29725 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29726 \begin_inset Text
29727
29728 \begin_layout Standard
29729 SIG_TMR0
29730 \end_layout
29731
29732 \end_inset
29733 </cell>
29734 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29735 \begin_inset Text
29736
29737 \begin_layout Standard
29738 TMR0 overflow interrupt
29739 \end_layout
29740
29741 \end_inset
29742 </cell>
29743 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29744 \begin_inset Text
29745
29746 \begin_layout Standard
29747 SIG_TX
29748 \end_layout
29749
29750 \end_inset
29751 </cell>
29752 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29753 \begin_inset Text
29754
29755 \begin_layout Standard
29756 USART transmit interrupt
29757 \end_layout
29758
29759 \end_inset
29760 </cell>
29761 </row>
29762 <row topline="true">
29763 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29764 \begin_inset Text
29765
29766 \begin_layout Standard
29767 SIG_TMR1
29768 \end_layout
29769
29770 \end_inset
29771 </cell>
29772 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29773 \begin_inset Text
29774
29775 \begin_layout Standard
29776 TMR1 overflow interrupt
29777 \end_layout
29778
29779 \end_inset
29780 </cell>
29781 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29782 \begin_inset Text
29783
29784 \begin_layout Standard
29785 SIG_MSSP
29786 \end_layout
29787
29788 \end_inset
29789 </cell>
29790 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29791 \begin_inset Text
29792
29793 \begin_layout Standard
29794 SSP receive/transmit interrupt
29795 \end_layout
29796
29797 \end_inset
29798 </cell>
29799 </row>
29800 <row topline="true">
29801 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29802 \begin_inset Text
29803
29804 \begin_layout Standard
29805 SIG_TMR2
29806 \end_layout
29807
29808 \end_inset
29809 </cell>
29810 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29811 \begin_inset Text
29812
29813 \begin_layout Standard
29814 TMR2 matches PR2 interrupt
29815 \end_layout
29816
29817 \end_inset
29818 </cell>
29819 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29820 \begin_inset Text
29821
29822 \begin_layout Standard
29823
29824 \end_layout
29825
29826 \end_inset
29827 </cell>
29828 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29829 \begin_inset Text
29830
29831 \begin_layout Standard
29832
29833 \end_layout
29834
29835 \end_inset
29836 </cell>
29837 </row>
29838 <row topline="true" bottomline="true">
29839 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29840 \begin_inset Text
29841
29842 \begin_layout Standard
29843 SIG_TMR3
29844 \end_layout
29845
29846 \end_inset
29847 </cell>
29848 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29849 \begin_inset Text
29850
29851 \begin_layout Standard
29852 TMR3 overflow interrupt
29853 \end_layout
29854
29855 \end_inset
29856 </cell>
29857 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29858 \begin_inset Text
29859
29860 \begin_layout Standard
29861
29862 \end_layout
29863
29864 \end_inset
29865 </cell>
29866 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29867 \begin_inset Text
29868
29869 \begin_layout Standard
29870
29871 \end_layout
29872
29873 \end_inset
29874 </cell>
29875 </row>
29876 </lyxtabular>
29877
29878 \end_inset
29879
29880
29881 \end_layout
29882
29883 \begin_layout Standard
29884 \noindent
29885 The prototypes for these names are defined in the header file 
29886 \emph on
29887 signal.h
29888 \emph default
29889  .
29890 \end_layout
29891
29892 \begin_layout Standard
29893 \noindent
29894 In order to simplify signal handling, a number of macros is provided:
29895 \end_layout
29896
29897 \begin_layout List
29898 \labelwidthstring 00.00.0000
29899 DEF_INTHIGH(name) begin the definition of the interrupt dispatch table for
29900  high priority interrupts.
29901  
29902 \emph on
29903 name
29904 \emph default
29905  is the function name to use.
29906 \end_layout
29907
29908 \begin_layout List
29909 \labelwidthstring 00.00.0000
29910 DEF_INTLOW(name) begin the definition of the interrupt dispatch table fo
29911  low priority interrupt.
29912  
29913 \emph on
29914 name
29915 \emph default
29916  is the function name to use.
29917 \end_layout
29918
29919 \begin_layout List
29920 \labelwidthstring 00.00.0000
29921 DEF_HANDLER(sig,handler) define a handler for signal 
29922 \emph on
29923 sig.
29924 \end_layout
29925
29926 \begin_layout List
29927 \labelwidthstring 00.00.0000
29928 END_DEF end the declaration of the dispatch table.
29929 \end_layout
29930
29931 \begin_layout Standard
29932 Additionally there are two more macros to simplify the declaration of the
29933  signal handler:
29934 \end_layout
29935
29936 \begin_layout List
29937 \labelwidthstring 00.00.0000
29938
29939 \series medium
29940 SIGHANDLER(handler)
29941 \series default
29942  this declares the function prototype for the 
29943 \emph on
29944 handler
29945 \emph default
29946  function.
29947 \end_layout
29948
29949 \begin_layout List
29950 \labelwidthstring 00.00.0000
29951 SIGHANDLERNAKED(handler) same as SIGHANDLER() but declares a naked function.
29952 \end_layout
29953
29954 \begin_layout Standard
29955 An example of using the macros above is shown below:
29956 \end_layout
29957
29958 \begin_layout LyX-Code
29959 #include <pic18fregs.h>
29960 \end_layout
29961
29962 \begin_layout LyX-Code
29963 #include <signal.h>
29964 \newline
29965
29966 \newline
29967 DEF_INTHIGH(high_int)
29968 \end_layout
29969
29970 \begin_layout LyX-Code
29971 DEF_HANDLER(SIG_TMR0, _tmr0_handler)
29972 \end_layout
29973
29974 \begin_layout LyX-Code
29975 DEF_HANDLER(SIG_BCOL, _bcol_handler)
29976 \end_layout
29977
29978 \begin_layout LyX-Code
29979 END_DEF
29980 \newline
29981
29982 \newline
29983 SIGHANDLER(_tmr0_handler)
29984 \end_layout
29985
29986 \begin_layout LyX-Code
29987 {
29988 \end_layout
29989
29990 \begin_layout LyX-Code
29991   /* action to be taken when timer 0 overflows */
29992 \end_layout
29993
29994 \begin_layout LyX-Code
29995 }
29996 \newline
29997
29998 \newline
29999 SIGHANDLERNAKED(_bcol_handler)
30000 \end_layout
30001
30002 \begin_layout LyX-Code
30003 {
30004 \end_layout
30005
30006 \begin_layout LyX-Code
30007   _asm
30008 \end_layout
30009
30010 \begin_layout LyX-Code
30011     /* action to be taken when bus collision occurs */
30012 \end_layout
30013
30014 \begin_layout LyX-Code
30015     retfie
30016 \end_layout
30017
30018 \begin_layout LyX-Code
30019  _endasm;
30020 \end_layout
30021
30022 \begin_layout LyX-Code
30023 }
30024 \end_layout
30025
30026 \begin_layout Standard
30027
30028 \series bold
30029 NOTES:
30030 \series default
30031  Special care should be taken when using the above scheme:
30032 \end_layout
30033
30034 \begin_layout Itemize
30035 do not place a colon (;) at the end of the DEF_* and END_DEF macros.
30036 \end_layout
30037
30038 \begin_layout Itemize
30039 when declaring SIGHANDLERNAKED handler never forget to use 
30040 \emph on
30041 retfie
30042 \emph default
30043  for proper returning.
30044 \end_layout
30045
30046 \begin_layout Subsection
30047 PIC16 Port -- Tips
30048 \end_layout
30049
30050 \begin_layout Standard
30051 Here you can find some general tips for compiling programs with SDCC/pic16.
30052 \end_layout
30053
30054 \begin_layout Subsubsection
30055 Stack size
30056 \end_layout
30057
30058 \begin_layout Standard
30059 The default stack
30060 \begin_inset LatexCommand index
30061 name "PIC16!stack"
30062
30063 \end_inset
30064
30065  size (that is 64 bytes) probably is enough for many programs.
30066  One must take care that when there are many levels of function nesting,
30067  or there is excessive usage of stack, its size should be extended.
30068  An example of such a case is the printf/sprintf family of functions.
30069  If you encounter problems like not being able to print integers, then you
30070  need to set the stack size around the maximum (256 for small stack model).
30071  The following diagram shows what happens when calling printf to print an
30072  integer:
30073 \end_layout
30074
30075 \begin_layout LyX-Code
30076 printf () --> ltoa () --> ultoa () --> divschar ()
30077 \end_layout
30078
30079 \begin_layout Standard
30080 It is should be understood that stack is easily consumed when calling complicate
30081 d functions.
30082  Using command line arguments like -
30083 \begin_inset ERT
30084 status collapsed
30085
30086 \begin_layout Standard
30087
30088
30089 \backslash
30090 /
30091 \end_layout
30092
30093 \end_inset
30094
30095 -fommit-frame-pointer might reduce stack usage by not creating unnecessery
30096  stack frames.
30097  Other ways to reduce stack usage may exist.
30098 \end_layout
30099
30100 \begin_layout Subsection
30101 Known Bugs
30102 \end_layout
30103
30104 \begin_layout Subsubsection
30105 Extended Instruction Set
30106 \end_layout
30107
30108 \begin_layout Standard
30109 The PIC16 port emits code which is incompatible with the extended instruction
30110  set available with many newer devices.
30111  Make sure to always explicitly disable it, usually using
30112 \end_layout
30113
30114 \begin_layout Standard
30115
30116 \family typewriter
30117 static __code char __at(__CONFIG4L) conf4l = /* more flags & */ _XINST_OFF_4L;
30118 \end_layout
30119
30120 \begin_layout Standard
30121 \noindent
30122 Some devices (namely 18f2455, 18f2550, 18f4455, and 18f4550) use _ENHCPU_OFF_4L
30123  instead of _XINST_OFF_4L.
30124 \end_layout
30125
30126 \begin_layout Subsubsection
30127 Regression Tests
30128 \end_layout
30129
30130 \begin_layout Standard
30131 The PIC16 port currently passes most but not all of the tests in SDCC's
30132  regression test
30133 \begin_inset LatexCommand index
30134 name "Regression test (PIC16)"
30135
30136 \end_inset
30137
30138  suite (see section 
30139 \begin_inset LatexCommand ref
30140 reference "sec:Quality-control"
30141
30142 \end_inset
30143
30144 ), thus no automatic regression tests are currently performed for the PIC16
30145  target.
30146 \end_layout
30147
30148 \begin_layout Chapter
30149 Debugging
30150 \end_layout
30151
30152 \begin_layout Standard
30153 There are several approaches to debugging your code.
30154  This chapter is meant to show your options and to give detail on some of
30155  them:
30156 \newline
30157
30158 \newline
30159 When writing your code:
30160 \end_layout
30161
30162 \begin_layout Itemize
30163 write your code with debugging in mind (avoid duplicating code, put conceptually
30164  similar variables into structs, use structured code, have strategic points
30165  within your code where all variables are consistent, ...)
30166 \end_layout
30167
30168 \begin_layout Itemize
30169 run a syntax-checking tool like splint
30170 \begin_inset LatexCommand index
30171 name "splint (syntax checking tool)"
30172
30173 \end_inset
30174
30175
30176 \begin_inset LatexCommand index
30177 name "lint (syntax checking tool)"
30178
30179 \end_inset
30180
30181  (see -
30182 \begin_inset ERT
30183 status collapsed
30184
30185 \begin_layout Standard
30186
30187
30188 \backslash
30189 /
30190 \end_layout
30191
30192 \end_inset
30193
30194 -more-pedantic 
30195 \begin_inset LatexCommand ref
30196 reference "lyx:more-pedantic-SPLINT"
30197
30198 \end_inset
30199
30200 ) over the code.
30201 \end_layout
30202
30203 \begin_layout Itemize
30204 for the high level code use a C-compiler (like f.e.
30205  GCC) to compile run and debug the code on your host.
30206  See (see -
30207 \begin_inset ERT
30208 status collapsed
30209
30210 \begin_layout Standard
30211
30212
30213 \backslash
30214 /
30215 \end_layout
30216
30217 \end_inset
30218
30219 -more-pedantic 
30220 \begin_inset LatexCommand ref
30221 reference "lyx:more-pedantic-SPLINT"
30222
30223 \end_inset
30224
30225 ) on how to handle syntax extensions like __xdata, __at(), ...
30226  
30227 \end_layout
30228
30229 \begin_layout Itemize
30230 use another C-compiler to compile code for your target.
30231  Always an option but not recommended:) And not very likely to help you.
30232  If you seriously consider walking this path you should at least occasionally
30233  check portability of your code.
30234  Most commercial compiler vendors will offer an evaluation version so you
30235  can test compile your code or snippets of your code.
30236 \end_layout
30237
30238 \begin_layout Standard
30239 Debugging on a simulator:
30240 \end_layout
30241
30242 \begin_layout Itemize
30243 there is a separate section about SDCDB (section 
30244 \begin_inset LatexCommand ref
30245 reference "cha:Debugging-with-SDCDB"
30246
30247 \end_inset
30248
30249 ) below.
30250 \end_layout
30251
30252 \begin_layout Itemize
30253 or (8051 specific) use a freeware/commercial simulator which interfaces
30254  to the AOMF
30255 \begin_inset LatexCommand index
30256 name "AOMF, AOMF51"
30257
30258 \end_inset
30259
30260  file (see 
30261 \begin_inset LatexCommand ref
30262 reference "OMF file"
30263
30264 \end_inset
30265
30266 ) optionally generated by SDCC.
30267 \end_layout
30268
30269 \begin_layout Standard
30270 Debugging On-target: 
30271 \end_layout
30272
30273 \begin_layout Itemize
30274 use a MCU port pin to serially output debug data to the RS232 port of your
30275  host.
30276  You'll probably want some level shifting device typically involving a MAX232
30277  or similar IC.
30278  If the hardware serial port of the MCU is not available search for 'Software
30279  UART' in your favourite search machine.
30280 \end_layout
30281
30282 \begin_layout Itemize
30283 use an on-target monitor.
30284  In this context a monitor is a small program which usually accepts commands
30285  via a serial line and allows to set program counter, to single step through
30286  a program and read/write memory locations.
30287  For the 8051 good examples of monitors are paulmon and cmon51 (see section
30288  
30289 \begin_inset LatexCommand ref
30290 reference "sec:Related-open-source-tools"
30291
30292 \end_inset
30293
30294 ).
30295 \end_layout
30296
30297 \begin_layout Itemize
30298 toggle MCU port pins at strategic points within your code and use an oscilloscop
30299 e.
30300  A 
30301 \emph on
30302 digital oscilloscope
30303 \emph default
30304
30305 \begin_inset LatexCommand index
30306 name "Oscilloscope"
30307
30308 \end_inset
30309
30310  with deep trace memory is really helpful especially if you have to debug
30311  a realtime application.
30312  If you need to monitor more pins than your oscilloscope provides you can
30313  sometimes get away with a small R-2R network.
30314  On a single channel oscilloscope you could f.e.
30315  monitor 2 push-pull driven pins by connecting one via a 10\InsetSpace ~
30316 k
30317 \begin_inset Formula $\Omega$
30318 \end_inset
30319
30320  resistor and the other one by a 5\InsetSpace ~
30321 k
30322 \begin_inset Formula $\Omega$
30323 \end_inset
30324
30325  resistor to the oscilloscope probe (check output drive capability of the
30326  pins you want to monitor).
30327  If you need to monitor many more pins a 
30328 \emph on
30329 logic analyzer
30330 \emph default
30331  will be handy.
30332 \end_layout
30333
30334 \begin_layout Itemize
30335 use an ICE (
30336 \emph on
30337 i
30338 \emph default
30339
30340 \emph on
30341 c
30342 \emph default
30343 ircuit 
30344 \emph on
30345 e
30346 \emph default
30347 mulator
30348 \begin_inset LatexCommand index
30349 name "ICE (in circuit emulator)"
30350
30351 \end_inset
30352
30353 ).
30354  Usually very expensive.
30355  And very nice to have too.
30356  And usually locks you (for years...) to the devices the ICE can emulate.
30357  
30358 \end_layout
30359
30360 \begin_layout Itemize
30361 use a remote debugger.
30362  In most 8-bit systems the symbol information is not available on the target,
30363  and a complete debugger is too bulky for the target system.
30364  Therefore usually a debugger on the host system connects to an on-target
30365  debugging stub which accepts only primitive commands.
30366  
30367 \newline
30368 Terms to enter into your favourite search engine could be 'remote debugging',
30369  'gdb stub' or 'inferior debugger'.
30370  (is there one?)
30371 \end_layout
30372
30373 \begin_layout Itemize
30374 use an on target hardware debugger.
30375  Some of the more modern MCUs include hardware support for setting break
30376  points and monitoring/changing variables by using dedicated hardware pins.
30377  This facility doesn't require additional code to run on the target and
30378  
30379 \emph on
30380 usually
30381 \emph default
30382  doesn't affect runtime behaviour until a breakpoint is hit.
30383  For the mcs51 most hardware debuggers use the AOMF
30384 \begin_inset LatexCommand index
30385 name "AOMF, AOMF51"
30386
30387 \end_inset
30388
30389  file (see 
30390 \begin_inset LatexCommand ref
30391 reference "OMF file"
30392
30393 \end_inset
30394
30395 ) as input file.
30396  
30397 \end_layout
30398
30399 \begin_layout Standard
30400 Last not least:
30401 \end_layout
30402
30403 \begin_layout Itemize
30404 if you are not familiar with any of the following terms you're likely to
30405  run into problems rather sooner than later: 
30406 \emph on
30407 volatile
30408 \emph default
30409
30410 \emph on
30411 atomic
30412 \emph default
30413
30414 \emph on
30415 memory map
30416 \emph default
30417
30418 \emph on
30419 overlay
30420 \emph default
30421 .
30422  As an embedded programmer you 
30423 \emph on
30424 have
30425 \emph default
30426  to know them so why not look them up 
30427 \emph on
30428 before
30429 \emph default
30430  you have problems?)
30431 \end_layout
30432
30433 \begin_layout Itemize
30434 tell someone else about your problem (actually this is a surprisingly effective
30435  means to hunt down the bug even if the listener is not familiar with your
30436  environment).
30437  As 'failure to communicate' is probably one of the job-induced deformations
30438  of an embedded programmer this is highly encouraged.
30439 \end_layout
30440
30441 \begin_layout Section
30442 Debugging with SDCDB
30443 \begin_inset LatexCommand label
30444 name "cha:Debugging-with-SDCDB"
30445
30446 \end_inset
30447
30448
30449 \begin_inset LatexCommand index
30450 name "SDCDB (debugger)"
30451
30452 \end_inset
30453
30454  
30455 \end_layout
30456
30457 \begin_layout Standard
30458 SDCC is distributed with a source level debugger
30459 \begin_inset LatexCommand index
30460 name "Debugger"
30461
30462 \end_inset
30463
30464 .
30465  The debugger uses a command line interface, the command repertoire of the
30466  debugger has been kept as close to gdb
30467 \begin_inset LatexCommand index
30468 name "gdb"
30469
30470 \end_inset
30471
30472  (the GNU debugger) as possible.
30473  The configuration and build process is part of the standard compiler installati
30474 on, which also builds and installs the debugger in the target directory
30475  specified during configuration.
30476  The debugger allows you debug BOTH at the C source and at the ASM source
30477  level.
30478 \end_layout
30479
30480 \begin_layout Subsection
30481 Compiling for Debugging
30482 \end_layout
30483
30484 \begin_layout Standard
30485 The -
30486 \begin_inset ERT
30487 status collapsed
30488
30489 \begin_layout Standard
30490
30491
30492 \backslash
30493 /
30494 \end_layout
30495
30496 \end_inset
30497
30498 -debug
30499 \begin_inset LatexCommand index
30500 name "-\\/-debug"
30501
30502 \end_inset
30503
30504  option must be specified for all files for which debug information is to
30505  be generated.
30506  The compiler generates a .adb file for each of these files.
30507  The linker creates the .cdb
30508 \begin_inset LatexCommand index
30509 name "<file>.cdb"
30510
30511 \end_inset
30512
30513  file from the .adb
30514 \begin_inset LatexCommand index
30515 name "<file>.adb"
30516
30517 \end_inset
30518
30519  files and the address information.
30520  This .cdb is used by the debugger.
30521 \end_layout
30522
30523 \begin_layout Subsection
30524 How the Debugger Works
30525 \end_layout
30526
30527 \begin_layout Standard
30528 When the -
30529 \begin_inset ERT
30530 status collapsed
30531
30532 \begin_layout Standard
30533
30534
30535 \backslash
30536 /
30537 \end_layout
30538
30539 \end_inset
30540
30541 -debug option is specified the compiler generates extra symbol information
30542  some of which are put into the assembler source and some are put into the
30543  .adb file.
30544  Then the linker creates the .cdb file from the individual .adb files with
30545  the address information for the symbols.
30546  The debugger reads the symbolic information generated by the compiler &
30547  the address information generated by the linker.
30548  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
30549  execution is controlled by the debugger.
30550  When a command is issued for the debugger, it translates it into appropriate
30551  commands for the simulator.
30552  (Currently SDCDM only connects to the simulator but 
30553 \emph on
30554 newcdb
30555 \emph default
30556  at 
30557 \begin_inset LatexCommand url
30558 target "http://ec2drv.sf.net/"
30559
30560 \end_inset
30561
30562  is an effort to connect directly to the hardware.) 
30563 \end_layout
30564
30565 \begin_layout Subsection
30566 Starting the Debugger SDCDB
30567 \end_layout
30568
30569 \begin_layout Standard
30570 The debugger can be started using the following command line.
30571  (Assume the file you are debugging has the file name foo).
30572 \newline
30573
30574 \newline
30575
30576 \family sans
30577 \series bold
30578 sdcdb foo
30579 \newline
30580
30581 \family default
30582 \series default
30583
30584 \newline
30585 The debugger will look for the following files.
30586 \end_layout
30587
30588 \begin_layout Itemize
30589 foo.c - the source file.
30590 \end_layout
30591
30592 \begin_layout Itemize
30593 foo.cdb - the debugger symbol information file.
30594 \end_layout
30595
30596 \begin_layout Itemize
30597 foo.ihx - the Intel hex format
30598 \begin_inset LatexCommand index
30599 name "Intel hex format"
30600
30601 \end_inset
30602
30603  object file.
30604 \end_layout
30605
30606 \begin_layout Subsection
30607 SDCDB Command Line Options
30608 \end_layout
30609
30610 \begin_layout Itemize
30611 -
30612 \begin_inset ERT
30613 status collapsed
30614
30615 \begin_layout Standard
30616
30617
30618 \backslash
30619 /
30620 \end_layout
30621
30622 \end_inset
30623
30624 -directory=<source file directory> this option can used to specify the directory
30625  search list.
30626  The debugger will look into the directory list specified for source, cdb
30627  & ihx files.
30628  The items in the directory list must be separated by ':', e.g.
30629  if the source files can be in the directories /home/src1 and /home/src2,
30630  the -
30631 \begin_inset ERT
30632 status collapsed
30633
30634 \begin_layout Standard
30635
30636
30637 \backslash
30638 /
30639 \end_layout
30640
30641 \end_inset
30642
30643 -directory option should be -
30644 \begin_inset ERT
30645 status collapsed
30646
30647 \begin_layout Standard
30648
30649
30650 \backslash
30651 /
30652 \end_layout
30653
30654 \end_inset
30655
30656 -directory=/home/src1:/home/src2.
30657  Note there can be no spaces in the option.
30658  
30659 \end_layout
30660
30661 \begin_layout Itemize
30662 -cd <directory> - change to the <directory>.
30663 \end_layout
30664
30665 \begin_layout Itemize
30666 -fullname - used by GUI front ends.
30667 \end_layout
30668
30669 \begin_layout Itemize
30670 -cpu <cpu-type> - this argument is passed to the simulator please see the
30671  simulator docs for details.
30672 \end_layout
30673
30674 \begin_layout Itemize
30675 -X <Clock frequency > this options is passed to the simulator please see
30676  the simulator docs for details.
30677 \end_layout
30678
30679 \begin_layout Itemize
30680 -s <serial port file> passed to simulator see the simulator docs for details.
30681 \end_layout
30682
30683 \begin_layout Itemize
30684 -S <serial in,out> passed to simulator see the simulator docs for details.
30685 \end_layout
30686
30687 \begin_layout Itemize
30688 -k <port number> passed to simulator see the simulator docs for details.
30689 \end_layout
30690
30691 \begin_layout Subsection
30692 SDCDB Debugger Commands
30693 \end_layout
30694
30695 \begin_layout Standard
30696 As mentioned earlier the command interface for the debugger has been deliberatel
30697 y kept as close the GNU debugger gdb, as possible.
30698  This will help the integration with existing graphical user interfaces
30699  (like ddd, xxgdb or xemacs) existing for the GNU debugger.
30700  If you use a graphical user interface for the debugger you can skip this
30701  section.
30702 \end_layout
30703
30704 \begin_layout Subsubsection*
30705 break [line | file:line | function | file:function]
30706 \end_layout
30707
30708 \begin_layout Standard
30709 Set breakpoint at specified line or function:
30710 \newline
30711
30712 \newline
30713
30714 \family sans
30715 \series bold
30716 sdcdb>break 100 
30717 \newline
30718 sdcdb>break foo.c:100
30719 \newline
30720 sdcdb>break funcfoo
30721 \newline
30722 sdcdb>break foo.c:funcfoo
30723 \end_layout
30724
30725 \begin_layout Subsubsection*
30726 clear [line | file:line | function | file:function ]
30727 \end_layout
30728
30729 \begin_layout Standard
30730 Clear breakpoint at specified line or function:
30731 \newline
30732
30733 \newline
30734
30735 \family sans
30736 \series bold
30737 sdcdb>clear 100
30738 \newline
30739 sdcdb>clear foo.c:100
30740 \newline
30741 sdcdb>clear funcfoo
30742 \newline
30743 sdcdb>clear foo.c:funcfoo
30744 \end_layout
30745
30746 \begin_layout Subsubsection*
30747 continue
30748 \end_layout
30749
30750 \begin_layout Standard
30751 Continue program being debugged, after breakpoint.
30752 \end_layout
30753
30754 \begin_layout Subsubsection*
30755 finish
30756 \end_layout
30757
30758 \begin_layout Standard
30759 Execute till the end of the current function.
30760 \end_layout
30761
30762 \begin_layout Subsubsection*
30763 delete [n]
30764 \end_layout
30765
30766 \begin_layout Standard
30767 Delete breakpoint number 'n'.
30768  If used without any option clear ALL user defined break points.
30769 \end_layout
30770
30771 \begin_layout Subsubsection*
30772 info [break | stack | frame | registers ]
30773 \end_layout
30774
30775 \begin_layout Itemize
30776 info break - list all breakpoints
30777 \end_layout
30778
30779 \begin_layout Itemize
30780 info stack - show the function call stack.
30781 \end_layout
30782
30783 \begin_layout Itemize
30784 info frame - show information about the current execution frame.
30785 \end_layout
30786
30787 \begin_layout Itemize
30788 info registers - show content of all registers.
30789 \end_layout
30790
30791 \begin_layout Subsubsection*
30792 step
30793 \end_layout
30794
30795 \begin_layout Standard
30796 Step program until it reaches a different source line.
30797  Note: pressing <return> repeats the last command.
30798 \end_layout
30799
30800 \begin_layout Subsubsection*
30801 next
30802 \end_layout
30803
30804 \begin_layout Standard
30805 Step program, proceeding through subroutine calls.
30806 \end_layout
30807
30808 \begin_layout Subsubsection*
30809 run
30810 \end_layout
30811
30812 \begin_layout Standard
30813 Start debugged program.
30814 \end_layout
30815
30816 \begin_layout Subsubsection*
30817 ptype variable 
30818 \end_layout
30819
30820 \begin_layout Standard
30821 Print type information of the variable.
30822 \end_layout
30823
30824 \begin_layout Subsubsection*
30825 print variable
30826 \end_layout
30827
30828 \begin_layout Standard
30829 print value of variable.
30830 \end_layout
30831
30832 \begin_layout Subsubsection*
30833 file filename
30834 \end_layout
30835
30836 \begin_layout Standard
30837 load the given file name.
30838  Note this is an alternate method of loading file for debugging.
30839 \end_layout
30840
30841 \begin_layout Subsubsection*
30842 frame
30843 \end_layout
30844
30845 \begin_layout Standard
30846 print information about current frame.
30847 \end_layout
30848
30849 \begin_layout Subsubsection*
30850 set srcmode
30851 \end_layout
30852
30853 \begin_layout Standard
30854 Toggle between C source & assembly source.
30855 \end_layout
30856
30857 \begin_layout Subsubsection*
30858 ! simulator command
30859 \end_layout
30860
30861 \begin_layout Standard
30862 Send the string following '!' to the simulator, the simulator response is
30863  displayed.
30864  Note the debugger does not interpret the command being sent to the simulator,
30865  so if a command like 'go' is sent the debugger can loose its execution
30866  context and may display incorrect values.
30867 \end_layout
30868
30869 \begin_layout Subsubsection*
30870 quit
30871 \end_layout
30872
30873 \begin_layout Standard
30874 "Watch me now.
30875  Iam going Down.
30876  My name is Bobby Brown"
30877 \end_layout
30878
30879 \begin_layout Subsection
30880 Interfacing SDCDB with DDD
30881 \end_layout
30882
30883 \begin_layout Standard
30884 \begin_inset Note Note
30885 status collapsed
30886
30887 \begin_layout Standard
30888 The screenshot was converted from png to eps with: 
30889 \begin_inset Quotes sld
30890 \end_inset
30891
30892 bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps
30893 \begin_inset Quotes srd
30894 \end_inset
30895
30896  which produces a pretty compact eps file which is free from compression
30897  artifacts.
30898 \end_layout
30899
30900 \begin_layout Standard
30901 The screenshot was included in sdccman.lyx cvs version 1.120 but later removed
30902  as this broke the build system on Sourceforge (pdf-file was broken.
30903  pdflatex does not accept eps files).
30904 \end_layout
30905
30906 \end_inset
30907
30908
30909 \end_layout
30910
30911 \begin_layout Standard
30912 The 
30913 \emph on
30914 p
30915 \emph default
30916 ortable 
30917 \emph on
30918 n
30919 \emph default
30920 etwork 
30921 \emph on
30922 g
30923 \emph default
30924 raphics File 
30925 \size footnotesize
30926
30927 \begin_inset LatexCommand url
30928 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/doc/figures/ddd_example.png"
30929
30930 \end_inset
30931
30932
30933 \size default
30934  shows a screenshot of a debugging session with DDD
30935 \begin_inset LatexCommand index
30936 name "DDD (debugger)"
30937
30938 \end_inset
30939
30940  (Unix only) on a simulated 8032.
30941  The debugging session might not run as smoothly as the screenshot suggests.
30942  The debugger allows setting of breakpoints, displaying and changing variables,
30943  single stepping through C and assembler code.
30944  
30945 \newline
30946 The source was compiled with 
30947 \family sans
30948 \series bold
30949
30950 \newline
30951
30952 \newline
30953 sdcc -
30954 \family default
30955 \series default
30956
30957 \begin_inset ERT
30958 status collapsed
30959
30960 \begin_layout Standard
30961
30962
30963 \backslash
30964 /
30965 \end_layout
30966
30967 \end_inset
30968
30969
30970 \family sans
30971 \series bold
30972 -debug ddd_example.c
30973 \family default
30974 \series default
30975  
30976 \family sans
30977 \series bold
30978
30979 \newline
30980
30981 \family default
30982 \series default
30983
30984 \newline
30985 and DDD was invoked with 
30986 \family sans
30987 \series bold
30988
30989 \newline
30990
30991 \newline
30992 ddd -debugger "sdcdb -cpu 8032 ddd_example"
30993 \end_layout
30994
30995 \begin_layout Standard
30996 \begin_inset Note Note
30997 status open
30998
30999 \begin_layout Standard
31000 Check that the double quotes or an apostrophe within the command line survive
31001  the LyX tool chain.
31002  Previously the apostrophes got slanted in the PDF output so a cut and paste
31003  did not work.
31004 \end_layout
31005
31006 \end_inset
31007
31008
31009 \end_layout
31010
31011 \begin_layout Subsection
31012 Interfacing SDCDB with XEmacs
31013 \begin_inset LatexCommand index
31014 name "XEmacs"
31015
31016 \end_inset
31017
31018
31019 \begin_inset LatexCommand index
31020 name "Emacs"
31021
31022 \end_inset
31023
31024
31025 \end_layout
31026
31027 \begin_layout Standard
31028 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
31029  sdcdb.el and sdcdbsrc.el.
31030  These two files can be found in the $(prefix)/bin directory after the installat
31031 ion is complete.
31032  These files need to be loaded into XEmacs for the interface to work.
31033  This can be done at XEmacs startup time by inserting the following into
31034  your '.xemacs' file (which can be found in your HOME directory): 
31035 \newline
31036
31037 \newline
31038
31039 \family typewriter
31040 (load-file sdcdbsrc.el)
31041 \family default
31042  
31043 \newline
31044
31045 \newline
31046 .xemacs is a lisp file so the () around the command is REQUIRED.
31047  The files can also be loaded dynamically while XEmacs is running, set the
31048  environment variable 'EMACSLOADPATH' to the installation bin directory
31049  (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
31050  To start the interface enter the following command: 
31051 \newline
31052
31053 \newline
31054
31055 \family sans
31056 \series bold
31057 ESC-x sdcdbsrc
31058 \family default
31059 \series default
31060
31061 \newline
31062
31063 \newline
31064 You will prompted to enter the file name to be debugged.
31065  
31066 \newline
31067
31068 \newline
31069 The command line options that are passed to the simulator directly are
31070  bound to default values in the file sdcdbsrc.el.
31071  The variables are listed below, these values maybe changed as required.
31072 \end_layout
31073
31074 \begin_layout Itemize
31075 sdcdbsrc-cpu-type '51
31076 \end_layout
31077
31078 \begin_layout Itemize
31079 sdcdbsrc-frequency '11059200
31080 \end_layout
31081
31082 \begin_layout Itemize
31083 sdcdbsrc-serial nil
31084 \end_layout
31085
31086 \begin_layout Standard
31087 The following is a list of key mapping for the debugger interface.
31088 \end_layout
31089
31090 \begin_layout Standard
31091 \InsetSpace ~
31092
31093 \family typewriter
31094
31095 \newline
31096 ;;\InsetSpace ~
31097 Current Listing :: 
31098 \newline
31099 ;;key\InsetSpace ~
31100 \InsetSpace ~
31101 \InsetSpace ~
31102 \InsetSpace ~
31103 \InsetSpace ~
31104 \InsetSpace ~
31105 \InsetSpace ~
31106 \InsetSpace ~
31107 \InsetSpace ~
31108 \InsetSpace ~
31109 \InsetSpace ~
31110 \InsetSpace ~
31111 \InsetSpace ~
31112 \InsetSpace ~
31113 binding\InsetSpace ~
31114 \InsetSpace ~
31115 \InsetSpace ~
31116 \InsetSpace ~
31117 \InsetSpace ~
31118 \InsetSpace ~
31119 \InsetSpace ~
31120 \InsetSpace ~
31121 \InsetSpace ~
31122 \InsetSpace ~
31123 \InsetSpace ~
31124 \InsetSpace ~
31125 \InsetSpace ~
31126 \InsetSpace ~
31127 \InsetSpace ~
31128 \InsetSpace ~
31129 \InsetSpace ~
31130 \InsetSpace ~
31131 \InsetSpace ~
31132 \InsetSpace ~
31133 \InsetSpace ~
31134 \InsetSpace ~
31135 Comment 
31136 \newline
31137 ;;---\InsetSpace ~
31138 \InsetSpace ~
31139 \InsetSpace ~
31140 \InsetSpace ~
31141 \InsetSpace ~
31142 \InsetSpace ~
31143 \InsetSpace ~
31144 \InsetSpace ~
31145 \InsetSpace ~
31146 \InsetSpace ~
31147 \InsetSpace ~
31148 \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 \InsetSpace ~
31171 \InsetSpace ~
31172 \InsetSpace ~
31173 -------
31174 \newline
31175 ;; 
31176 \newline
31177 ;;\InsetSpace ~
31178 n\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 sdcdb-next-fro
31194 m-src\InsetSpace ~
31195 \InsetSpace ~
31196 \InsetSpace ~
31197 \InsetSpace ~
31198 \InsetSpace ~
31199 \InsetSpace ~
31200 \InsetSpace ~
31201 \InsetSpace ~
31202 \InsetSpace ~
31203 \InsetSpace ~
31204 SDCDB next command 
31205 \newline
31206 ;;\InsetSpace ~
31207 b\InsetSpace ~
31208 \InsetSpace ~
31209 \InsetSpace ~
31210 \InsetSpace ~
31211 \InsetSpace ~
31212 \InsetSpace ~
31213 \InsetSpace ~
31214 \InsetSpace ~
31215 \InsetSpace ~
31216 \InsetSpace ~
31217 \InsetSpace ~
31218 \InsetSpace ~
31219 \InsetSpace ~
31220 \InsetSpace ~
31221 \InsetSpace ~
31222 sdcdb-back-from-src\InsetSpace ~
31223 \InsetSpace ~
31224 \InsetSpace ~
31225 \InsetSpace ~
31226 \InsetSpace ~
31227 \InsetSpace ~
31228 \InsetSpace ~
31229 \InsetSpace ~
31230 \InsetSpace ~
31231 \InsetSpace ~
31232 SDCDB back command 
31233 \newline
31234 ;;\InsetSpace ~
31235 c\InsetSpace ~
31236 \InsetSpace ~
31237 \InsetSpace ~
31238 \InsetSpace ~
31239 \InsetSpace ~
31240 \InsetSpace ~
31241 \InsetSpace ~
31242 \InsetSpace ~
31243 \InsetSpace ~
31244 \InsetSpace ~
31245 \InsetSpace ~
31246 \InsetSpace ~
31247 \InsetSpace ~
31248 \InsetSpace ~
31249 \InsetSpace ~
31250 sdcdb-cont-f
31251 rom-src\InsetSpace ~
31252 \InsetSpace ~
31253 \InsetSpace ~
31254 \InsetSpace ~
31255 \InsetSpace ~
31256 \InsetSpace ~
31257 \InsetSpace ~
31258 \InsetSpace ~
31259 \InsetSpace ~
31260 \InsetSpace ~
31261 SDCDB continue command
31262 \newline
31263 ;;\InsetSpace ~
31264 s\InsetSpace ~
31265 \InsetSpace ~
31266 \InsetSpace ~
31267 \InsetSpace ~
31268 \InsetSpace ~
31269 \InsetSpace ~
31270 \InsetSpace ~
31271 \InsetSpace ~
31272 \InsetSpace ~
31273 \InsetSpace ~
31274 \InsetSpace ~
31275 \InsetSpace ~
31276 \InsetSpace ~
31277 \InsetSpace ~
31278 \InsetSpace ~
31279 sdcdb-step-from-src\InsetSpace ~
31280 \InsetSpace ~
31281 \InsetSpace ~
31282 \InsetSpace ~
31283 \InsetSpace ~
31284 \InsetSpace ~
31285 \InsetSpace ~
31286 \InsetSpace ~
31287 \InsetSpace ~
31288 \InsetSpace ~
31289 SDCDB step command 
31290 \newline
31291 ;;\InsetSpace ~
31292 ?\InsetSpace ~
31293 \InsetSpace ~
31294 \InsetSpace ~
31295 \InsetSpace ~
31296 \InsetSpace ~
31297 \InsetSpace ~
31298 \InsetSpace ~
31299 \InsetSpace ~
31300 \InsetSpace ~
31301 \InsetSpace ~
31302 \InsetSpace ~
31303 \InsetSpace ~
31304 \InsetSpace ~
31305 \InsetSpace ~
31306 \InsetSpace ~
31307 sdcdb-w
31308 hatis-c-sexp\InsetSpace ~
31309 \InsetSpace ~
31310 \InsetSpace ~
31311 \InsetSpace ~
31312 \InsetSpace ~
31313 \InsetSpace ~
31314 \InsetSpace ~
31315 \InsetSpace ~
31316 \InsetSpace ~
31317 \InsetSpace ~
31318 SDCDB ptypecommand for data at 
31319 \newline
31320 ;;\InsetSpace ~
31321 \InsetSpace ~
31322 \InsetSpace ~
31323 \InsetSpace ~
31324 \InsetSpace ~
31325 \InsetSpace ~
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 \InsetSpace ~
31343 \InsetSpace ~
31344 \InsetSpace ~
31345 \InsetSpace ~
31346 \InsetSpace ~
31347 \InsetSpace ~
31348 \InsetSpace ~
31349 \InsetSpace ~
31350 \InsetSpace ~
31351 \InsetSpace ~
31352 \InsetSpace ~
31353 \InsetSpace ~
31354 \InsetSpace ~
31355 \InsetSpace ~
31356 \InsetSpace ~
31357 \InsetSpace ~
31358 \InsetSpace ~
31359 \InsetSpace ~
31360 \InsetSpace ~
31361 \InsetSpace ~
31362 \InsetSpace ~
31363 \InsetSpace ~
31364 \InsetSpace ~
31365 \InsetSpace ~
31366 \InsetSpace ~
31367 buffer point 
31368 \newline
31369 ;;\InsetSpace ~
31370 x\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 sdcdbsrc-delete\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 SDCD
31400 B Delete all breakpoints if no arg 
31401 \newline
31402 ;;\InsetSpace ~
31403 \InsetSpace ~
31404 \InsetSpace ~
31405 \InsetSpace ~
31406 \InsetSpace ~
31407 \InsetSpace ~
31408 \InsetSpace ~
31409 \InsetSpace ~
31410 \InsetSpace ~
31411 \InsetSpace ~
31412 \InsetSpace ~
31413 \InsetSpace ~
31414 \InsetSpace ~
31415 \InsetSpace ~
31416 \InsetSpace ~
31417 \InsetSpace ~
31418 \InsetSpace ~
31419 \InsetSpace ~
31420 \InsetSpace ~
31421 \InsetSpace ~
31422 \InsetSpace ~
31423 \InsetSpace ~
31424 \InsetSpace ~
31425 \InsetSpace ~
31426 \InsetSpace ~
31427 \InsetSpace ~
31428 \InsetSpace ~
31429 \InsetSpace ~
31430 \InsetSpace ~
31431 \InsetSpace ~
31432 \InsetSpace ~
31433 \InsetSpace ~
31434 \InsetSpace ~
31435 \InsetSpace ~
31436 \InsetSpace ~
31437 \InsetSpace ~
31438 \InsetSpace ~
31439 \InsetSpace ~
31440 \InsetSpace ~
31441 \InsetSpace ~
31442 \InsetSpace ~
31443 \InsetSpace ~
31444 \InsetSpace ~
31445 \InsetSpace ~
31446 \InsetSpace ~
31447 \InsetSpace ~
31448 \InsetSpace ~
31449 given or delete arg (C-u arg x) 
31450 \newline
31451 ;;\InsetSpace ~
31452 m\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 sdcdbsrc
31468 -frame\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 SDCDB Display current frame if no arg, 
31484 \newline
31485 ;;\InsetSpace ~
31486 \InsetSpace ~
31487 \InsetSpace ~
31488 \InsetSpace ~
31489 \InsetSpace ~
31490 \InsetSpace ~
31491 \InsetSpace ~
31492 \InsetSpace ~
31493 \InsetSpace ~
31494 \InsetSpace ~
31495 \InsetSpace ~
31496 \InsetSpace ~
31497 \InsetSpace ~
31498 \InsetSpace ~
31499 \InsetSpace ~
31500 \InsetSpace ~
31501 \InsetSpace ~
31502 \InsetSpace ~
31503 \InsetSpace ~
31504 \InsetSpace ~
31505 \InsetSpace ~
31506 \InsetSpace ~
31507 \InsetSpace ~
31508 \InsetSpace ~
31509 \InsetSpace ~
31510 \InsetSpace ~
31511 \InsetSpace ~
31512 \InsetSpace ~
31513 \InsetSpace ~
31514 \InsetSpace ~
31515 \InsetSpace ~
31516 \InsetSpace ~
31517 \InsetSpace ~
31518 \InsetSpace ~
31519 \InsetSpace ~
31520 \InsetSpace ~
31521 \InsetSpace ~
31522 \InsetSpace ~
31523 \InsetSpace ~
31524 \InsetSpace ~
31525 \InsetSpace ~
31526 \InsetSpace ~
31527 \InsetSpace ~
31528 \InsetSpace ~
31529 \InsetSpace ~
31530 \InsetSpace ~
31531 \InsetSpace ~
31532 given or display frame arg
31533  
31534 \newline
31535 ;;\InsetSpace ~
31536 \InsetSpace ~
31537 \InsetSpace ~
31538 \InsetSpace ~
31539 \InsetSpace ~
31540 \InsetSpace ~
31541 \InsetSpace ~
31542 \InsetSpace ~
31543 \InsetSpace ~
31544 \InsetSpace ~
31545 \InsetSpace ~
31546 \InsetSpace ~
31547 \InsetSpace ~
31548 \InsetSpace ~
31549 \InsetSpace ~
31550 \InsetSpace ~
31551 \InsetSpace ~
31552 \InsetSpace ~
31553 \InsetSpace ~
31554 \InsetSpace ~
31555 \InsetSpace ~
31556 \InsetSpace ~
31557 \InsetSpace ~
31558 \InsetSpace ~
31559 \InsetSpace ~
31560 \InsetSpace ~
31561 \InsetSpace ~
31562 \InsetSpace ~
31563 \InsetSpace ~
31564 \InsetSpace ~
31565 \InsetSpace ~
31566 \InsetSpace ~
31567 \InsetSpace ~
31568 \InsetSpace ~
31569 \InsetSpace ~
31570 \InsetSpace ~
31571 \InsetSpace ~
31572 \InsetSpace ~
31573 \InsetSpace ~
31574 \InsetSpace ~
31575 \InsetSpace ~
31576 \InsetSpace ~
31577 \InsetSpace ~
31578 \InsetSpace ~
31579 \InsetSpace ~
31580 \InsetSpace ~
31581 \InsetSpace ~
31582 buffer point 
31583 \newline
31584 ;;\InsetSpace ~
31585 !\InsetSpace ~
31586 \InsetSpace ~
31587 \InsetSpace ~
31588 \InsetSpace ~
31589 \InsetSpace ~
31590 \InsetSpace ~
31591 \InsetSpace ~
31592 \InsetSpace ~
31593 \InsetSpace ~
31594 \InsetSpace ~
31595 \InsetSpace ~
31596 \InsetSpace ~
31597 \InsetSpace ~
31598 \InsetSpace ~
31599 \InsetSpace ~
31600 sdcdbsrc-goto-sdcdb\InsetSpace ~
31601 \InsetSpace ~
31602 \InsetSpace ~
31603 \InsetSpace ~
31604 \InsetSpace ~
31605 \InsetSpace ~
31606 \InsetSpace ~
31607 \InsetSpace ~
31608 \InsetSpace ~
31609 \InsetSpace ~
31610 Goto the SDCDB output buffer 
31611 \newline
31612 ;;\InsetSpace ~
31613 p\InsetSpace ~
31614 \InsetSpace ~
31615 \InsetSpace ~
31616 \InsetSpace ~
31617 \InsetSpace ~
31618 \InsetSpace ~
31619 \InsetSpace ~
31620 \InsetSpace ~
31621 \InsetSpace ~
31622 \InsetSpace ~
31623 \InsetSpace ~
31624 \InsetSpace ~
31625 \InsetSpace ~
31626 \InsetSpace ~
31627 \InsetSpace ~
31628 sdcdb-prin
31629 t-c-sexp\InsetSpace ~
31630 \InsetSpace ~
31631 \InsetSpace ~
31632 \InsetSpace ~
31633 \InsetSpace ~
31634 \InsetSpace ~
31635 \InsetSpace ~
31636 \InsetSpace ~
31637 \InsetSpace ~
31638 \InsetSpace ~
31639 \InsetSpace ~
31640 SDCDB print command for data at 
31641 \newline
31642 ;;\InsetSpace ~
31643 \InsetSpace ~
31644 \InsetSpace ~
31645 \InsetSpace ~
31646 \InsetSpace ~
31647 \InsetSpace ~
31648 \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 \InsetSpace ~
31664 \InsetSpace ~
31665 \InsetSpace ~
31666 \InsetSpace ~
31667 \InsetSpace ~
31668 \InsetSpace ~
31669 \InsetSpace ~
31670 \InsetSpace ~
31671 \InsetSpace ~
31672 \InsetSpace ~
31673 \InsetSpace ~
31674 \InsetSpace ~
31675 \InsetSpace ~
31676 \InsetSpace ~
31677 \InsetSpace ~
31678 \InsetSpace ~
31679 \InsetSpace ~
31680 \InsetSpace ~
31681 \InsetSpace ~
31682 \InsetSpace ~
31683 \InsetSpace ~
31684 \InsetSpace ~
31685 \InsetSpace ~
31686 \InsetSpace ~
31687 \InsetSpace ~
31688 \InsetSpace ~
31689 buffer point 
31690 \newline
31691 ;;\InsetSpace ~
31692 g\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 sdcdbsrc-goto-sdcdb\InsetSpace ~
31708 \InsetSpace ~
31709 \InsetSpace ~
31710 \InsetSpace ~
31711 \InsetSpace ~
31712 \InsetSpace ~
31713 \InsetSpace ~
31714 \InsetSpace ~
31715 \InsetSpace ~
31716 \InsetSpace ~
31717 Got
31718 o the SDCDB output buffer 
31719 \newline
31720 ;;\InsetSpace ~
31721 t\InsetSpace ~
31722 \InsetSpace ~
31723 \InsetSpace ~
31724 \InsetSpace ~
31725 \InsetSpace ~
31726 \InsetSpace ~
31727 \InsetSpace ~
31728 \InsetSpace ~
31729 \InsetSpace ~
31730 \InsetSpace ~
31731 \InsetSpace ~
31732 \InsetSpace ~
31733 \InsetSpace ~
31734 \InsetSpace ~
31735 \InsetSpace ~
31736 sdcdbsrc-mode\InsetSpace ~
31737 \InsetSpace ~
31738 \InsetSpace ~
31739 \InsetSpace ~
31740 \InsetSpace ~
31741 \InsetSpace ~
31742 \InsetSpace ~
31743 \InsetSpace ~
31744 \InsetSpace ~
31745 \InsetSpace ~
31746 \InsetSpace ~
31747 \InsetSpace ~
31748 \InsetSpace ~
31749 \InsetSpace ~
31750 \InsetSpace ~
31751 \InsetSpace ~
31752 Toggles Sdcdbsrc mode (turns it
31753  off) 
31754 \newline
31755 ;; 
31756 \newline
31757 ;;\InsetSpace ~
31758 C-c\InsetSpace ~
31759 C-f\InsetSpace ~
31760 \InsetSpace ~
31761 \InsetSpace ~
31762 \InsetSpace ~
31763 \InsetSpace ~
31764 \InsetSpace ~
31765 \InsetSpace ~
31766 \InsetSpace ~
31767 \InsetSpace ~
31768 sdcdb-finish-from-src\InsetSpace ~
31769 \InsetSpace ~
31770 \InsetSpace ~
31771 \InsetSpace ~
31772 \InsetSpace ~
31773 \InsetSpace ~
31774 \InsetSpace ~
31775 \InsetSpace ~
31776 SDCDB finish command 
31777 \newline
31778 ;; 
31779 \newline
31780 ;;\InsetSpace ~
31781 C-x\InsetSpace ~
31782 SPC\InsetSpace ~
31783 \InsetSpace ~
31784 \InsetSpace ~
31785 \InsetSpace ~
31786 \InsetSpace ~
31787 \InsetSpace ~
31788 \InsetSpace ~
31789 \InsetSpace ~
31790 \InsetSpace ~
31791 sdcdb-brea
31792 k\InsetSpace ~
31793 \InsetSpace ~
31794 \InsetSpace ~
31795 \InsetSpace ~
31796 \InsetSpace ~
31797 \InsetSpace ~
31798 \InsetSpace ~
31799 \InsetSpace ~
31800 \InsetSpace ~
31801 \InsetSpace ~
31802 \InsetSpace ~
31803 \InsetSpace ~
31804 \InsetSpace ~
31805 \InsetSpace ~
31806 \InsetSpace ~
31807 \InsetSpace ~
31808 \InsetSpace ~
31809 \InsetSpace ~
31810 Set break for line with point 
31811 \newline
31812 ;;\InsetSpace ~
31813 ESC\InsetSpace ~
31814 t\InsetSpace ~
31815 \InsetSpace ~
31816 \InsetSpace ~
31817 \InsetSpace ~
31818 \InsetSpace ~
31819 \InsetSpace ~
31820 \InsetSpace ~
31821 \InsetSpace ~
31822 \InsetSpace ~
31823 \InsetSpace ~
31824 \InsetSpace ~
31825 sdcdbsrc-mode\InsetSpace ~
31826 \InsetSpace ~
31827 \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 Toggle Sdcdbsrc mode 
31842 \newline
31843 ;;\InsetSpace ~
31844 ESC\InsetSpace ~
31845 m\InsetSpace ~
31846 \InsetSpace ~
31847 \InsetSpace ~
31848 \InsetSpace ~
31849 \InsetSpace ~
31850 \InsetSpace ~
31851 \InsetSpace ~
31852 \InsetSpace ~
31853 \InsetSpace ~
31854 \InsetSpace ~
31855 \InsetSpace ~
31856 sdc
31857 dbsrc-srcmode\InsetSpace ~
31858 \InsetSpace ~
31859 \InsetSpace ~
31860 \InsetSpace ~
31861 \InsetSpace ~
31862 \InsetSpace ~
31863 \InsetSpace ~
31864 \InsetSpace ~
31865 \InsetSpace ~
31866 \InsetSpace ~
31867 \InsetSpace ~
31868 \InsetSpace ~
31869 \InsetSpace ~
31870 Toggle list mode 
31871 \newline
31872 ;; 
31873 \newline
31874
31875 \family default
31876
31877 \newpage
31878
31879 \end_layout
31880
31881 \begin_layout Chapter
31882 TIPS
31883 \end_layout
31884
31885 \begin_layout Standard
31886 Here are a few guidelines that will help the compiler generate more efficient
31887  code, some of the tips are specific to this compiler others are generally
31888  good programming practice.
31889 \end_layout
31890
31891 \begin_layout Itemize
31892 Use the smallest data type to represent your data-value.
31893  If it is known in advance that the value is going to be less than 256 then
31894  use an 'unsigned char' instead of a 'short' or 'int'.
31895  Please note, that ANSI C requires both signed and unsigned chars to be
31896  promoted to 'signed int'
31897 \begin_inset LatexCommand index
31898 name "promotion to signed int"
31899
31900 \end_inset
31901
31902
31903 \begin_inset Marginal
31904 status collapsed
31905
31906 \begin_layout Standard
31907
31908 \series bold
31909 \InsetSpace ~
31910 !
31911 \end_layout
31912
31913 \end_inset
31914
31915  before doing any operation.
31916  This promotion
31917 \begin_inset LatexCommand index
31918 name "type promotion"
31919
31920 \end_inset
31921
31922
31923 \begin_inset LatexCommand label
31924 name "type promotion"
31925
31926 \end_inset
31927
31928  can be omitted, if the result is the same.
31929  The effect of the promotion rules together with the sign-extension is often
31930  surprising:
31931 \end_layout
31932
31933 \begin_deeper
31934 \begin_layout Verse
31935
31936 \family typewriter
31937 unsigned char uc = 0xfe;
31938 \newline
31939 if (uc * uc < 0) /* this is true! */
31940 \newline
31941 {
31942 \newline
31943 \InsetSpace ~
31944 \InsetSpace ~
31945 \InsetSpace ~
31946 \InsetSpace ~
31947 ....
31948 \newline
31949 }
31950 \end_layout
31951
31952 \begin_layout Standard
31953
31954 \family typewriter
31955 uc * uc
31956 \family default
31957  is evaluated as 
31958 \family typewriter
31959 (int) uc * (int) uc = (int) 0xfe * (int) 0xfe = (int) 0xfc04 = -1024
31960 \family default
31961 .
31962  
31963 \newline
31964 Another one:
31965 \end_layout
31966
31967 \begin_layout Verse
31968
31969 \family typewriter
31970 (unsigned char) -12 / (signed char) -3 = ...
31971 \end_layout
31972
31973 \begin_layout Standard
31974 No, the result is not 4:
31975 \end_layout
31976
31977 \begin_layout Verse
31978
31979 \family typewriter
31980 (int) (unsigned char) -12 / (int) (signed char) -3 =
31981 \newline
31982 (int) (unsigned char)
31983  0xf4 / (int) (signed char) 0xfd =
31984 \newline
31985 (int) 0x00f4 / (int) 0xfffd =
31986 \newline
31987 (int) 0x00f4
31988  / (int) 0xfffd =
31989 \newline
31990 (int) 244 / (int) -3 =
31991 \newline
31992 (int) -81 = (int) 0xffaf;
31993 \end_layout
31994
31995 \begin_layout Standard
31996 Don't complain, that gcc gives you a different result.
31997  gcc uses 32 bit ints, while SDCC uses 16 bit ints.
31998  Therefore the results are different.
31999 \newline
32000 From 
32001 \begin_inset Quotes sld
32002 \end_inset
32003
32004 comp.lang.c FAQ
32005 \begin_inset Quotes srd
32006 \end_inset
32007
32008 :
32009 \end_layout
32010
32011 \begin_layout Quote
32012
32013 \emph on
32014 If well-defined overflow characteristics are important and negative values
32015  are not, or if you want to steer clear of sign-extension problems when
32016  manipulating bits or bytes, use one of the corresponding unsigned types.
32017  (Beware when mixing signed and unsigned values in expressions, though.)
32018 \newline
32019 Although
32020  character types (especially unsigned char) can be used as "tiny" integers,
32021  doing so is sometimes more trouble than it's worth, due to unpredictable
32022  sign extension and increased code size.
32023 \end_layout
32024
32025 \end_deeper
32026 \begin_layout Itemize
32027 Use unsigned when it is known in advance that the value is not going to
32028  be negative.
32029  This helps especially if you are doing division or multiplication, bit-shifting
32030  or are using an array index.
32031 \end_layout
32032
32033 \begin_layout Itemize
32034 NEVER jump into a LOOP.
32035 \end_layout
32036
32037 \begin_layout Itemize
32038 Declare the variables to be local
32039 \begin_inset LatexCommand index
32040 name "local variables"
32041
32042 \end_inset
32043
32044  whenever possible, especially loop control variables (induction).
32045 \end_layout
32046
32047 \begin_layout Itemize
32048 Have a look at the assembly listing to get a 
32049 \begin_inset Quotes sld
32050 \end_inset
32051
32052 feeling
32053 \begin_inset Quotes srd
32054 \end_inset
32055
32056  for the code generation.
32057 \end_layout
32058
32059 \begin_layout Section
32060 Porting code from or to other compilers
32061 \begin_inset LatexCommand label
32062 name "sec:Porting-code-to-other-compilers"
32063
32064 \end_inset
32065
32066
32067 \end_layout
32068
32069 \begin_layout Itemize
32070 check whether endianness of the compilers differs and adapt where needed.
32071 \end_layout
32072
32073 \begin_layout Itemize
32074 check the device specific header files
32075 \begin_inset LatexCommand index
32076 name "Header files"
32077
32078 \end_inset
32079
32080
32081 \begin_inset LatexCommand index
32082 name "Include files"
32083
32084 \end_inset
32085
32086  for compiler specific syntax.
32087  Eventually include the file <compiler.h
32088 \begin_inset LatexCommand index
32089 name "compiler.h (include file)"
32090
32091 \end_inset
32092
32093
32094 \begin_inset LatexCommand url
32095 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/compiler.h?view=markup"
32096
32097 \end_inset
32098
32099  to allow using common header files.
32100  (see f.e.
32101  cc2510fx.h 
32102 \begin_inset LatexCommand url
32103 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/cc2510fx.h?view=markup"
32104
32105 \end_inset
32106
32107 ).
32108 \end_layout
32109
32110 \begin_layout Itemize
32111 check whether the startup code contains the correct initialization (watchdog,
32112  peripherals).
32113 \end_layout
32114
32115 \begin_layout Itemize
32116 check whether the sizes of short, int, long match.
32117 \end_layout
32118
32119 \begin_layout Itemize
32120 check if some 16 or 32 bit hardware registers require a specific addressing
32121  order (least significant or most significant byte first) and adapt if needed
32122  (
32123 \emph on
32124 first
32125 \emph default
32126  and 
32127 \emph on
32128 last
32129 \emph default
32130  relate to time and not to lower/upper memory location here, so this is
32131  
32132 \emph on
32133 not
32134 \emph default
32135  the same as endianness).
32136 \end_layout
32137
32138 \begin_layout Itemize
32139 check whether the keyword 
32140 \emph on
32141 volatile
32142 \emph default
32143  is used where needed.
32144  The compilers might differ in their optimization characteristics (as different
32145  versions of the same compiler might also use more clever optimizations
32146  this is good idea anyway).
32147  See section 
32148 \begin_inset LatexCommand ref
32149 reference "sub:Common-interrupt-pitfall-volatile"
32150
32151 \end_inset
32152
32153 .
32154 \end_layout
32155
32156 \begin_layout Itemize
32157 check that the compilers are not told to suppress warnings.
32158 \end_layout
32159
32160 \begin_layout Itemize
32161 check and convert compiler specific extensions (interrupts, memory areas,
32162  pragmas etc.).
32163 \end_layout
32164
32165 \begin_layout Itemize
32166 check for differences in type promotion.
32167  Especially check for math operations on 
32168 \family typewriter
32169 char
32170 \family default
32171  or 
32172 \family typewriter
32173 unsigned char
32174 \family default
32175  variables.
32176  For the sake of C99 compatibility SDCC will probably promote these to 
32177 \family typewriter
32178 int
32179 \family default
32180  more often than other compilers.
32181  Eventually insert explicit casts to 
32182 \family typewriter
32183 (char)
32184 \family default
32185  or 
32186 \family typewriter
32187 (unsigned char)
32188 \family default
32189 .
32190  Also check that the ~\InsetSpace ~
32191 operator
32192 \begin_inset LatexCommand index
32193 name "\\~\\/ Operator"
32194
32195 \end_inset
32196
32197  is not used on 
32198 \family typewriter
32199 bit
32200 \begin_inset LatexCommand index
32201 name "bit"
32202
32203 \end_inset
32204
32205
32206 \family default
32207  variables, use the !\InsetSpace ~
32208 operator instead.
32209  See sections 
32210 \begin_inset LatexCommand ref
32211 reference "type promotion"
32212
32213 \end_inset
32214
32215  and 
32216 \begin_inset LatexCommand ref
32217 reference "sec:Compatibility-with-previous"
32218
32219 \end_inset
32220
32221 .
32222 \end_layout
32223
32224 \begin_layout Itemize
32225 check the assembly code generated for interrupt routines (f.e.
32226  for calls to possibly non-reentrant library functions).
32227 \end_layout
32228
32229 \begin_layout Itemize
32230 check whether timing loops result in proper timing (or preferably consider
32231  a rewrite of the code with timer based delays instead).
32232 \end_layout
32233
32234 \begin_layout Itemize
32235 check for differences in printf parameters (some compilers push (va_arg
32236 \begin_inset LatexCommand index
32237 name "vararg, va\\_arg"
32238
32239 \end_inset
32240
32241 ) char variables as 
32242 \family typewriter
32243 int
32244 \family default
32245  others push them as 
32246 \family typewriter
32247 char
32248 \family default
32249 .
32250  See section 
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 resulting memory map
32261 \begin_inset LatexCommand index
32262 name "Memory map"
32263
32264 \end_inset
32265
32266 .
32267  Usage of different memory spaces: code, stack, data (for mcs51/ds390 additional
32268 ly idata, pdata, xdata).
32269  Eventually check if unexpected library functions are included.
32270 \end_layout
32271
32272 \begin_layout Section
32273 Tools
32274 \begin_inset LatexCommand index
32275 name "Tools"
32276
32277 \end_inset
32278
32279  included in the distribution
32280 \end_layout
32281
32282 \begin_layout Standard
32283 \align left
32284 \begin_inset Tabular
32285 <lyxtabular version="3" rows="12" columns="3">
32286 <features>
32287 <column alignment="left" valignment="top" leftline="true" width="0pt">
32288 <column alignment="left" valignment="top" leftline="true" width="0pt">
32289 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
32290 <row topline="true" bottomline="true">
32291 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32292 \begin_inset Text
32293
32294 \begin_layout Standard
32295
32296 \series bold
32297 Name
32298 \end_layout
32299
32300 \end_inset
32301 </cell>
32302 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32303 \begin_inset Text
32304
32305 \begin_layout Standard
32306
32307 \series bold
32308 Purpose
32309 \end_layout
32310
32311 \end_inset
32312 </cell>
32313 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32314 \begin_inset Text
32315
32316 \begin_layout Standard
32317
32318 \series bold
32319 Directory
32320 \end_layout
32321
32322 \end_inset
32323 </cell>
32324 </row>
32325 <row topline="true">
32326 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32327 \begin_inset Text
32328
32329 \begin_layout Standard
32330 uCsim
32331 \begin_inset LatexCommand index
32332 name "uCsim"
32333
32334 \end_inset
32335
32336
32337 \end_layout
32338
32339 \end_inset
32340 </cell>
32341 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32342 \begin_inset Text
32343
32344 \begin_layout Standard
32345 Simulator for various architectures
32346 \end_layout
32347
32348 \end_inset
32349 </cell>
32350 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32351 \begin_inset Text
32352
32353 \begin_layout Standard
32354 sdcc/sim/ucsim
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 keil2sdcc.pl
32366 \end_layout
32367
32368 \end_inset
32369 </cell>
32370 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32371 \begin_inset Text
32372
32373 \begin_layout Standard
32374 header file
32375 \begin_inset LatexCommand index
32376 name "Header files"
32377
32378 \end_inset
32379
32380
32381 \begin_inset LatexCommand index
32382 name "Include files"
32383
32384 \end_inset
32385
32386  conversion
32387 \end_layout
32388
32389 \end_inset
32390 </cell>
32391 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32392 \begin_inset Text
32393
32394 \begin_layout Standard
32395 sdcc/support/scripts
32396 \end_layout
32397
32398 \end_inset
32399 </cell>
32400 </row>
32401 <row topline="true">
32402 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32403 \begin_inset Text
32404
32405 \begin_layout Standard
32406 mh2h.c
32407 \end_layout
32408
32409 \end_inset
32410 </cell>
32411 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32412 \begin_inset Text
32413
32414 \begin_layout Standard
32415 header file conversion
32416 \end_layout
32417
32418 \end_inset
32419 </cell>
32420 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32421 \begin_inset Text
32422
32423 \begin_layout Standard
32424 sdcc/support/scripts
32425 \end_layout
32426
32427 \end_inset
32428 </cell>
32429 </row>
32430 <row topline="true">
32431 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32432 \begin_inset Text
32433
32434 \begin_layout Standard
32435 as-gbz80
32436 \end_layout
32437
32438 \end_inset
32439 </cell>
32440 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32441 \begin_inset Text
32442
32443 \begin_layout Standard
32444 Assembler
32445 \end_layout
32446
32447 \end_inset
32448 </cell>
32449 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32450 \begin_inset Text
32451
32452 \begin_layout Standard
32453
32454 \family roman
32455 \series medium
32456 \shape up
32457 \size normal
32458 \emph off
32459 \bar no
32460 \noun off
32461 \color none
32462 sdcc/bin
32463 \end_layout
32464
32465 \end_inset
32466 </cell>
32467 </row>
32468 <row topline="true">
32469 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32470 \begin_inset Text
32471
32472 \begin_layout Standard
32473 as-z80
32474 \end_layout
32475
32476 \end_inset
32477 </cell>
32478 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32479 \begin_inset Text
32480
32481 \begin_layout Standard
32482 Assembler
32483 \end_layout
32484
32485 \end_inset
32486 </cell>
32487 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32488 \begin_inset Text
32489
32490 \begin_layout Standard
32491
32492 \family roman
32493 \series medium
32494 \shape up
32495 \size normal
32496 \emph off
32497 \bar no
32498 \noun off
32499 \color none
32500 sdcc/bin
32501 \end_layout
32502
32503 \end_inset
32504 </cell>
32505 </row>
32506 <row topline="true">
32507 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32508 \begin_inset Text
32509
32510 \begin_layout Standard
32511 asx8051
32512 \end_layout
32513
32514 \end_inset
32515 </cell>
32516 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32517 \begin_inset Text
32518
32519 \begin_layout Standard
32520 Assembler
32521 \end_layout
32522
32523 \end_inset
32524 </cell>
32525 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32526 \begin_inset Text
32527
32528 \begin_layout Standard
32529
32530 \family roman
32531 \series medium
32532 \shape up
32533 \size normal
32534 \emph off
32535 \bar no
32536 \noun off
32537 \color none
32538 sdcc/bin
32539 \end_layout
32540
32541 \end_inset
32542 </cell>
32543 </row>
32544 <row topline="true">
32545 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32546 \begin_inset Text
32547
32548 \begin_layout Standard
32549 SDCDB
32550 \end_layout
32551
32552 \end_inset
32553 </cell>
32554 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32555 \begin_inset Text
32556
32557 \begin_layout Standard
32558 Simulator
32559 \end_layout
32560
32561 \end_inset
32562 </cell>
32563 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32564 \begin_inset Text
32565
32566 \begin_layout Standard
32567
32568 \family roman
32569 \series medium
32570 \shape up
32571 \size normal
32572 \emph off
32573 \bar no
32574 \noun off
32575 \color none
32576 sdcc/bin
32577 \end_layout
32578
32579 \end_inset
32580 </cell>
32581 </row>
32582 <row topline="true">
32583 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32584 \begin_inset Text
32585
32586 \begin_layout Standard
32587 aslink
32588 \end_layout
32589
32590 \end_inset
32591 </cell>
32592 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32593 \begin_inset Text
32594
32595 \begin_layout Standard
32596 Linker
32597 \end_layout
32598
32599 \end_inset
32600 </cell>
32601 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32602 \begin_inset Text
32603
32604 \begin_layout Standard
32605
32606 \family roman
32607 \series medium
32608 \shape up
32609 \size normal
32610 \emph off
32611 \bar no
32612 \noun off
32613 \color none
32614 sdcc/bin
32615 \end_layout
32616
32617 \end_inset
32618 </cell>
32619 </row>
32620 <row topline="true">
32621 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32622 \begin_inset Text
32623
32624 \begin_layout Standard
32625 link-z80
32626 \end_layout
32627
32628 \end_inset
32629 </cell>
32630 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32631 \begin_inset Text
32632
32633 \begin_layout Standard
32634 Linker
32635 \end_layout
32636
32637 \end_inset
32638 </cell>
32639 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32640 \begin_inset Text
32641
32642 \begin_layout Standard
32643
32644 \family roman
32645 \series medium
32646 \shape up
32647 \size normal
32648 \emph off
32649 \bar no
32650 \noun off
32651 \color none
32652 sdcc/bin
32653 \end_layout
32654
32655 \end_inset
32656 </cell>
32657 </row>
32658 <row topline="true">
32659 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32660 \begin_inset Text
32661
32662 \begin_layout Standard
32663 link-gbz80
32664 \end_layout
32665
32666 \end_inset
32667 </cell>
32668 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32669 \begin_inset Text
32670
32671 \begin_layout Standard
32672 Linker
32673 \end_layout
32674
32675 \end_inset
32676 </cell>
32677 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32678 \begin_inset Text
32679
32680 \begin_layout Standard
32681
32682 \family roman
32683 \series medium
32684 \shape up
32685 \size normal
32686 \emph off
32687 \bar no
32688 \noun off
32689 \color none
32690 sdcc/bin
32691 \end_layout
32692
32693 \end_inset
32694 </cell>
32695 </row>
32696 <row topline="true" bottomline="true">
32697 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32698 \begin_inset Text
32699
32700 \begin_layout Standard
32701 packihx
32702 \end_layout
32703
32704 \end_inset
32705 </cell>
32706 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32707 \begin_inset Text
32708
32709 \begin_layout Standard
32710 Intel Hex packer 
32711 \begin_inset LatexCommand index
32712 name "packihx (tool)"
32713
32714 \end_inset
32715
32716
32717 \end_layout
32718
32719 \end_inset
32720 </cell>
32721 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32722 \begin_inset Text
32723
32724 \begin_layout Standard
32725
32726 \family roman
32727 \series medium
32728 \shape up
32729 \size normal
32730 \emph off
32731 \bar no
32732 \noun off
32733 \color none
32734 sdcc/bin
32735 \end_layout
32736
32737 \end_inset
32738 </cell>
32739 </row>
32740 </lyxtabular>
32741
32742 \end_inset
32743
32744
32745 \newline
32746
32747 \end_layout
32748
32749 \begin_layout Section
32750 Documentation
32751 \begin_inset LatexCommand index
32752 name "Documentation"
32753
32754 \end_inset
32755
32756  included in the distribution
32757 \end_layout
32758
32759 \begin_layout Standard
32760 \align left
32761 \begin_inset Tabular
32762 <lyxtabular version="3" rows="10" columns="2">
32763 <features>
32764 <column alignment="block" valignment="top" leftline="true" width="40col%">
32765 <column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
32766 <row topline="true" bottomline="true" endhead="true">
32767 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32768 \begin_inset Text
32769
32770 \begin_layout Standard
32771
32772 \series bold
32773 Subject / Title
32774 \end_layout
32775
32776 \end_inset
32777 </cell>
32778 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32779 \begin_inset Text
32780
32781 \begin_layout Standard
32782
32783 \series bold
32784 Filename / Where to get
32785 \end_layout
32786
32787 \end_inset
32788 </cell>
32789 </row>
32790 <row topline="true">
32791 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32792 \begin_inset Text
32793
32794 \begin_layout Standard
32795 SDCC Compiler User Guide
32796 \end_layout
32797
32798 \end_inset
32799 </cell>
32800 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32801 \begin_inset Text
32802
32803 \begin_layout Standard
32804 You're reading it right now 
32805 \emph on
32806 \InsetSpace ~
32807 \InsetSpace ~
32808 \InsetSpace ~
32809
32810 \hfill
32811 online at:
32812 \emph default
32813
32814 \newline
32815
32816 \begin_inset LatexCommand url
32817 target "http://sdcc.sourceforge.net/doc/sdccman.pdf"
32818
32819 \end_inset
32820
32821
32822 \end_layout
32823
32824 \end_inset
32825 </cell>
32826 </row>
32827 <row topline="true">
32828 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32829 \begin_inset Text
32830
32831 \begin_layout Standard
32832 Changelog of SDCC
32833 \end_layout
32834
32835 \end_inset
32836 </cell>
32837 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32838 \begin_inset Text
32839
32840 \begin_layout Standard
32841 sdcc/Changelog 
32842 \emph on
32843 \InsetSpace ~
32844 \InsetSpace ~
32845 \InsetSpace ~
32846
32847 \hfill
32848 online at:
32849 \emph default
32850
32851 \newline
32852
32853 \begin_inset LatexCommand url
32854 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog"
32855
32856 \end_inset
32857
32858
32859 \end_layout
32860
32861 \end_inset
32862 </cell>
32863 </row>
32864 <row topline="true">
32865 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32866 \begin_inset Text
32867
32868 \begin_layout Standard
32869 ASXXXX
32870 \begin_inset LatexCommand index
32871 name "asXXXX (as-gbz80, as-hc08, asx8051, as-z80)"
32872
32873 \end_inset
32874
32875
32876 \begin_inset LatexCommand index
32877 name "Assembler documentation"
32878
32879 \end_inset
32880
32881  Assemblers and
32882 \newline
32883 ASLINK
32884 \begin_inset LatexCommand index
32885 name "aslink"
32886
32887 \end_inset
32888
32889
32890 \begin_inset LatexCommand index
32891 name "Linker documentation"
32892
32893 \end_inset
32894
32895  Relocating Linker
32896 \end_layout
32897
32898 \end_inset
32899 </cell>
32900 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32901 \begin_inset Text
32902
32903 \begin_layout Standard
32904 sdcc/as/doc/asxhtm.html 
32905 \emph on
32906 \InsetSpace ~
32907 \InsetSpace ~
32908 \InsetSpace ~
32909
32910 \hfill
32911 online at:
32912 \emph default
32913
32914 \newline
32915
32916 \begin_inset LatexCommand url
32917 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html"
32918
32919 \end_inset
32920
32921
32922 \end_layout
32923
32924 \end_inset
32925 </cell>
32926 </row>
32927 <row topline="true">
32928 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32929 \begin_inset Text
32930
32931 \begin_layout Standard
32932 SDCC regression test
32933 \begin_inset LatexCommand index
32934 name "Regression test"
32935
32936 \end_inset
32937
32938
32939 \end_layout
32940
32941 \end_inset
32942 </cell>
32943 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32944 \begin_inset Text
32945
32946 \begin_layout Standard
32947 sdcc/doc/test_suite_spec.pdf 
32948 \emph on
32949 \InsetSpace ~
32950 \InsetSpace ~
32951 \InsetSpace ~
32952
32953 \hfill
32954 online at:
32955 \emph default
32956
32957 \newline
32958
32959 \begin_inset LatexCommand url
32960 target "http://sdcc.sourceforge.net/doc/test_suite_spec.pdf"
32961
32962 \end_inset
32963
32964
32965 \end_layout
32966
32967 \end_inset
32968 </cell>
32969 </row>
32970 <row topline="true">
32971 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32972 \begin_inset Text
32973
32974 \begin_layout Standard
32975 Various notes
32976 \end_layout
32977
32978 \end_inset
32979 </cell>
32980 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32981 \begin_inset Text
32982
32983 \begin_layout Standard
32984 sdcc/doc/* 
32985 \emph on
32986 \InsetSpace ~
32987 \InsetSpace ~
32988 \InsetSpace ~
32989
32990 \hfill
32991 online at:
32992 \emph default
32993
32994 \newline
32995
32996 \begin_inset LatexCommand url
32997 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/doc/"
32998
32999 \end_inset
33000
33001
33002 \end_layout
33003
33004 \end_inset
33005 </cell>
33006 </row>
33007 <row topline="true">
33008 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33009 \begin_inset Text
33010
33011 \begin_layout Standard
33012 Notes on debugging with SDCDB
33013 \begin_inset LatexCommand index
33014 name "SDCDB (debugger)"
33015
33016 \end_inset
33017
33018
33019 \end_layout
33020
33021 \end_inset
33022 </cell>
33023 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33024 \begin_inset Text
33025
33026 \begin_layout Standard
33027 sdcc/debugger/README 
33028 \emph on
33029 \InsetSpace ~
33030 \InsetSpace ~
33031 \InsetSpace ~
33032
33033 \hfill
33034 online at
33035 \emph default
33036 :
33037 \newline
33038
33039 \begin_inset LatexCommand url
33040 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README"
33041
33042 \end_inset
33043
33044
33045 \end_layout
33046
33047 \end_inset
33048 </cell>
33049 </row>
33050 <row topline="true">
33051 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33052 \begin_inset Text
33053
33054 \begin_layout Standard
33055 uCsim
33056 \begin_inset LatexCommand index
33057 name "uCsim"
33058
33059 \end_inset
33060
33061  Software simulator for microcontrollers
33062 \end_layout
33063
33064 \end_inset
33065 </cell>
33066 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33067 \begin_inset Text
33068
33069 \begin_layout Standard
33070
33071 \family roman
33072 \series medium
33073 \shape up
33074 \size normal
33075 \emph off
33076 \bar no
33077 \noun off
33078 \color none
33079 sdcc/sim/ucsim/doc
33080 \family default
33081 \series default
33082 \shape default
33083 \size default
33084 \emph default
33085 \bar default
33086 \noun default
33087 /index.html 
33088 \emph on
33089 \InsetSpace ~
33090 \InsetSpace ~
33091 \InsetSpace ~
33092
33093 \hfill
33094 online at:
33095 \emph default
33096
33097 \newline
33098
33099 \begin_inset LatexCommand url
33100 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html"
33101
33102 \end_inset
33103
33104
33105 \end_layout
33106
33107 \end_inset
33108 </cell>
33109 </row>
33110 <row topline="true">
33111 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33112 \begin_inset Text
33113
33114 \begin_layout Standard
33115 Temporary notes on the pic16
33116 \begin_inset LatexCommand index
33117 name "PIC16"
33118
33119 \end_inset
33120
33121  port
33122 \end_layout
33123
33124 \end_inset
33125 </cell>
33126 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33127 \begin_inset Text
33128
33129 \begin_layout Standard
33130 sdcc/src/pic16/NOTES 
33131 \emph on
33132 \InsetSpace ~
33133 \InsetSpace ~
33134 \InsetSpace ~
33135
33136 \hfill
33137 online at:
33138 \newline
33139
33140 \emph default
33141
33142 \begin_inset LatexCommand url
33143 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES"
33144
33145 \end_inset
33146
33147
33148 \end_layout
33149
33150 \end_inset
33151 </cell>
33152 </row>
33153 <row topline="true" bottomline="true">
33154 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33155 \begin_inset Text
33156
33157 \begin_layout Standard
33158 SDCC internal documentation (debugging file format)
33159 \end_layout
33160
33161 \end_inset
33162 </cell>
33163 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33164 \begin_inset Text
33165
33166 \begin_layout Standard
33167 sdcc/doc/
33168 \family roman
33169 \series medium
33170 \shape up
33171 \size normal
33172 \emph off
33173 \bar no
33174 \noun off
33175 \color none
33176 cdbfileformat.pd
33177 \family default
33178 \series default
33179 \shape default
33180 \size default
33181 \emph default
33182 \bar default
33183 \noun default
33184
33185 \emph on
33186 \InsetSpace ~
33187 \InsetSpace ~
33188 \InsetSpace ~
33189
33190 \hfill
33191 online at:
33192 \emph default
33193
33194 \newline
33195
33196 \begin_inset LatexCommand url
33197 target "http://sdcc.sourceforge.net/doc/cdbfileformat.pdf"
33198
33199 \end_inset
33200
33201
33202 \end_layout
33203
33204 \end_inset
33205 </cell>
33206 </row>
33207 </lyxtabular>
33208
33209 \end_inset
33210
33211
33212 \newline
33213
33214 \end_layout
33215
33216 \begin_layout Section
33217 Related open source tools
33218 \begin_inset LatexCommand label
33219 name "sec:Related-open-source-tools"
33220
33221 \end_inset
33222
33223
33224 \begin_inset LatexCommand index
33225 name "Related tools"
33226
33227 \end_inset
33228
33229
33230 \end_layout
33231
33232 \begin_layout Standard
33233 \align left
33234 \begin_inset Tabular
33235 <lyxtabular version="3" rows="16" columns="3">
33236 <features>
33237 <column alignment="left" valignment="top" leftline="true" width="0pt">
33238 <column alignment="block" valignment="top" leftline="true" width="30line%">
33239 <column alignment="left" valignment="top" leftline="true" rightline="true" width="40col%">
33240 <row topline="true" bottomline="true">
33241 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33242 \begin_inset Text
33243
33244 \begin_layout Standard
33245
33246 \series bold
33247 Name
33248 \end_layout
33249
33250 \end_inset
33251 </cell>
33252 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33253 \begin_inset Text
33254
33255 \begin_layout Standard
33256
33257 \series bold
33258 Purpose
33259 \end_layout
33260
33261 \end_inset
33262 </cell>
33263 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33264 \begin_inset Text
33265
33266 \begin_layout Standard
33267
33268 \series bold
33269 Where to get
33270 \end_layout
33271
33272 \end_inset
33273 </cell>
33274 </row>
33275 <row topline="true">
33276 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33277 \begin_inset Text
33278
33279 \begin_layout Standard
33280 gpsim
33281 \begin_inset LatexCommand index
33282 name "gpsim (pic simulator)"
33283
33284 \end_inset
33285
33286
33287 \end_layout
33288
33289 \end_inset
33290 </cell>
33291 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33292 \begin_inset Text
33293
33294 \begin_layout Standard
33295 PIC simulator
33296 \end_layout
33297
33298 \end_inset
33299 </cell>
33300 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33301 \begin_inset Text
33302
33303 \begin_layout Standard
33304 \begin_inset LatexCommand url
33305 target "http://www.dattalo.com/gnupic/gpsim.html"
33306
33307 \end_inset
33308
33309
33310 \end_layout
33311
33312 \end_inset
33313 </cell>
33314 </row>
33315 <row topline="true">
33316 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33317 \begin_inset Text
33318
33319 \begin_layout Standard
33320 gputils
33321 \begin_inset LatexCommand index
33322 name "gputils (pic tools)"
33323
33324 \end_inset
33325
33326
33327 \end_layout
33328
33329 \end_inset
33330 </cell>
33331 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33332 \begin_inset Text
33333
33334 \begin_layout Standard
33335 GNU PIC utilities
33336 \end_layout
33337
33338 \end_inset
33339 </cell>
33340 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33341 \begin_inset Text
33342
33343 \begin_layout Standard
33344 \begin_inset LatexCommand url
33345 target "http://sourceforge.net/projects/gputils"
33346
33347 \end_inset
33348
33349
33350 \end_layout
33351
33352 \end_inset
33353 </cell>
33354 </row>
33355 <row topline="true">
33356 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33357 \begin_inset Text
33358
33359 \begin_layout Standard
33360 flP5
33361 \end_layout
33362
33363 \end_inset
33364 </cell>
33365 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33366 \begin_inset Text
33367
33368 \begin_layout Standard
33369 PIC programmer
33370 \end_layout
33371
33372 \end_inset
33373 </cell>
33374 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33375 \begin_inset Text
33376
33377 \begin_layout Standard
33378 \begin_inset LatexCommand url
33379 target "http://freshmeat.net/projects/flp5/"
33380
33381 \end_inset
33382
33383
33384 \end_layout
33385
33386 \end_inset
33387 </cell>
33388 </row>
33389 <row topline="true">
33390 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33391 \begin_inset Text
33392
33393 \begin_layout Standard
33394 ec2drv/newcdb
33395 \end_layout
33396
33397 \end_inset
33398 </cell>
33399 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33400 \begin_inset Text
33401
33402 \begin_layout Standard
33403 Tools for Silicon Laboratories JTAG debug adapter, partly based on SDCDB
33404  (Unix only)
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://sourceforge.net/projects/ec2drv"
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 indent
33430 \begin_inset LatexCommand index
33431 name "indent (source formatting tool)"
33432
33433 \end_inset
33434
33435
33436 \end_layout
33437
33438 \end_inset
33439 </cell>
33440 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33441 \begin_inset Text
33442
33443 \begin_layout Standard
33444 Formats C source - Master of the white spaces
33445 \end_layout
33446
33447 \end_inset
33448 </cell>
33449 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33450 \begin_inset Text
33451
33452 \begin_layout Standard
33453 \begin_inset LatexCommand url
33454 target "http://directory.fsf.org/GNU/indent.html"
33455
33456 \end_inset
33457
33458
33459 \end_layout
33460
33461 \end_inset
33462 </cell>
33463 </row>
33464 <row topline="true">
33465 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33466 \begin_inset Text
33467
33468 \begin_layout Standard
33469 srecord
33470 \begin_inset LatexCommand index
33471 name "srecord (bin, hex, ... tool)"
33472
33473 \end_inset
33474
33475
33476 \end_layout
33477
33478 \end_inset
33479 </cell>
33480 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33481 \begin_inset Text
33482
33483 \begin_layout Standard
33484 Object file conversion, checksumming, ...
33485 \end_layout
33486
33487 \end_inset
33488 </cell>
33489 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33490 \begin_inset Text
33491
33492 \begin_layout Standard
33493 \begin_inset LatexCommand url
33494 target "http://sourceforge.net/projects/srecord"
33495
33496 \end_inset
33497
33498
33499 \end_layout
33500
33501 \end_inset
33502 </cell>
33503 </row>
33504 <row topline="true">
33505 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33506 \begin_inset Text
33507
33508 \begin_layout Standard
33509 objdump
33510 \begin_inset LatexCommand index
33511 name "objdump (tool)"
33512
33513 \end_inset
33514
33515
33516 \end_layout
33517
33518 \end_inset
33519 </cell>
33520 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33521 \begin_inset Text
33522
33523 \begin_layout Standard
33524 Object file conversion, ...
33525 \end_layout
33526
33527 \end_inset
33528 </cell>
33529 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33530 \begin_inset Text
33531
33532 \begin_layout Standard
33533 Part of binutils (should be there anyway)
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 cmon51
33545 \end_layout
33546
33547 \end_inset
33548 </cell>
33549 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33550 \begin_inset Text
33551
33552 \begin_layout Standard
33553 8051 monitor (hex up-/download, single step, disassemble)
33554 \end_layout
33555
33556 \end_inset
33557 </cell>
33558 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33559 \begin_inset Text
33560
33561 \begin_layout Standard
33562 \begin_inset LatexCommand url
33563 target "http://sourceforge.net/projects/cmon51"
33564
33565 \end_inset
33566
33567
33568 \end_layout
33569
33570 \end_inset
33571 </cell>
33572 </row>
33573 <row topline="true">
33574 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33575 \begin_inset Text
33576
33577 \begin_layout Standard
33578 doxygen
33579 \begin_inset LatexCommand index
33580 name "doxygen (source documentation tool)"
33581
33582 \end_inset
33583
33584
33585 \end_layout
33586
33587 \end_inset
33588 </cell>
33589 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33590 \begin_inset Text
33591
33592 \begin_layout Standard
33593 Source code documentation system
33594 \end_layout
33595
33596 \end_inset
33597 </cell>
33598 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33599 \begin_inset Text
33600
33601 \begin_layout Standard
33602 \begin_inset LatexCommand url
33603 target "http://www.doxygen.org"
33604
33605 \end_inset
33606
33607
33608 \end_layout
33609
33610 \end_inset
33611 </cell>
33612 </row>
33613 <row topline="true">
33614 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33615 \begin_inset Text
33616
33617 \begin_layout Standard
33618 kdevelop
33619 \end_layout
33620
33621 \end_inset
33622 </cell>
33623 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33624 \begin_inset Text
33625
33626 \begin_layout Standard
33627 IDE (has anyone tried integrating SDCC & SDCDB? Unix only)
33628 \end_layout
33629
33630 \end_inset
33631 </cell>
33632 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33633 \begin_inset Text
33634
33635 \begin_layout Standard
33636 \begin_inset LatexCommand url
33637 target "http://www.kdevelop.org"
33638
33639 \end_inset
33640
33641
33642 \end_layout
33643
33644 \end_inset
33645 </cell>
33646 </row>
33647 <row topline="true">
33648 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33649 \begin_inset Text
33650
33651 \begin_layout Standard
33652 paulmon
33653 \end_layout
33654
33655 \end_inset
33656 </cell>
33657 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33658 \begin_inset Text
33659
33660 \begin_layout Standard
33661 8051 monitor (hex up-/download, single step, disassemble)
33662 \end_layout
33663
33664 \end_inset
33665 </cell>
33666 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33667 \begin_inset Text
33668
33669 \begin_layout Standard
33670 \begin_inset LatexCommand url
33671 target "http://www.pjrc.com/tech/8051/paulmon2.html"
33672
33673 \end_inset
33674
33675
33676 \end_layout
33677
33678 \end_inset
33679 </cell>
33680 </row>
33681 <row topline="true">
33682 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33683 \begin_inset Text
33684
33685 \begin_layout Standard
33686 splint
33687 \begin_inset LatexCommand index
33688 name "splint (syntax checking tool)"
33689
33690 \end_inset
33691
33692
33693 \end_layout
33694
33695 \end_inset
33696 </cell>
33697 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33698 \begin_inset Text
33699
33700 \begin_layout Standard
33701 Statically checks c sources (see 
33702 \begin_inset LatexCommand ref
33703 reference "lyx:more-pedantic-SPLINT"
33704
33705 \end_inset
33706
33707 )
33708 \end_layout
33709
33710 \end_inset
33711 </cell>
33712 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33713 \begin_inset Text
33714
33715 \begin_layout Standard
33716 \begin_inset LatexCommand url
33717 target "http://www.splint.org"
33718
33719 \end_inset
33720
33721
33722 \end_layout
33723
33724 \end_inset
33725 </cell>
33726 </row>
33727 <row topline="true" bottomline="true">
33728 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33729 \begin_inset Text
33730
33731 \begin_layout Standard
33732 ddd
33733 \begin_inset LatexCommand index
33734 name "DDD (debugger)"
33735
33736 \end_inset
33737
33738
33739 \end_layout
33740
33741 \end_inset
33742 </cell>
33743 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33744 \begin_inset Text
33745
33746 \begin_layout Standard
33747 Debugger, serves nicely as GUI to SDCDB
33748 \begin_inset LatexCommand index
33749 name "SDCDB (debugger)"
33750
33751 \end_inset
33752
33753  (Unix only)
33754 \end_layout
33755
33756 \end_inset
33757 </cell>
33758 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33759 \begin_inset Text
33760
33761 \begin_layout Standard
33762 \begin_inset LatexCommand url
33763 target "http://www.gnu.org/software/ddd/"
33764
33765 \end_inset
33766
33767
33768 \end_layout
33769
33770 \end_inset
33771 </cell>
33772 </row>
33773 <row bottomline="true">
33774 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33775 \begin_inset Text
33776
33777 \begin_layout Standard
33778 d52
33779 \begin_inset LatexCommand index
33780 name "d52"
33781
33782 \end_inset
33783
33784
33785 \begin_inset LatexCommand index
33786 name "d52 (disassembler)"
33787
33788 \end_inset
33789
33790
33791 \end_layout
33792
33793 \end_inset
33794 </cell>
33795 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33796 \begin_inset Text
33797
33798 \begin_layout Standard
33799 Disassembler, can count instruction cycles
33800 \begin_inset LatexCommand index
33801 name "instruction cycles (count)"
33802
33803 \end_inset
33804
33805 , use with options -pnd
33806 \end_layout
33807
33808 \end_inset
33809 </cell>
33810 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33811 \begin_inset Text
33812
33813 \begin_layout Standard
33814 \begin_inset LatexCommand url
33815 target "http://www.8052.com/users/disasm/"
33816
33817 \end_inset
33818
33819
33820 \end_layout
33821
33822 \end_inset
33823 </cell>
33824 </row>
33825 <row bottomline="true">
33826 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33827 \begin_inset Text
33828
33829 \begin_layout Standard
33830 cmake
33831 \begin_inset LatexCommand index
33832 name "cmake"
33833
33834 \end_inset
33835
33836
33837 \end_layout
33838
33839 \end_inset
33840 </cell>
33841 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33842 \begin_inset Text
33843
33844 \begin_layout Standard
33845 Cross platform build system, generates Makefiles
33846 \begin_inset LatexCommand index
33847 name "Makefile"
33848
33849 \end_inset
33850
33851  and project workspaces
33852 \begin_inset LatexCommand index
33853 name "project workspace"
33854
33855 \end_inset
33856
33857
33858 \end_layout
33859
33860 \end_inset
33861 </cell>
33862 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33863 \begin_inset Text
33864
33865 \begin_layout Standard
33866 \begin_inset LatexCommand url
33867 target "http://www.cmake.org"
33868
33869 \end_inset
33870
33871  \InsetSpace ~
33872 \InsetSpace ~
33873 \InsetSpace ~
33874 \InsetSpace ~
33875 and a dedicated wiki entry: 
33876 \begin_inset LatexCommand url
33877 target "http://www.cmake.org/Wiki/CmakeSdcc"
33878
33879 \end_inset
33880
33881
33882 \end_layout
33883
33884 \end_inset
33885 </cell>
33886 </row>
33887 </lyxtabular>
33888
33889 \end_inset
33890
33891
33892 \newline
33893
33894 \end_layout
33895
33896 \begin_layout Section
33897 Related documentation / recommended reading
33898 \end_layout
33899
33900 \begin_layout Standard
33901 \align left
33902 \begin_inset Tabular
33903 <lyxtabular version="3" rows="7" columns="3">
33904 <features>
33905 <column alignment="left" valignment="top" leftline="true" width="0pt">
33906 <column alignment="left" valignment="top" leftline="true" width="0">
33907 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
33908 <row topline="true" bottomline="true">
33909 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33910 \begin_inset Text
33911
33912 \begin_layout Standard
33913
33914 \series bold
33915 Name
33916 \end_layout
33917
33918 \end_inset
33919 </cell>
33920 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33921 \begin_inset Text
33922
33923 \begin_layout Standard
33924
33925 \series bold
33926 Subject / Title
33927 \end_layout
33928
33929 \end_inset
33930 </cell>
33931 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33932 \begin_inset Text
33933
33934 \begin_layout Standard
33935
33936 \series bold
33937 Where to get
33938 \end_layout
33939
33940 \end_inset
33941 </cell>
33942 </row>
33943 <row topline="true">
33944 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33945 \begin_inset Text
33946
33947 \begin_layout Standard
33948
33949 \family roman
33950 \series medium
33951 \shape up
33952 \size normal
33953 \emph off
33954 \bar no
33955 \noun off
33956 \color none
33957 c-refcard.pdf
33958 \end_layout
33959
33960 \end_inset
33961 </cell>
33962 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33963 \begin_inset Text
33964
33965 \begin_layout Standard
33966 C Reference Card
33967 \begin_inset LatexCommand index
33968 name "C Reference card"
33969
33970 \end_inset
33971
33972 , 2 pages
33973 \end_layout
33974
33975 \end_inset
33976 </cell>
33977 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33978 \begin_inset Text
33979
33980 \begin_layout Standard
33981 \begin_inset LatexCommand url
33982 target "http://refcards.com/refcards/c/index.html"
33983
33984 \end_inset
33985
33986
33987 \end_layout
33988
33989 \end_inset
33990 </cell>
33991 </row>
33992 <row topline="true">
33993 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33994 \begin_inset Text
33995
33996 \begin_layout Standard
33997 c-faq
33998 \end_layout
33999
34000 \end_inset
34001 </cell>
34002 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34003 \begin_inset Text
34004
34005 \begin_layout Standard
34006 C-FAQ
34007 \begin_inset LatexCommand index
34008 name "C FAQ"
34009
34010 \end_inset
34011
34012
34013 \end_layout
34014
34015 \end_inset
34016 </cell>
34017 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34018 \begin_inset Text
34019
34020 \begin_layout Standard
34021 \begin_inset LatexCommand url
34022 target "http://www.c-faq.com"
34023
34024 \end_inset
34025
34026
34027 \end_layout
34028
34029 \end_inset
34030 </cell>
34031 </row>
34032 <row topline="true">
34033 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34034 \begin_inset Text
34035
34036 \begin_layout Standard
34037 ISO/IEC 9899:TC2
34038 \end_layout
34039
34040 \end_inset
34041 </cell>
34042 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34043 \begin_inset Text
34044
34045 \begin_layout Standard
34046 \begin_inset Quotes sld
34047 \end_inset
34048
34049 C-Standard
34050 \begin_inset Quotes srd
34051 \end_inset
34052
34053
34054 \end_layout
34055
34056 \end_inset
34057 </cell>
34058 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34059 \begin_inset Text
34060
34061 \begin_layout Standard
34062
34063 \size footnotesize
34064 \begin_inset LatexCommand url
34065 target "http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899"
34066
34067 \end_inset
34068
34069
34070 \end_layout
34071
34072 \end_inset
34073 </cell>
34074 </row>
34075 <row topline="true">
34076 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34077 \begin_inset Text
34078
34079 \begin_layout Standard
34080 ISO/IEC DTR 18037
34081 \end_layout
34082
34083 \end_inset
34084 </cell>
34085 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34086 \begin_inset Text
34087
34088 \begin_layout Standard
34089 \begin_inset Quotes sld
34090 \end_inset
34091
34092 Extensions for Embedded C
34093 \begin_inset Quotes srd
34094 \end_inset
34095
34096
34097 \end_layout
34098
34099 \end_inset
34100 </cell>
34101 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34102 \begin_inset Text
34103
34104 \begin_layout Standard
34105
34106 \size footnotesize
34107 \begin_inset LatexCommand url
34108 target "http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1021.pdf"
34109
34110 \end_inset
34111
34112
34113 \end_layout
34114
34115 \end_inset
34116 </cell>
34117 </row>
34118 <row topline="true">
34119 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34120 \begin_inset Text
34121
34122 \begin_layout Standard
34123
34124 \end_layout
34125
34126 \end_inset
34127 </cell>
34128 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34129 \begin_inset Text
34130
34131 \begin_layout Standard
34132 Latest datasheet of target CPU
34133 \end_layout
34134
34135 \end_inset
34136 </cell>
34137 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34138 \begin_inset Text
34139
34140 \begin_layout Standard
34141 vendor
34142 \end_layout
34143
34144 \end_inset
34145 </cell>
34146 </row>
34147 <row topline="true" bottomline="true">
34148 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34149 \begin_inset Text
34150
34151 \begin_layout Standard
34152
34153 \end_layout
34154
34155 \end_inset
34156 </cell>
34157 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34158 \begin_inset Text
34159
34160 \begin_layout Standard
34161 Revision history of datasheet
34162 \end_layout
34163
34164 \end_inset
34165 </cell>
34166 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34167 \begin_inset Text
34168
34169 \begin_layout Standard
34170 vendor
34171 \end_layout
34172
34173 \end_inset
34174 </cell>
34175 </row>
34176 </lyxtabular>
34177
34178 \end_inset
34179
34180
34181 \newline
34182
34183 \end_layout
34184
34185 \begin_layout Section
34186 Application notes specifically for SDCC
34187 \end_layout
34188
34189 \begin_layout Standard
34190 SDCC makes no claims about the completeness of this list and about up-to-datenes
34191 s or correctness of the application notes
34192 \begin_inset LatexCommand index
34193 name "Application notes"
34194
34195 \end_inset
34196
34197 .
34198 \end_layout
34199
34200 \begin_layout Standard
34201 \align left
34202
34203 \size footnotesize
34204 \begin_inset Tabular
34205 <lyxtabular version="3" rows="7" columns="3">
34206 <features>
34207 <column alignment="block" valignment="top" leftline="true" width="17col%">
34208 <column alignment="block" valignment="top" leftline="true" width="27col%">
34209 <column alignment="block" valignment="top" leftline="true" rightline="true" width="57col%">
34210 <row topline="true" bottomline="true">
34211 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34212 \begin_inset Text
34213
34214 \begin_layout Standard
34215
34216 \series bold
34217 \size footnotesize
34218 Vendor
34219 \end_layout
34220
34221 \end_inset
34222 </cell>
34223 <cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
34224 \begin_inset Text
34225
34226 \begin_layout Standard
34227
34228 \series bold
34229 \size footnotesize
34230 Subject / Title
34231 \end_layout
34232
34233 \end_inset
34234 </cell>
34235 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34236 \begin_inset Text
34237
34238 \begin_layout Standard
34239
34240 \series bold
34241 \size footnotesize
34242 Where to get
34243 \end_layout
34244
34245 \end_inset
34246 </cell>
34247 </row>
34248 <row topline="true">
34249 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34250 \begin_inset Text
34251
34252 \begin_layout Standard
34253
34254 \size footnotesize
34255 Maxim / Dallas
34256 \end_layout
34257
34258 \end_inset
34259 </cell>
34260 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34261 \begin_inset Text
34262
34263 \begin_layout Standard
34264
34265 \size footnotesize
34266 Using the SDCC Compiler for the DS80C400
34267 \begin_inset LatexCommand index
34268 name "DS80C400"
34269
34270 \end_inset
34271
34272
34273 \end_layout
34274
34275 \end_inset
34276 </cell>
34277 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34278 \begin_inset Text
34279
34280 \begin_layout Standard
34281
34282 \size footnotesize
34283 \begin_inset LatexCommand url
34284 target "http://pdfserv.maxim-ic.com/en/an/AN3346.pdf"
34285
34286 \end_inset
34287
34288
34289 \end_layout
34290
34291 \end_inset
34292 </cell>
34293 </row>
34294 <row topline="true">
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 Maxim / Dallas
34302 \end_layout
34303
34304 \end_inset
34305 </cell>
34306 <cell multicolumn="1" alignment="left" valignment="top" topline="true" leftline="true" usebox="none" width="30line%">
34307 \begin_inset Text
34308
34309 \begin_layout Standard
34310
34311 \size footnotesize
34312 Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450
34313 \begin_inset LatexCommand index
34314 name "DS89C4x0"
34315
34316 \end_inset
34317
34318  Family of Microcontrollers
34319 \end_layout
34320
34321 \end_inset
34322 </cell>
34323 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34324 \begin_inset Text
34325
34326 \begin_layout Standard
34327
34328 \size footnotesize
34329 \begin_inset LatexCommand url
34330 target "http://pdfserv.maxim-ic.com/en/an/AN3477.pdf"
34331
34332 \end_inset
34333
34334
34335 \end_layout
34336
34337 \end_inset
34338 </cell>
34339 </row>
34340 <row topline="true">
34341 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34342 \begin_inset Text
34343
34344 \begin_layout Standard
34345
34346 \size footnotesize
34347 Silicon Laboratories / Cygnal
34348 \end_layout
34349
34350 \end_inset
34351 </cell>
34352 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34353 \begin_inset Text
34354
34355 \begin_layout Standard
34356
34357 \size footnotesize
34358 Integrating SDCC 8051 Tools Into The Silicon Labs IDE
34359 \begin_inset LatexCommand index
34360 name "IDE"
34361
34362 \end_inset
34363
34364
34365 \end_layout
34366
34367 \end_inset
34368 </cell>
34369 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34370 \begin_inset Text
34371
34372 \begin_layout Standard
34373
34374 \size footnotesize
34375 \begin_inset LatexCommand url
34376 target "http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/en/an198.pdf"
34377
34378 \end_inset
34379
34380
34381 \end_layout
34382
34383 \end_inset
34384 </cell>
34385 </row>
34386 <row topline="true">
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 Ramtron / Goal Semiconductor
34394 \end_layout
34395
34396 \end_inset
34397 </cell>
34398 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34399 \begin_inset Text
34400
34401 \begin_layout Standard
34402
34403 \size footnotesize
34404 Interfacing SDCC to Syn and Textpad
34405 \end_layout
34406
34407 \end_inset
34408 </cell>
34409 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34410 \begin_inset Text
34411
34412 \begin_layout Standard
34413
34414 \size footnotesize
34415 \begin_inset LatexCommand url
34416 target "http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp"
34417
34418 \end_inset
34419
34420
34421 \end_layout
34422
34423 \end_inset
34424 </cell>
34425 </row>
34426 <row topline="true">
34427 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34428 \begin_inset Text
34429
34430 \begin_layout Standard
34431
34432 \size footnotesize
34433 Ramtron / Goal Semiconductor
34434 \end_layout
34435
34436 \end_inset
34437 </cell>
34438 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34439 \begin_inset Text
34440
34441 \begin_layout Standard
34442
34443 \size footnotesize
34444 Installing and Configuring SDCC and Crimson Editor 
34445 \end_layout
34446
34447 \end_inset
34448 </cell>
34449 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34450 \begin_inset Text
34451
34452 \begin_layout Standard
34453
34454 \size footnotesize
34455 \begin_inset LatexCommand url
34456 target "http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp"
34457
34458 \end_inset
34459
34460
34461 \end_layout
34462
34463 \end_inset
34464 </cell>
34465 </row>
34466 <row topline="true" bottomline="true">
34467 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34468 \begin_inset Text
34469
34470 \begin_layout Standard
34471
34472 \size footnotesize
34473 Texas Instruments
34474 \end_layout
34475
34476 \end_inset
34477 </cell>
34478 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34479 \begin_inset Text
34480
34481 \begin_layout Standard
34482
34483 \size footnotesize
34484 MSC12xx Programming with SDCC
34485 \end_layout
34486
34487 \end_inset
34488 </cell>
34489 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34490 \begin_inset Text
34491
34492 \begin_layout Standard
34493
34494 \size footnotesize
34495 \begin_inset LatexCommand url
34496 target "http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sbaa109&fileType=pdf"
34497
34498 \end_inset
34499
34500
34501 \end_layout
34502
34503 \end_inset
34504 </cell>
34505 </row>
34506 </lyxtabular>
34507
34508 \end_inset
34509
34510
34511 \end_layout
34512
34513 \begin_layout Section
34514 Some Questions
34515 \end_layout
34516
34517 \begin_layout Standard
34518 Some questions answered, some pointers given - it might be time to in turn
34519  ask 
34520 \emph on
34521 you
34522 \emph default
34523  some questions: 
34524 \end_layout
34525
34526 \begin_layout Itemize
34527 can you solve your project with the selected microcontroller? Would you
34528  find out early or rather late that your target is too small/slow/whatever?
34529  Can you switch to a slightly better device if it doesn't fit?
34530 \end_layout
34531
34532 \begin_layout Itemize
34533 should you solve the problem with an 8 bit CPU? Or would a 16/32 bit CPU
34534  and/or another programming language be more adequate? Would an operating
34535  system on the target device help?
34536 \end_layout
34537
34538 \begin_layout Itemize
34539 if you solved the problem, will the marketing department be happy?
34540 \end_layout
34541
34542 \begin_layout Itemize
34543 if the marketing department is happy, will customers be happy?
34544 \end_layout
34545
34546 \begin_layout Itemize
34547 if you're the project manager, marketing department and maybe even the customer
34548  in one person, have you tried to see the project from the outside?
34549 \end_layout
34550
34551 \begin_layout Itemize
34552 is the project done if you think it is done? Or is just that other interface/pro
34553 tocol/feature/configuration/option missing? How about website, manual(s),
34554  internationali(z|s)ation, packaging, labels, 2nd source for components,
34555  electromagnetic compatability/interference, documentation for production,
34556  production test software, update mechanism, patent issues?
34557 \end_layout
34558
34559 \begin_layout Itemize
34560 is your project adequately positioned in that magic triangle: fame, fortune,
34561  fun?
34562 \end_layout
34563
34564 \begin_layout Standard
34565 Maybe not all answers to these questions are known and some answers may
34566  even be 
34567 \emph on
34568 no
34569 \emph default
34570 , nevertheless knowing these questions may help you to avoid burnout
34571 \begin_inset Foot
34572 status open
34573
34574 \begin_layout Standard
34575 burnout is bad for electronic devices, programmers and motorcycle tyres
34576 \end_layout
34577
34578 \end_inset
34579
34580 .
34581  Chances are you didn't want to hear some of them...
34582 \end_layout
34583
34584 \begin_layout Chapter
34585 Support
34586 \begin_inset LatexCommand index
34587 name "Support"
34588
34589 \end_inset
34590
34591
34592 \end_layout
34593
34594 \begin_layout Standard
34595 SDCC has grown to be a large project.
34596  The compiler alone (without the preprocessor, assembler and linker) is
34597  well over 150,000 lines of code (blank stripped).
34598  The open source nature of this project is a key to its continued growth
34599  and support.
34600  You gain the benefit and support of many active software developers and
34601  end users.
34602  Is SDCC perfect? No, that's why we need your help.
34603  The developers take pride in fixing reported bugs.
34604  You can help by reporting the bugs and helping other SDCC users.
34605  There are lots of ways to contribute, and we encourage you to take part
34606  in making SDCC a great software package.
34607  
34608 \end_layout
34609
34610 \begin_layout Standard
34611 The SDCC project is hosted on the SDCC sourceforge site at 
34612 \begin_inset LatexCommand htmlurl
34613 target "http://sourceforge.net/projects/sdcc"
34614
34615 \end_inset
34616
34617 .
34618  You'll find the complete set of mailing lists
34619 \begin_inset LatexCommand index
34620 name "Mailing list(s)"
34621
34622 \end_inset
34623
34624 , forums, bug reporting system, patch submission
34625 \begin_inset LatexCommand index
34626 name "Patch submission"
34627
34628 \end_inset
34629
34630  system, download
34631 \begin_inset LatexCommand index
34632 name "download"
34633
34634 \end_inset
34635
34636  area and Subversion code repository
34637 \begin_inset LatexCommand index
34638 name "Subversion code repository"
34639
34640 \end_inset
34641
34642  there.
34643 \end_layout
34644
34645 \begin_layout Section
34646 Reporting Bugs
34647 \begin_inset LatexCommand index
34648 name "Bug reporting"
34649
34650 \end_inset
34651
34652
34653 \begin_inset LatexCommand index
34654 name "Reporting bugs"
34655
34656 \end_inset
34657
34658
34659 \end_layout
34660
34661 \begin_layout Standard
34662 The recommended way of reporting bugs is using the infrastructure of the
34663  sourceforge site.
34664  You can follow the status of bug reports there and have an overview about
34665  the known bugs.
34666 \end_layout
34667
34668 \begin_layout Standard
34669 Bug reports are automatically forwarded to the developer mailing list and
34670  will be fixed ASAP.
34671  When reporting a bug, it is very useful to include a small test program
34672  (the smaller the better) which reproduces the problem.
34673  If you can isolate the problem by looking at the generated assembly code,
34674  this can be very helpful.
34675  Compiling your program with the -
34676 \begin_inset ERT
34677 status collapsed
34678
34679 \begin_layout Standard
34680
34681
34682 \backslash
34683 /
34684 \end_layout
34685
34686 \end_inset
34687
34688 -dumpall
34689 \begin_inset LatexCommand index
34690 name "-\\/-dumpall"
34691
34692 \end_inset
34693
34694  option can sometimes be useful in locating optimization problems.
34695  When reporting a bug please make sure you:
34696 \end_layout
34697
34698 \begin_layout Enumerate
34699 Attach the code you are compiling with SDCC.
34700  
34701 \end_layout
34702
34703 \begin_layout Enumerate
34704 Specify the exact command you use to run SDCC, or attach your Makefile.
34705  
34706 \end_layout
34707
34708 \begin_layout Enumerate
34709 Specify the SDCC version (type "
34710 \family sans
34711 \series bold
34712 sdcc -v
34713 \family default
34714 \series default
34715 "), your platform, and operating system.
34716  
34717 \end_layout
34718
34719 \begin_layout Enumerate
34720 Provide an exact copy of any error message or incorrect output.
34721  
34722 \end_layout
34723
34724 \begin_layout Enumerate
34725 Put something meaningful in the subject of your message.
34726 \end_layout
34727
34728 \begin_layout Standard
34729 Please attempt to include these 5 important parts, as applicable, in all
34730  requests for support or when reporting any problems or bugs with SDCC.
34731  Though this will make your message lengthy, it will greatly improve your
34732  chance that SDCC users and developers will be able to help you.
34733  Some SDCC developers are frustrated by bug reports without code provided
34734  that they can use to reproduce and ultimately fix the problem, so please
34735  be sure to provide sample code if you are reporting a bug! 
34736 \end_layout
34737
34738 \begin_layout Standard
34739 Please have a short check that you are using a recent version of SDCC and
34740  the bug is not yet known.
34741  This is the link for reporting bugs: 
34742 \begin_inset LatexCommand htmlurl
34743 target "http://sourceforge.net/tracker/?group_id=599&atid=100599"
34744
34745 \end_inset
34746
34747 .
34748  With SDCC on average having more than 200 downloads
34749 \begin_inset LatexCommand index
34750 name "download"
34751
34752 \end_inset
34753
34754  on sourceforge per day
34755 \begin_inset Foot
34756 status open
34757
34758 \begin_layout Standard
34759 220 daily downloads on average Jan-Sept 2006 and about 150 daily downloads
34760  between 2002 and 2005.
34761  This does not include other methods of distribution.
34762 \end_layout
34763
34764 \end_inset
34765
34766  there must be some users.
34767  So it's not exactly easy to find a new bug.
34768  If you find one we need it: 
34769 \emph on
34770 reporting bugs is good
34771 \emph default
34772 .
34773 \end_layout
34774
34775 \begin_layout Section
34776 Requesting Features
34777 \begin_inset LatexCommand label
34778 name "sub:Requesting-Features"
34779
34780 \end_inset
34781
34782
34783 \begin_inset LatexCommand index
34784 name "Feature request"
34785
34786 \end_inset
34787
34788
34789 \begin_inset LatexCommand index
34790 name "Requesting features"
34791
34792 \end_inset
34793
34794
34795 \end_layout
34796
34797 \begin_layout Standard
34798 Like bug reports feature requests are forwarded to the developer mailing
34799  list.
34800  This is the link for requesting features: 
34801 \begin_inset LatexCommand htmlurl
34802 target "http://sourceforge.net/tracker/?group_id=599&atid=350599"
34803
34804 \end_inset
34805
34806 .
34807 \end_layout
34808
34809 \begin_layout Section
34810 Submitting patches
34811 \end_layout
34812
34813 \begin_layout Standard
34814 Like bug reports contributed patches are forwarded to the developer mailing
34815  list.
34816  This is the link for submitting patches
34817 \begin_inset LatexCommand index
34818 name "Patch submission"
34819
34820 \end_inset
34821
34822
34823 \begin_inset LatexCommand url
34824 target "http://sourceforge.net/tracker/?group_id=599&atid=300599"
34825
34826 \end_inset
34827
34828 .
34829 \end_layout
34830
34831 \begin_layout Standard
34832 You need to specify some parameters to the 
34833 \family typewriter
34834 diff
34835 \family default
34836  command for the patches to be useful.
34837  If you modified more than one file a patch created f.e.
34838  with 
34839 \family sans
34840 \series bold
34841
34842 \begin_inset Quotes sld
34843 \end_inset
34844
34845 diff -Naur unmodified_directory modified_directory >my_changes.patch
34846 \begin_inset Quotes srd
34847 \end_inset
34848
34849
34850 \family default
34851 \series default
34852  will be fine, otherwise 
34853 \family sans
34854 \series bold
34855
34856 \begin_inset Quotes sld
34857 \end_inset
34858
34859 diff -u sourcefile.c.orig sourcefile.c >my_changes.patch
34860 \begin_inset Quotes srd
34861 \end_inset
34862
34863
34864 \family default
34865 \series default
34866  will do.
34867 \end_layout
34868
34869 \begin_layout Section
34870 Getting Help
34871 \end_layout
34872
34873 \begin_layout Standard
34874 These links should take you directly to the 
34875 \begin_inset LatexCommand url
34876 name "Mailing lists"
34877 target "http://sourceforge.net/mail/?group_id=599"
34878
34879 \end_inset
34880
34881
34882 \begin_inset Foot
34883 status open
34884
34885 \begin_layout Standard
34886 Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
34887  automated messages (mid 2003)
34888 \end_layout
34889
34890 \end_inset
34891
34892  and the 
34893 \begin_inset LatexCommand url
34894 name "Forums"
34895 target "http://sourceforge.net/forum/?group_id=599"
34896
34897 \end_inset
34898
34899 , lists
34900 \begin_inset LatexCommand index
34901 name "Mailing list(s)"
34902
34903 \end_inset
34904
34905  and forums are archived and searchable so if you are lucky someone already
34906  had a similar problem.
34907  While mails to the lists themselves are delivered promptly their web front
34908  end on sourceforge sometimes shows a severe time lag (up to several weeks),
34909  if you're seriously using SDCC please consider subscribing to the lists.
34910 \end_layout
34911
34912 \begin_layout Section
34913 ChangeLog
34914 \end_layout
34915
34916 \begin_layout Standard
34917 You can follow the status of the Subversion version
34918 \begin_inset LatexCommand index
34919 name "version"
34920
34921 \end_inset
34922
34923  of SDCC by watching the Changelog
34924 \begin_inset LatexCommand index
34925 name "Changelog"
34926
34927 \end_inset
34928
34929  in the Subversion repository
34930 \size footnotesize
34931  
34932 \begin_inset LatexCommand htmlurl
34933 target "http://sdcc.svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/ChangeLog"
34934
34935 \end_inset
34936
34937 .
34938 \end_layout
34939
34940 \begin_layout Section
34941 Subversion Source Code Repository
34942 \end_layout
34943
34944 \begin_layout Standard
34945 The output of 
34946 \family sans
34947 \series bold
34948 sdcc -
34949 \family default
34950
34951 \begin_inset ERT
34952 status open
34953
34954 \begin_layout Standard
34955
34956
34957 \backslash
34958 /
34959 \end_layout
34960
34961 \end_inset
34962
34963
34964 \family sans
34965 -version
34966 \family default
34967 \series default
34968  or the filenames of the snapshot versions of SDCC include date and its
34969  Subversion
34970 \begin_inset LatexCommand index
34971 name "Subversion code repository"
34972
34973 \end_inset
34974
34975  number.
34976  Subversion allows to download the source of recent or previous versions
34977  
34978 \begin_inset LatexCommand url
34979 target "http://sourceforge.net/svn/?group_id=599"
34980
34981 \end_inset
34982
34983  (by number or by date).
34984  An on-line source code browser and detailled instructions are also available
34985  there.
34986  SDCC versions starting from 1999 up to now are available (currently the
34987  versions prior to the conversion from cvs
34988 \begin_inset LatexCommand index
34989 name "cvs|see{Subversion}"
34990
34991 \end_inset
34992
34993  to Subversion (April 2006) are either by accessible by Subversion or by
34994  cvs).
34995 \end_layout
34996
34997 \begin_layout Section
34998 Release policy
34999 \begin_inset LatexCommand index
35000 name "Release policy"
35001
35002 \end_inset
35003
35004
35005 \end_layout
35006
35007 \begin_layout Standard
35008 Historically there often were long delays between official releases and
35009  the sourceforge download area tends to get not updated at all.
35010  Excuses in the past might have referred to problems with live range analysis,
35011  but as this was fixed a while ago, the current problem is that another
35012  excuse has to be found.
35013  Kidding aside, we have to get better there! On the other hand there are
35014  daily snapshots available at 
35015 \begin_inset LatexCommand htmlurl
35016 name "snap"
35017 target "http://sdcc.sourceforge.net/snap.php"
35018
35019 \end_inset
35020
35021 , and you can always build the very last version (hopefully with many bugs
35022  fixed, and features added) from the source code available at 
35023 \begin_inset LatexCommand htmlurl
35024 name "Source"
35025 target "http://sdcc.sourceforge.net/snap.php#Source"
35026
35027 \end_inset
35028
35029 .
35030  The SDCC Wiki
35031 \begin_inset LatexCommand index
35032 name "wiki"
35033
35034 \end_inset
35035
35036
35037 \begin_inset LatexCommand index
35038 name "SDCC Wiki"
35039
35040 \end_inset
35041
35042  at 
35043 \begin_inset LatexCommand url
35044 target "http://sdcc.wiki.sourceforge.net/"
35045
35046 \end_inset
35047
35048  also holds some information about past and future releases.
35049 \end_layout
35050
35051 \begin_layout Section
35052 Examples
35053 \begin_inset LatexCommand index
35054 name "Examples"
35055
35056 \end_inset
35057
35058
35059 \end_layout
35060
35061 \begin_layout Standard
35062 You'll find some small examples in the directory 
35063 \emph on
35064 sdcc/device/examples/.
35065
35066 \emph default
35067  More examples and libraries are available at 
35068 \emph on
35069 The SDCC Open Knowledge Resource 
35070 \begin_inset LatexCommand url
35071 target "http://sdccokr.dl9sec.de/"
35072
35073 \end_inset
35074
35075
35076 \emph default
35077  web site or at 
35078 \begin_inset LatexCommand url
35079 target "http://www.pjrc.com/tech/8051/"
35080
35081 \end_inset
35082
35083 .
35084 \end_layout
35085
35086 \begin_layout Standard
35087 \begin_inset Note Note
35088 status collapsed
35089
35090 \begin_layout Standard
35091 I did insert a reference to Paul's web site here although it seems rather
35092  dedicated to a specific 8032 board (I think it's okay because it f.e.
35093  shows LCD/Harddisc interface and has a free 8051 monitor.
35094  Independent 8032 board vendors face hard competition of heavily subsidized
35095  development boards anyway).
35096 \end_layout
35097
35098 \begin_layout Standard
35099 Maybe we should include some links to real world applications.
35100  Preferably pointer to pointers (one for each architecture) so this stays
35101  manageable here?
35102 \end_layout
35103
35104 \end_inset
35105
35106
35107 \end_layout
35108
35109 \begin_layout Section
35110 Quality control
35111 \begin_inset LatexCommand label
35112 name "sec:Quality-control"
35113
35114 \end_inset
35115
35116
35117 \begin_inset LatexCommand index
35118 name "Quality control"
35119
35120 \end_inset
35121
35122
35123 \end_layout
35124
35125 \begin_layout Standard
35126 The compiler is passed through snaphot build compile and build checks.
35127  The so called 
35128 \shape italic
35129 regression tests
35130 \shape default
35131
35132 \begin_inset LatexCommand index
35133 name "Regression test"
35134
35135 \end_inset
35136
35137  check that SDCC itself compiles flawlessly on several host platforms (i386,
35138  Opteron, 64 bit Alpha, ppc64, Mac OS X on ppc and i386, Solaris on Sparc)
35139  and checks the quality of the code generated by SDCC by running the code
35140  for several target platforms through simulators.
35141  The regression test suite comprises more than 100 files which expand to
35142  more than 500 test cases which include more than 4500 tests.
35143  The results of these tests are published daily on SDCC's snapshot page
35144  (click on the red or green symbols on the right side of 
35145 \begin_inset LatexCommand url
35146 target "http://sdcc.sourceforge.net/snap.php"
35147
35148 \end_inset
35149
35150 ).
35151 \end_layout
35152
35153 \begin_layout Standard
35154 There is a separate document 
35155 \shape italic
35156 test_suite.pdf 
35157 \begin_inset LatexCommand index
35158 name "Test suite"
35159
35160 \end_inset
35161
35162
35163 \shape default
35164  
35165 \begin_inset LatexCommand url
35166 target "http://sdcc.sourceforge.net/doc/test_suite_spec.pdf"
35167
35168 \end_inset
35169
35170  about the regression test suite.
35171 \end_layout
35172
35173 \begin_layout Standard
35174 You'll find the test code in the directory 
35175 \shape italic
35176 sdcc/support/regression
35177 \shape default
35178 .
35179  You can run these tests manually by running 
35180 \family sans
35181 make
35182 \family default
35183  in this directory (or f.e.
35184  
35185 \family sans
35186 \series bold
35187
35188 \begin_inset Quotes sld
35189 \end_inset
35190
35191 make test-mcs51
35192 \begin_inset Quotes srd
35193 \end_inset
35194
35195
35196 \family default
35197 \series default
35198  if you don't want to run the complete tests).
35199  The test code might also be interesting if you want to look for examples
35200 \begin_inset LatexCommand index
35201 name "Examples"
35202
35203 \end_inset
35204
35205  checking corner cases of SDCC or if you plan to submit patches
35206 \begin_inset LatexCommand index
35207 name "Patch submission"
35208
35209 \end_inset
35210
35211 .
35212 \end_layout
35213
35214 \begin_layout Standard
35215 The PIC14 port uses a different set of regression tests 
35216 \begin_inset LatexCommand index
35217 name "Regression test (PIC14)"
35218
35219 \end_inset
35220
35221 , you'll find them in the directory 
35222 \shape italic
35223 sdcc/src/regression
35224 \shape default
35225 .
35226 \end_layout
35227
35228 \begin_layout Section
35229 Use of SDCC in Education
35230 \end_layout
35231
35232 \begin_layout Standard
35233 In short: 
35234 \emph on
35235 highly
35236 \emph default
35237  encouraged
35238 \begin_inset Foot
35239 status open
35240
35241 \begin_layout Standard
35242 the phrase "use in education" might evoke the association "
35243 \emph on
35244 only
35245 \emph default
35246  fit for use in education".
35247  This connotation is not intended but nevertheless risked as the licensing
35248  of SDCC makes it difficult to offer educational discounts
35249 \end_layout
35250
35251 \end_inset
35252
35253 .
35254  If your rationales are to:
35255 \end_layout
35256
35257 \begin_layout Enumerate
35258 give students a chance to understand the 
35259 \emph on
35260 complete
35261 \emph default
35262  steps of code generation
35263 \end_layout
35264
35265 \begin_layout Enumerate
35266 have a curriculum that can be extended for years.
35267  Then you could use an fpga board as target and your curriculum will seamlessly
35268  extend from logic synthesis (
35269 \begin_inset LatexCommand url
35270 name "http://www.opencores.org"
35271 target "opencores.org"
35272
35273 \end_inset
35274
35275
35276 \begin_inset LatexCommand url
35277 name "Oregano"
35278 target "http://www.oregano.at/ip/ip01.htm"
35279
35280 \end_inset
35281
35282 ), over assembly programming, to C to FPGA compilers (
35283 \begin_inset LatexCommand url
35284 name "FPGAC"
35285 target "http://sf.net/projects/fpgac"
35286
35287 \end_inset
35288
35289 ) and to C.
35290 \end_layout
35291
35292 \begin_layout Enumerate
35293 be able to insert excursions about skills like using a revision control
35294  system, submitting/applying patches, using a type-setting (as opposed to
35295  word-processing) engine LyX/LaTeX, using 
35296 \begin_inset LatexCommand url
35297 name "SourceForge"
35298 target "http://www.sf.net"
35299
35300 \end_inset
35301
35302 , following some 
35303 \begin_inset LatexCommand url
35304 name "netiquette"
35305 target "http://en.wikipedia.org/wiki/Netiquette"
35306
35307 \end_inset
35308
35309 , understanding BSD/LGPL/GPL/Proprietary licensing, growth models of Open
35310  Source Software, CPU simulation, compiler regression tests
35311 \begin_inset LatexCommand index
35312 name "Regression test"
35313
35314 \end_inset
35315
35316 .
35317  
35318 \newline
35319 And if there should be a shortage of ideas then you can always point students
35320  to the ever-growing feature request list 
35321 \begin_inset LatexCommand htmlurl
35322 target "http://sourceforge.net/tracker/?group_id=599&atid=350599"
35323
35324 \end_inset
35325
35326 .
35327 \end_layout
35328
35329 \begin_layout Enumerate
35330 not tie students to a specific host platform and instead allow them to use
35331  a host platform of 
35332 \emph on
35333 their
35334 \emph default
35335  choice (among them Alpha, i386, i386_64, Mac OS X, Mips, Sparc, Windows
35336  and eventually 
35337 \begin_inset LatexCommand url
35338 name "OLPC"
35339 target "http://www.laptop.org"
35340
35341 \end_inset
35342
35343 )
35344 \end_layout
35345
35346 \begin_layout Enumerate
35347 not encourage students to use illegal copies of educational software
35348 \end_layout
35349
35350 \begin_layout Enumerate
35351 be immune to licensing/availability/price changes of the chosen tool chain
35352 \end_layout
35353
35354 \begin_layout Enumerate
35355 be able to change to a new target platform without having to adopt a new
35356  tool chain
35357 \end_layout
35358
35359 \begin_layout Enumerate
35360 have complete control over and insight into the tool chain
35361 \end_layout
35362
35363 \begin_layout Enumerate
35364 make your students aware about the pros and cons of open source software
35365  development
35366 \end_layout
35367
35368 \begin_layout Enumerate
35369 give back to the public as you are probably at least partially publicly
35370  funded
35371 \end_layout
35372
35373 \begin_layout Enumerate
35374 give students a chance to publicly prove their skills and to possibly see
35375  a world wide impact
35376 \end_layout
35377
35378 \begin_layout Standard
35379 then SDCC is probably among the first choices.
35380  Well, probably SDCC might be the only choice.
35381 \newpage
35382
35383 \end_layout
35384
35385 \begin_layout Chapter
35386 SDCC Technical Data
35387 \end_layout
35388
35389 \begin_layout Section
35390 Optimizations
35391 \begin_inset LatexCommand index
35392 name "Optimizations"
35393
35394 \end_inset
35395
35396
35397 \end_layout
35398
35399 \begin_layout Standard
35400 SDCC performs a host of standard optimizations in addition to some MCU specific
35401  optimizations.
35402  
35403 \end_layout
35404
35405 \begin_layout Subsection
35406 Sub-expression Elimination
35407 \begin_inset LatexCommand index
35408 name "Subexpression elimination"
35409
35410 \end_inset
35411
35412
35413 \end_layout
35414
35415 \begin_layout Standard
35416 The compiler does local and 
35417 \emph on
35418 g
35419 \emph default
35420 lobal 
35421 \emph on
35422 c
35423 \emph default
35424 ommon 
35425 \emph on
35426 s
35427 \emph default
35428 ubexpression 
35429 \emph on
35430 e
35431 \emph default
35432 limination, e.g.: 
35433 \end_layout
35434
35435 \begin_layout Verse
35436
35437 \family typewriter
35438 i = x + y + 1; 
35439 \newline
35440 j = x + y;
35441 \end_layout
35442
35443 \begin_layout Standard
35444 will be translated to
35445 \end_layout
35446
35447 \begin_layout Verse
35448
35449 \family typewriter
35450 iTemp = x + y; 
35451 \newline
35452 i = iTemp + 1; 
35453 \newline
35454 j = iTemp;
35455 \end_layout
35456
35457 \begin_layout Standard
35458 Some subexpressions are not as obvious as the above example, e.g.:
35459 \end_layout
35460
35461 \begin_layout Verse
35462
35463 \family typewriter
35464 a->b[i].c = 10; 
35465 \newline
35466 a->b[i].d = 11;
35467 \end_layout
35468
35469 \begin_layout Standard
35470 In this case the address arithmetic a->b[i] will be computed only once;
35471  the equivalent code in C would be.
35472 \end_layout
35473
35474 \begin_layout Verse
35475
35476 \family typewriter
35477 iTemp = a->b[i]; 
35478 \newline
35479 iTemp.c = 10; 
35480 \newline
35481 iTemp.d = 11;
35482 \end_layout
35483
35484 \begin_layout Standard
35485 The compiler will try to keep these temporary variables in registers.
35486 \end_layout
35487
35488 \begin_layout Subsection
35489 Dead-Code Elimination
35490 \begin_inset LatexCommand index
35491 name "Dead-code elimination"
35492
35493 \end_inset
35494
35495
35496 \end_layout
35497
35498 \begin_layout Verse
35499
35500 \family typewriter
35501 int global;
35502 \newline
35503
35504 \newline
35505 void f () { 
35506 \newline
35507 \InsetSpace ~
35508 \InsetSpace ~
35509 int i; 
35510 \newline
35511 \InsetSpace ~
35512 \InsetSpace ~
35513 i = 1; \InsetSpace ~
35514 \InsetSpace ~
35515 \InsetSpace ~
35516 \InsetSpace ~
35517 \InsetSpace ~
35518 /* dead store */ 
35519 \newline
35520 \InsetSpace ~
35521 \InsetSpace ~
35522 global = 1;\InsetSpace ~
35523 /* dead
35524  store */ 
35525 \newline
35526 \InsetSpace ~
35527 \InsetSpace ~
35528 global = 2; 
35529 \newline
35530 \InsetSpace ~
35531 \InsetSpace ~
35532 return; 
35533 \newline
35534 \InsetSpace ~
35535 \InsetSpace ~
35536 global = 3;\InsetSpace ~
35537 /* unreachable */ 
35538 \newline
35539 }
35540 \end_layout
35541
35542 \begin_layout Standard
35543 will be changed to
35544 \end_layout
35545
35546 \begin_layout Verse
35547
35548 \family typewriter
35549 int global;
35550 \newline
35551
35552 \newline
35553 void f () {
35554 \newline
35555 \InsetSpace ~
35556 \InsetSpace ~
35557 global = 2; 
35558 \newline
35559 }
35560 \end_layout
35561
35562 \begin_layout Subsection
35563 Copy-Propagation
35564 \begin_inset LatexCommand index
35565 name "Copy propagation"
35566
35567 \end_inset
35568
35569
35570 \end_layout
35571
35572 \begin_layout Verse
35573
35574 \family typewriter
35575 int f() { 
35576 \newline
35577 \InsetSpace ~
35578 \InsetSpace ~
35579 int i, j; 
35580 \newline
35581 \InsetSpace ~
35582 \InsetSpace ~
35583 i = 10; 
35584 \newline
35585 \InsetSpace ~
35586 \InsetSpace ~
35587 j = i; 
35588 \newline
35589 \InsetSpace ~
35590 \InsetSpace ~
35591 return j; 
35592 \newline
35593 }
35594 \end_layout
35595
35596 \begin_layout Standard
35597 will be changed to 
35598 \end_layout
35599
35600 \begin_layout Verse
35601
35602 \family typewriter
35603 int f() { 
35604 \newline
35605 \InsetSpace ~
35606 \InsetSpace ~
35607 int i, j; 
35608 \newline
35609 \InsetSpace ~
35610 \InsetSpace ~
35611 i = 10; 
35612 \newline
35613 \InsetSpace ~
35614 \InsetSpace ~
35615 j = 10; 
35616 \newline
35617 \InsetSpace ~
35618 \InsetSpace ~
35619 return 10; 
35620 \newline
35621 }
35622 \end_layout
35623
35624 \begin_layout Standard
35625 Note: the dead stores created by this copy propagation will be eliminated
35626  by dead-code elimination.
35627 \end_layout
35628
35629 \begin_layout Subsection
35630 Loop Optimizations
35631 \begin_inset LatexCommand index
35632 name "Loop optimization"
35633
35634 \end_inset
35635
35636
35637 \begin_inset LatexCommand label
35638 name "sub:Loop-Optimizations"
35639
35640 \end_inset
35641
35642
35643 \end_layout
35644
35645 \begin_layout Standard
35646 Two types of loop optimizations are done by SDCC 
35647 \emph on
35648 loop invariant
35649 \emph default
35650  lifting and 
35651 \emph on
35652 strength reduction
35653 \emph default
35654  of loop induction variables.
35655  In addition to the strength reduction the optimizer marks the induction
35656  variables and the register allocator tries to keep the induction variables
35657  in registers for the duration of the loop.
35658  Because of this preference of the register allocator
35659 \begin_inset LatexCommand index
35660 name "Register allocation"
35661
35662 \end_inset
35663
35664 , loop induction optimization causes an increase in register pressure, which
35665  may cause unwanted spilling of other temporary variables into the stack
35666 \begin_inset LatexCommand index
35667 name "stack"
35668
35669 \end_inset
35670
35671  / data space.
35672  The compiler will generate a warning message when it is forced to allocate
35673  extra space either on the stack or data space.
35674  If this extra space allocation is undesirable then induction optimization
35675  can be eliminated either for the entire source file (with -
35676 \begin_inset ERT
35677 status collapsed
35678
35679 \begin_layout Standard
35680
35681
35682 \backslash
35683 /
35684 \end_layout
35685
35686 \end_inset
35687
35688 -noinduction option) or for a given function only using #pragma\InsetSpace ~
35689 noinduction
35690 \begin_inset LatexCommand index
35691 name "\\#pragma noinduction"
35692
35693 \end_inset
35694
35695 .
35696 \newline
35697
35698 \newline
35699 Loop Invariant:
35700 \end_layout
35701
35702 \begin_layout Verse
35703
35704 \family typewriter
35705 for (i = 0 ; i < 100 ; i ++) 
35706 \newline
35707 \InsetSpace ~
35708 \InsetSpace ~
35709 \InsetSpace ~
35710 \InsetSpace ~
35711 f += k + l;
35712 \end_layout
35713
35714 \begin_layout Standard
35715 changed to
35716 \end_layout
35717
35718 \begin_layout Verse
35719
35720 \family typewriter
35721 itemp = k + l; 
35722 \newline
35723 for (i = 0; i < 100; i++) 
35724 \newline
35725 \InsetSpace ~
35726 \InsetSpace ~
35727 \InsetSpace ~
35728 \InsetSpace ~
35729 f += itemp;
35730 \end_layout
35731
35732 \begin_layout Standard
35733 As mentioned previously some loop invariants are not as apparent, all static
35734  address computations are also moved out of the loop.
35735 \newline
35736
35737 \newline
35738 Strength Reduction
35739 \begin_inset LatexCommand index
35740 name "Strength reduction"
35741
35742 \end_inset
35743
35744 , this optimization substitutes an expression by a cheaper expression:
35745 \end_layout
35746
35747 \begin_layout Verse
35748
35749 \family typewriter
35750 for (i=0;i < 100; i++)
35751 \newline
35752 \InsetSpace ~
35753 \InsetSpace ~
35754 \InsetSpace ~
35755 \InsetSpace ~
35756 ar[i*5] = i*3;
35757 \end_layout
35758
35759 \begin_layout Standard
35760 changed to
35761 \end_layout
35762
35763 \begin_layout Verse
35764
35765 \family typewriter
35766 itemp1 = 0; 
35767 \newline
35768 itemp2 = 0; 
35769 \newline
35770 for (i=0;i< 100;i++) { 
35771 \newline
35772 \InsetSpace ~
35773 \InsetSpace ~
35774 \InsetSpace ~
35775 \InsetSpace ~
35776 ar[itemp1] = itemp2; 
35777 \newline
35778 \InsetSpace ~
35779 \InsetSpace ~
35780 \InsetSpace ~
35781 \InsetSpace ~
35782 itemp1
35783  += 5; 
35784 \newline
35785 \InsetSpace ~
35786 \InsetSpace ~
35787 \InsetSpace ~
35788 \InsetSpace ~
35789 itemp2 += 3; 
35790 \newline
35791 }
35792 \end_layout
35793
35794 \begin_layout Standard
35795 The more expensive multiplication
35796 \begin_inset LatexCommand index
35797 name "Multiplication"
35798
35799 \end_inset
35800
35801  is changed to a less expensive addition.
35802 \end_layout
35803
35804 \begin_layout Subsection
35805 Loop Reversing
35806 \begin_inset LatexCommand index
35807 name "Loop reversing"
35808
35809 \end_inset
35810
35811
35812 \end_layout
35813
35814 \begin_layout Standard
35815 This optimization is done to reduce the overhead of checking loop boundaries
35816  for every iteration.
35817  Some simple loops can be reversed and implemented using a 
35818 \begin_inset Quotes eld
35819 \end_inset
35820
35821 decrement and jump if not zero
35822 \begin_inset Quotes erd
35823 \end_inset
35824
35825  instruction.
35826  SDCC checks for the following criterion to determine if a loop is reversible
35827  (note: more sophisticated compilers use data-dependency analysis to make
35828  this determination, SDCC uses a more simple minded analysis).
35829 \end_layout
35830
35831 \begin_layout Itemize
35832 The 'for' loop is of the form 
35833 \newline
35834
35835 \newline
35836
35837 \family typewriter
35838 for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
35839  += 1])
35840 \newline
35841 \InsetSpace ~
35842 \InsetSpace ~
35843 \InsetSpace ~
35844 \InsetSpace ~
35845 <for body>
35846 \end_layout
35847
35848 \begin_layout Itemize
35849 The <for body> does not contain 
35850 \begin_inset Quotes eld
35851 \end_inset
35852
35853 continue
35854 \begin_inset Quotes erd
35855 \end_inset
35856
35857  or 'break
35858 \begin_inset Quotes erd
35859 \end_inset
35860
35861 .
35862 \end_layout
35863
35864 \begin_layout Itemize
35865 All goto's are contained within the loop.
35866 \end_layout
35867
35868 \begin_layout Itemize
35869 No function calls within the loop.
35870 \end_layout
35871
35872 \begin_layout Itemize
35873 The loop control variable <sym> is not assigned any value within the loop
35874 \end_layout
35875
35876 \begin_layout Itemize
35877 The loop control variable does NOT participate in any arithmetic operation
35878  within the loop.
35879 \end_layout
35880
35881 \begin_layout Itemize
35882 There are NO switch statements in the loop.
35883 \end_layout
35884
35885 \begin_layout Subsection
35886 Algebraic Simplifications
35887 \end_layout
35888
35889 \begin_layout Standard
35890 SDCC does numerous algebraic simplifications, the following is a small sub-set
35891  of these optimizations.
35892 \end_layout
35893
35894 \begin_layout Verse
35895
35896 \family typewriter
35897 i = j + 0;\InsetSpace ~
35898 \InsetSpace ~
35899 \InsetSpace ~
35900 \InsetSpace ~
35901  /* changed to: */\InsetSpace ~
35902 \InsetSpace ~
35903 \InsetSpace ~
35904 \InsetSpace ~
35905  i = j; 
35906 \newline
35907 i /= 2;\InsetSpace ~
35908 \InsetSpace ~
35909 \InsetSpace ~
35910 \InsetSpace ~
35911 \InsetSpace ~
35912 \InsetSpace ~
35913 \InsetSpace ~
35914  /* changed to: */\InsetSpace ~
35915 \InsetSpace ~
35916 \InsetSpace ~
35917 \InsetSpace ~
35918  i >>= 1; 
35919 \newline
35920 i
35921  = j - j;\InsetSpace ~
35922 \InsetSpace ~
35923 \InsetSpace ~
35924 \InsetSpace ~
35925  /* changed to: */\InsetSpace ~
35926 \InsetSpace ~
35927 \InsetSpace ~
35928 \InsetSpace ~
35929  i = 0; 
35930 \newline
35931 i = j / 1;\InsetSpace ~
35932 \InsetSpace ~
35933 \InsetSpace ~
35934 \InsetSpace ~
35935  /* changed to: */\InsetSpace ~
35936 \InsetSpace ~
35937 \InsetSpace ~
35938 \InsetSpace ~
35939  i = j;
35940 \end_layout
35941
35942 \begin_layout Standard
35943 Note the subexpressions
35944 \begin_inset LatexCommand index
35945 name "Subexpression"
35946
35947 \end_inset
35948
35949  given above are generally introduced by macro expansions or as a result
35950  of copy/constant propagation.
35951 \end_layout
35952
35953 \begin_layout Subsection
35954 'switch' Statements
35955 \begin_inset LatexCommand label
35956 name "sub:'switch'-Statements"
35957
35958 \end_inset
35959
35960
35961 \begin_inset LatexCommand index
35962 name "switch statement"
35963
35964 \end_inset
35965
35966
35967 \end_layout
35968
35969 \begin_layout Standard
35970 SDCC can optimize switch statements to jump tables
35971 \begin_inset LatexCommand index
35972 name "jump tables"
35973
35974 \end_inset
35975
35976 .
35977  It makes the decision based on an estimate of the generated code size.
35978  SDCC is quite liberal in the requirements for jump table generation: 
35979 \end_layout
35980
35981 \begin_layout Itemize
35982 The labels need not be in order, and the starting number need not be one
35983  or zero, the case labels are in numerical sequence or not too many case
35984  labels are missing.
35985 \end_layout
35986
35987 \begin_deeper
35988 \begin_layout Verse
35989
35990 \family typewriter
35991 switch(i) {\InsetSpace ~
35992 \InsetSpace ~
35993 \InsetSpace ~
35994 \InsetSpace ~
35995 \InsetSpace ~
35996 \InsetSpace ~
35997 \InsetSpace ~
35998 \InsetSpace ~
35999 \InsetSpace ~
36000 \InsetSpace ~
36001 \InsetSpace ~
36002 \InsetSpace ~
36003 \InsetSpace ~
36004 \InsetSpace ~
36005 \InsetSpace ~
36006 \InsetSpace ~
36007 \InsetSpace ~
36008 \InsetSpace ~
36009 \InsetSpace ~
36010 \InsetSpace ~
36011 \InsetSpace ~
36012 \InsetSpace ~
36013 \InsetSpace ~
36014 \InsetSpace ~
36015 \InsetSpace ~
36016 \InsetSpace ~
36017 switch (i) { 
36018 \newline
36019 \InsetSpace ~
36020 \InsetSpace ~
36021 \InsetSpace ~
36022 case 4: ...\InsetSpace ~
36023 \InsetSpace ~
36024 \InsetSpace ~
36025 \InsetSpace ~
36026 \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 case 0: ...
36049  
36050 \newline
36051 \InsetSpace ~
36052 \InsetSpace ~
36053 \InsetSpace ~
36054 case 5: ...\InsetSpace ~
36055 \InsetSpace ~
36056 \InsetSpace ~
36057 \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 case 1: ...
36081  
36082 \newline
36083 \InsetSpace ~
36084 \InsetSpace ~
36085 \InsetSpace ~
36086 case 3: ...\InsetSpace ~
36087 \InsetSpace ~
36088 \InsetSpace ~
36089 \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
36113 \newline
36114 \InsetSpace ~
36115 \InsetSpace ~
36116 \InsetSpace ~
36117 case 6: ...\InsetSpace ~
36118 \InsetSpace ~
36119 \InsetSpace ~
36120 \InsetSpace ~
36121 \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 case 3: ...
36144  
36145 \newline
36146 \InsetSpace ~
36147 \InsetSpace ~
36148 \InsetSpace ~
36149 case 7: ...\InsetSpace ~
36150 \InsetSpace ~
36151 \InsetSpace ~
36152 \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 case 4: ...
36176  
36177 \newline
36178 \InsetSpace ~
36179 \InsetSpace ~
36180 \InsetSpace ~
36181 case 8: ...\InsetSpace ~
36182 \InsetSpace ~
36183 \InsetSpace ~
36184 \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 case 5: ...
36208  
36209 \newline
36210 \InsetSpace ~
36211 \InsetSpace ~
36212 \InsetSpace ~
36213 case 9: ...\InsetSpace ~
36214 \InsetSpace ~
36215 \InsetSpace ~
36216 \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 case 6: ...
36240  
36241 \newline
36242 \InsetSpace ~
36243 \InsetSpace ~
36244 \InsetSpace ~
36245 case 10: ...\InsetSpace ~
36246 \InsetSpace ~
36247 \InsetSpace ~
36248 \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 case 7: ...
36271  
36272 \newline
36273 \InsetSpace ~
36274 \InsetSpace ~
36275 \InsetSpace ~
36276 case 11: ...\InsetSpace ~
36277 \InsetSpace ~
36278 \InsetSpace ~
36279 \InsetSpace ~
36280 \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 case 8: ...
36302  
36303 \newline
36304 }\InsetSpace ~
36305 \InsetSpace ~
36306 \InsetSpace ~
36307 \InsetSpace ~
36308 \InsetSpace ~
36309 \InsetSpace ~
36310 \InsetSpace ~
36311 \InsetSpace ~
36312 \InsetSpace ~
36313 \InsetSpace ~
36314 \InsetSpace ~
36315 \InsetSpace ~
36316 \InsetSpace ~
36317 \InsetSpace ~
36318 \InsetSpace ~
36319 \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 \InsetSpace ~
36337 \InsetSpace ~
36338 \InsetSpace ~
36339 \InsetSpace ~
36340 }
36341 \end_layout
36342
36343 \begin_layout Standard
36344 Both the above switch statements will be implemented using a jump-table.
36345  The example to the right side is slightly more efficient as the check for
36346  the lower boundary of the jump-table is not needed.
36347 \end_layout
36348
36349 \end_deeper
36350 \begin_layout Itemize
36351 The number of case labels is not larger than supported by the target architectur
36352 e.
36353 \end_layout
36354
36355 \begin_layout Itemize
36356 If the case labels are not in numerical sequence ('gaps' between cases)
36357  SDCC checks whether a jump table with additionally inserted dummy cases
36358  is still attractive.
36359  
36360 \end_layout
36361
36362 \begin_layout Itemize
36363 If the starting number is not zero and a check for the lower boundary of
36364  the jump-table can thus be eliminated SDCC might insert dummy cases 0,
36365  ...
36366  .
36367 \end_layout
36368
36369 \begin_layout Standard
36370 Switch statements which have large gaps in the numeric sequence or those
36371  that have too many case labels can be split into more than one switch statement
36372  for efficient code generation, e.g.:
36373 \end_layout
36374
36375 \begin_layout Verse
36376
36377 \family typewriter
36378 switch (i) { 
36379 \newline
36380 \InsetSpace ~
36381 \InsetSpace ~
36382 case 1: ...
36383  
36384 \newline
36385 \InsetSpace ~
36386 \InsetSpace ~
36387 case 2: ...
36388  
36389 \newline
36390 \InsetSpace ~
36391 \InsetSpace ~
36392 case 3: ...
36393  
36394 \newline
36395 \InsetSpace ~
36396 \InsetSpace ~
36397 case 4: ...
36398  
36399 \newline
36400 \InsetSpace ~
36401 \InsetSpace ~
36402 case 5: ...
36403  
36404 \newline
36405 \InsetSpace ~
36406 \InsetSpace ~
36407 case 6: ...
36408  
36409 \newline
36410 \InsetSpace ~
36411 \InsetSpace ~
36412 case 7: ...
36413  
36414 \newline
36415 \InsetSpace ~
36416 \InsetSpace ~
36417 case 101: ...
36418  
36419 \newline
36420 \InsetSpace ~
36421 \InsetSpace ~
36422 case 102: ...
36423  
36424 \newline
36425 \InsetSpace ~
36426 \InsetSpace ~
36427 case 103: ...
36428  
36429 \newline
36430 \InsetSpace ~
36431 \InsetSpace ~
36432 case 104: ...
36433  
36434 \newline
36435 \InsetSpace ~
36436 \InsetSpace ~
36437 case 105: ...
36438  
36439 \newline
36440 \InsetSpace ~
36441 \InsetSpace ~
36442 case 106: ...
36443  
36444 \newline
36445 \InsetSpace ~
36446 \InsetSpace ~
36447 case 107: ...
36448  
36449 \newline
36450 }
36451 \end_layout
36452
36453 \begin_layout Standard
36454 If the above switch statement is broken down into two switch statements
36455 \end_layout
36456
36457 \begin_layout Verse
36458
36459 \family typewriter
36460 switch (i) { 
36461 \newline
36462 \InsetSpace ~
36463 \InsetSpace ~
36464 case 1: ...
36465  
36466 \newline
36467 \InsetSpace ~
36468 \InsetSpace ~
36469 case 2: ...
36470  
36471 \newline
36472 \InsetSpace ~
36473 \InsetSpace ~
36474 case 3: ...
36475  
36476 \newline
36477 \InsetSpace ~
36478 \InsetSpace ~
36479 case 4: ...
36480  
36481 \newline
36482 \InsetSpace ~
36483 \InsetSpace ~
36484 case 5: ...
36485  
36486 \newline
36487 \InsetSpace ~
36488 \InsetSpace ~
36489 case 6: ...
36490  
36491 \newline
36492 \InsetSpace ~
36493 \InsetSpace ~
36494 case 7: ...
36495  
36496 \newline
36497 }
36498 \end_layout
36499
36500 \begin_layout Standard
36501 and
36502 \end_layout
36503
36504 \begin_layout Verse
36505
36506 \family typewriter
36507 switch (i) { 
36508 \newline
36509 \InsetSpace ~
36510 \InsetSpace ~
36511 case 101: ...
36512  
36513 \newline
36514 \InsetSpace ~
36515 \InsetSpace ~
36516 case 102: ...
36517  
36518 \newline
36519 \InsetSpace ~
36520 \InsetSpace ~
36521 case 103: ...
36522  
36523 \newline
36524 \InsetSpace ~
36525 \InsetSpace ~
36526 case 104: ...
36527  
36528 \newline
36529 \InsetSpace ~
36530 \InsetSpace ~
36531 case 105: ...
36532  
36533 \newline
36534 \InsetSpace ~
36535 \InsetSpace ~
36536 case 106: ...
36537  
36538 \newline
36539 \InsetSpace ~
36540 \InsetSpace ~
36541 case 107: ...
36542  
36543 \newline
36544 }
36545 \end_layout
36546
36547 \begin_layout Standard
36548 then both the switch statements will be implemented using jump-tables whereas
36549  the unmodified switch statement will not be.
36550 \end_layout
36551
36552 \begin_layout Standard
36553 \begin_inset Note Note
36554 status collapsed
36555
36556 \begin_layout Standard
36557 There might be reasons which SDCC cannot know about to either favour or
36558  not favour jump tables.
36559  If the target system has to be as quick for the last switch case as for
36560  the first (pro jump table), or if the switch argument is known to be zero
36561  in the majority of the cases (contra jump table).
36562 \end_layout
36563
36564 \end_inset
36565
36566
36567 \end_layout
36568
36569 \begin_layout Standard
36570 The pragma nojtbound
36571 \begin_inset LatexCommand index
36572 name "\\#pragma nojtbound"
36573
36574 \end_inset
36575
36576  can be used to turn off checking the 
36577 \emph on
36578 j
36579 \emph default
36580 ump 
36581 \emph on
36582 t
36583 \emph default
36584 able 
36585 \emph on
36586 bound
36587 \emph default
36588 aries.
36589  It has no effect if a default label is supplied.
36590  Use of this pragma is dangerous: if the switch
36591 \begin_inset LatexCommand index
36592 name "switch statement"
36593
36594 \end_inset
36595
36596  argument is not matched by a case statement the processor will happily
36597  jump into Nirvana.
36598 \end_layout
36599
36600 \begin_layout Subsection
36601 Bit-shifting Operations
36602 \begin_inset LatexCommand index
36603 name "Bit shifting"
36604
36605 \end_inset
36606
36607 .
36608 \end_layout
36609
36610 \begin_layout Standard
36611 Bit shifting is one of the most frequently used operation in embedded programmin
36612 g.
36613  SDCC tries to implement bit-shift operations in the most efficient way
36614  possible, e.g.:
36615 \end_layout
36616
36617 \begin_layout Verse
36618
36619 \family typewriter
36620 unsigned char i;
36621 \newline
36622 ...
36623  
36624 \newline
36625 i >>= 4; 
36626 \newline
36627 ...
36628 \end_layout
36629
36630 \begin_layout Standard
36631 generates the following code:
36632 \end_layout
36633
36634 \begin_layout Verse
36635
36636 \family typewriter
36637 mov\InsetSpace ~
36638  a,_i 
36639 \newline
36640 swap a 
36641 \newline
36642 anl\InsetSpace ~
36643  a,#0x0f 
36644 \newline
36645 mov\InsetSpace ~
36646  _i,a
36647 \end_layout
36648
36649 \begin_layout Standard
36650 In general SDCC will never setup a loop if the shift count is known.
36651  Another example:
36652 \end_layout
36653
36654 \begin_layout Verse
36655
36656 \family typewriter
36657 unsigned int i; 
36658 \newline
36659 ...
36660  
36661 \newline
36662 i >>= 9; 
36663 \newline
36664 ...
36665 \end_layout
36666
36667 \begin_layout Standard
36668 will generate:
36669 \end_layout
36670
36671 \begin_layout Verse
36672
36673 \family typewriter
36674 mov\InsetSpace ~
36675 \InsetSpace ~
36676 a,(_i + 1) 
36677 \newline
36678 mov\InsetSpace ~
36679 \InsetSpace ~
36680 (_i + 1),#0x00 
36681 \newline
36682 clr\InsetSpace ~
36683 \InsetSpace ~
36684
36685 \newline
36686 rrc\InsetSpace ~
36687 \InsetSpace ~
36688
36689 \newline
36690 mov\InsetSpace ~
36691 \InsetSpace ~
36692 _i,a
36693 \end_layout
36694
36695 \begin_layout Subsection
36696 Bit-rotation
36697 \begin_inset LatexCommand index
36698 name "Bit rotation"
36699
36700 \end_inset
36701
36702
36703 \end_layout
36704
36705 \begin_layout Standard
36706 A special case of the bit-shift operation is bit rotation
36707 \begin_inset LatexCommand index
36708 name "rotating bits"
36709
36710 \end_inset
36711
36712 , SDCC recognizes the following expression to be a left bit-rotation:
36713 \end_layout
36714
36715 \begin_layout Verse
36716
36717 \family typewriter
36718 \series bold
36719 unsigned
36720 \series default
36721 \InsetSpace ~
36722 \InsetSpace ~
36723 char i;\InsetSpace ~
36724 \InsetSpace ~
36725 \InsetSpace ~
36726 \InsetSpace ~
36727 \InsetSpace ~
36728 \InsetSpace ~
36729 \InsetSpace ~
36730 \InsetSpace ~
36731 \InsetSpace ~
36732 \InsetSpace ~
36733 \InsetSpace ~
36734 /* unsigned is needed for rotation */ 
36735 \newline
36736 ...
36737  
36738 \newline
36739 i = ((i << 1) | (i >> 7));
36740 \family default
36741  
36742 \newline
36743
36744 \family typewriter
36745 ...
36746 \end_layout
36747
36748 \begin_layout Standard
36749 will generate the following code:
36750 \end_layout
36751
36752 \begin_layout Verse
36753
36754 \family typewriter
36755 mov\InsetSpace ~
36756 \InsetSpace ~
36757 a,_i 
36758 \newline
36759 rl\InsetSpace ~
36760 \InsetSpace ~
36761 \InsetSpace ~
36762
36763 \newline
36764 mov\InsetSpace ~
36765 \InsetSpace ~
36766 _i,a
36767 \end_layout
36768
36769 \begin_layout Standard
36770 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
36771 ns of this case will also be recognized as bit-rotation, i.e.: 
36772 \end_layout
36773
36774 \begin_layout Verse
36775
36776 \family typewriter
36777 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
36778 \end_layout
36779
36780 \begin_layout Subsection
36781 Nibble and Byte Swapping
36782 \end_layout
36783
36784 \begin_layout Standard
36785 Other special cases of the bit-shift operations are nibble or byte swapping
36786 \begin_inset LatexCommand index
36787 name "swapping nibbles/bytes"
36788
36789 \end_inset
36790
36791 , SDCC recognizes the following expressions:
36792 \end_layout
36793
36794 \begin_layout Verse
36795
36796 \family typewriter
36797 \series bold
36798 unsigned
36799 \series default
36800 \InsetSpace ~
36801 \InsetSpace ~
36802 char i; 
36803 \newline
36804
36805 \series bold
36806 unsigned
36807 \series default
36808 \InsetSpace ~
36809 \InsetSpace ~
36810 int j; 
36811 \newline
36812 ...
36813  
36814 \newline
36815 i = ((i << 4) | (i >> 4));
36816 \family default
36817  
36818 \newline
36819
36820 \family typewriter
36821 j = ((j << 8) | (j >> 8)); 
36822 \end_layout
36823
36824 \begin_layout Standard
36825 and generates a swap instruction for the nibble swapping
36826 \begin_inset LatexCommand index
36827 name "Nibble swapping"
36828
36829 \end_inset
36830
36831  or move instructions for the byte swapping
36832 \begin_inset LatexCommand index
36833 name "Byte swapping"
36834
36835 \end_inset
36836
36837 .
36838  The 
36839 \begin_inset Quotes sld
36840 \end_inset
36841
36842 j
36843 \begin_inset Quotes srd
36844 \end_inset
36845
36846  example can be used to convert from little to big-endian or vice versa.
36847  If you want to change the endianness of a 
36848 \emph on
36849 signed
36850 \emph default
36851  integer you have to cast to 
36852 \family typewriter
36853 (unsigned int)
36854 \family default
36855  first.
36856 \end_layout
36857
36858 \begin_layout Standard
36859 Note that SDCC stores numbers in little-endian
36860 \begin_inset Foot
36861 status open
36862
36863 \begin_layout Standard
36864 Usually 8-bit processors don't care much about endianness.
36865  This is not the case for the standard 8051 which only has an instruction
36866  to increment its 
36867 \emph on
36868 dptr
36869 \emph default
36870
36871 \begin_inset LatexCommand index
36872 name "DPTR"
36873
36874 \end_inset
36875
36876 -datapointer so little-endian is the more efficient byte order.
36877 \end_layout
36878
36879 \end_inset
36880
36881
36882 \begin_inset LatexCommand index
36883 name "little-endian"
36884
36885 \end_inset
36886
36887
36888 \begin_inset LatexCommand index
36889 name "Endianness"
36890
36891 \end_inset
36892
36893  format (i.e.
36894  lowest order first).
36895 \end_layout
36896
36897 \begin_layout Subsection
36898 Highest Order Bit
36899 \begin_inset LatexCommand index
36900 name "Highest Order Bit"
36901
36902 \end_inset
36903
36904  / Any Order Bit
36905 \begin_inset LatexCommand index
36906 name "Any Order Bit"
36907
36908 \end_inset
36909
36910
36911 \end_layout
36912
36913 \begin_layout Standard
36914 It is frequently required to obtain the highest order bit of an integral
36915  type (long, int, short or char types).
36916  Also obtaining any other order bit is not uncommon.
36917  SDCC recognizes the following expressions to yield the highest order bit
36918  and generates optimized code for it, e.g.:
36919 \end_layout
36920
36921 \begin_layout Verse
36922
36923 \family typewriter
36924 unsigned int gint; 
36925 \newline
36926
36927 \newline
36928 foo () { 
36929 \newline
36930 \InsetSpace ~
36931 \InsetSpace ~
36932 unsigned char hob1, aob1; 
36933 \newline
36934 \InsetSpace ~
36935 \InsetSpace ~
36936 bit hob2, hob3, aob2,
36937  aob3; 
36938 \newline
36939 \InsetSpace ~
36940 \InsetSpace ~
36941 ...
36942  
36943 \newline
36944 \InsetSpace ~
36945 \InsetSpace ~
36946 hob1 = (gint >> 15) & 1; 
36947 \newline
36948 \InsetSpace ~
36949 \InsetSpace ~
36950 hob2 = (gint >> 15) & 1; 
36951 \newline
36952 \InsetSpace ~
36953 \InsetSpace ~
36954 hob3 = gint & 0x8000;
36955  
36956 \newline
36957 \InsetSpace ~
36958 \InsetSpace ~
36959 aob1 = (gint >> 9) & 1; 
36960 \newline
36961 \InsetSpace ~
36962 \InsetSpace ~
36963 aob2 = (gint >> 8) & 1; 
36964 \newline
36965 \InsetSpace ~
36966 \InsetSpace ~
36967 aob3 = gint & 0x0800; 
36968 \newline
36969 \InsetSpace ~
36970 \InsetSpace ~
36971 ..
36972  
36973 \newline
36974 }
36975 \end_layout
36976
36977 \begin_layout Standard
36978 will generate the following code:
36979 \end_layout
36980
36981 \begin_layout Verse
36982
36983 \family typewriter
36984 \InsetSpace ~
36985 \InsetSpace ~
36986 \InsetSpace ~
36987 \InsetSpace ~
36988 \InsetSpace ~
36989 \InsetSpace ~
36990 \InsetSpace ~
36991 \InsetSpace ~
36992 \InsetSpace ~
36993 \InsetSpace ~
36994 \InsetSpace ~
36995 \InsetSpace ~
36996 \InsetSpace ~
36997 \InsetSpace ~
36998 \InsetSpace ~
36999 \InsetSpace ~
37000 \InsetSpace ~
37001 \InsetSpace ~
37002 \InsetSpace ~
37003 \InsetSpace ~
37004 \InsetSpace ~
37005 \InsetSpace ~
37006 \InsetSpace ~
37007 \InsetSpace ~
37008 \InsetSpace ~
37009  61 ;\InsetSpace ~
37010  hob.c 7 
37011 \newline
37012 000A E5*01\InsetSpace ~
37013 \InsetSpace ~
37014 \InsetSpace ~
37015 \InsetSpace ~
37016 \InsetSpace ~
37017 \InsetSpace ~
37018 \InsetSpace ~
37019 \InsetSpace ~
37020 \InsetSpace ~
37021 \InsetSpace ~
37022 \InsetSpace ~
37023 \InsetSpace ~
37024 \InsetSpace ~
37025 \InsetSpace ~
37026 \InsetSpace ~
37027  62\InsetSpace ~
37028 \InsetSpace ~
37029 \InsetSpace ~
37030 \InsetSpace ~
37031 \InsetSpace ~
37032 \InsetSpace ~
37033 \InsetSpace ~
37034 \InsetSpace ~
37035  mov\InsetSpace ~
37036 \InsetSpace ~
37037  a,(_gint + 1) 
37038 \newline
37039 000C 23\InsetSpace ~
37040 \InsetSpace ~
37041 \InsetSpace ~
37042 \InsetSpace ~
37043 \InsetSpace ~
37044 \InsetSpace ~
37045 \InsetSpace ~
37046 \InsetSpace ~
37047 \InsetSpace ~
37048 \InsetSpace ~
37049 \InsetSpace ~
37050 \InsetSpace ~
37051 \InsetSpace ~
37052 \InsetSpace ~
37053 \InsetSpace ~
37054 \InsetSpace ~
37055 \InsetSpace ~
37056 \InsetSpace ~
37057  63\InsetSpace ~
37058 \InsetSpace ~
37059 \InsetSpace ~
37060 \InsetSpace ~
37061 \InsetSpace ~
37062 \InsetSpace ~
37063 \InsetSpace ~
37064 \InsetSpace ~
37065  rl\InsetSpace ~
37066 \InsetSpace ~
37067 \InsetSpace ~
37068  a 
37069 \newline
37070 000D 54 01\InsetSpace ~
37071 \InsetSpace ~
37072 \InsetSpace ~
37073 \InsetSpace ~
37074 \InsetSpace ~
37075 \InsetSpace ~
37076 \InsetSpace ~
37077 \InsetSpace ~
37078 \InsetSpace ~
37079 \InsetSpace ~
37080 \InsetSpace ~
37081 \InsetSpace ~
37082 \InsetSpace ~
37083 \InsetSpace ~
37084 \InsetSpace ~
37085
37086  64\InsetSpace ~
37087 \InsetSpace ~
37088 \InsetSpace ~
37089 \InsetSpace ~
37090 \InsetSpace ~
37091 \InsetSpace ~
37092 \InsetSpace ~
37093 \InsetSpace ~
37094  anl\InsetSpace ~
37095 \InsetSpace ~
37096  a,#0x01 
37097 \newline
37098 000F F5*02\InsetSpace ~
37099 \InsetSpace ~
37100 \InsetSpace ~
37101 \InsetSpace ~
37102 \InsetSpace ~
37103 \InsetSpace ~
37104 \InsetSpace ~
37105 \InsetSpace ~
37106 \InsetSpace ~
37107 \InsetSpace ~
37108 \InsetSpace ~
37109 \InsetSpace ~
37110 \InsetSpace ~
37111 \InsetSpace ~
37112 \InsetSpace ~
37113  65\InsetSpace ~
37114 \InsetSpace ~
37115 \InsetSpace ~
37116 \InsetSpace ~
37117 \InsetSpace ~
37118 \InsetSpace ~
37119 \InsetSpace ~
37120 \InsetSpace ~
37121  mov\InsetSpace ~
37122 \InsetSpace ~
37123  _foo_hob1_1_1,a 
37124 \newline
37125 \InsetSpace ~
37126 \InsetSpace ~
37127 \InsetSpace ~
37128 \InsetSpace ~
37129 \InsetSpace ~
37130 \InsetSpace ~
37131 \InsetSpace ~
37132 \InsetSpace ~
37133 \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 \InsetSpace ~
37149 \InsetSpace ~
37150  66 ;\InsetSpace ~
37151  hob.c 8 
37152 \newline
37153 0011 E5*01\InsetSpace ~
37154 \InsetSpace ~
37155 \InsetSpace ~
37156 \InsetSpace ~
37157 \InsetSpace ~
37158 \InsetSpace ~
37159 \InsetSpace ~
37160 \InsetSpace ~
37161 \InsetSpace ~
37162 \InsetSpace ~
37163 \InsetSpace ~
37164 \InsetSpace ~
37165 \InsetSpace ~
37166 \InsetSpace ~
37167 \InsetSpace ~
37168
37169  67\InsetSpace ~
37170 \InsetSpace ~
37171 \InsetSpace ~
37172 \InsetSpace ~
37173 \InsetSpace ~
37174 \InsetSpace ~
37175 \InsetSpace ~
37176 \InsetSpace ~
37177  mov\InsetSpace ~
37178 \InsetSpace ~
37179  a,(_gint + 1) 
37180 \newline
37181 0013 33\InsetSpace ~
37182 \InsetSpace ~
37183 \InsetSpace ~
37184 \InsetSpace ~
37185 \InsetSpace ~
37186 \InsetSpace ~
37187 \InsetSpace ~
37188 \InsetSpace ~
37189 \InsetSpace ~
37190 \InsetSpace ~
37191 \InsetSpace ~
37192 \InsetSpace ~
37193 \InsetSpace ~
37194 \InsetSpace ~
37195 \InsetSpace ~
37196 \InsetSpace ~
37197 \InsetSpace ~
37198 \InsetSpace ~
37199  68\InsetSpace ~
37200 \InsetSpace ~
37201 \InsetSpace ~
37202 \InsetSpace ~
37203 \InsetSpace ~
37204 \InsetSpace ~
37205 \InsetSpace ~
37206 \InsetSpace ~
37207  rlc\InsetSpace ~
37208 \InsetSpace ~
37209  a 
37210 \newline
37211 0014 92*00\InsetSpace ~
37212 \InsetSpace ~
37213 \InsetSpace ~
37214 \InsetSpace ~
37215 \InsetSpace ~
37216 \InsetSpace ~
37217 \InsetSpace ~
37218 \InsetSpace ~
37219 \InsetSpace ~
37220 \InsetSpace ~
37221 \InsetSpace ~
37222 \InsetSpace ~
37223 \InsetSpace ~
37224 \InsetSpace ~
37225 \InsetSpace ~
37226  69\InsetSpace ~
37227 \InsetSpace ~
37228 \InsetSpace ~
37229 \InsetSpace ~
37230 \InsetSpace ~
37231 \InsetSpace ~
37232 \InsetSpace ~
37233 \InsetSpace ~
37234  mov\InsetSpace ~
37235 \InsetSpace ~
37236  _foo_hob2_1_1,c
37237  
37238 \newline
37239 \InsetSpace ~
37240 \InsetSpace ~
37241 \InsetSpace ~
37242 \InsetSpace ~
37243 \InsetSpace ~
37244 \InsetSpace ~
37245 \InsetSpace ~
37246 \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 \InsetSpace ~
37262 \InsetSpace ~
37263 \InsetSpace ~
37264  66 ;\InsetSpace ~
37265  hob.c 9 
37266 \newline
37267 0016 E5*01\InsetSpace ~
37268 \InsetSpace ~
37269 \InsetSpace ~
37270 \InsetSpace ~
37271 \InsetSpace ~
37272 \InsetSpace ~
37273 \InsetSpace ~
37274 \InsetSpace ~
37275 \InsetSpace ~
37276 \InsetSpace ~
37277 \InsetSpace ~
37278 \InsetSpace ~
37279 \InsetSpace ~
37280 \InsetSpace ~
37281 \InsetSpace ~
37282  67\InsetSpace ~
37283 \InsetSpace ~
37284 \InsetSpace ~
37285 \InsetSpace ~
37286 \InsetSpace ~
37287 \InsetSpace ~
37288 \InsetSpace ~
37289 \InsetSpace ~
37290  mov\InsetSpace ~
37291 \InsetSpace ~
37292  a,(_gint + 1) 
37293 \newline
37294 0018 33\InsetSpace ~
37295 \InsetSpace ~
37296 \InsetSpace ~
37297 \InsetSpace ~
37298 \InsetSpace ~
37299 \InsetSpace ~
37300 \InsetSpace ~
37301 \InsetSpace ~
37302 \InsetSpace ~
37303 \InsetSpace ~
37304 \InsetSpace ~
37305 \InsetSpace ~
37306 \InsetSpace ~
37307 \InsetSpace ~
37308 \InsetSpace ~
37309 \InsetSpace ~
37310 \InsetSpace ~
37311 \InsetSpace ~
37312  68\InsetSpace ~
37313 \InsetSpace ~
37314 \InsetSpace ~
37315 \InsetSpace ~
37316 \InsetSpace ~
37317 \InsetSpace ~
37318 \InsetSpace ~
37319 \InsetSpace ~
37320  rlc\InsetSpace ~
37321 \InsetSpace ~
37322  a 
37323 \newline
37324 0019 92*01\InsetSpace ~
37325 \InsetSpace ~
37326 \InsetSpace ~
37327 \InsetSpace ~
37328 \InsetSpace ~
37329 \InsetSpace ~
37330 \InsetSpace ~
37331 \InsetSpace ~
37332 \InsetSpace ~
37333 \InsetSpace ~
37334 \InsetSpace ~
37335 \InsetSpace ~
37336 \InsetSpace ~
37337 \InsetSpace ~
37338 \InsetSpace ~
37339
37340  69\InsetSpace ~
37341 \InsetSpace ~
37342 \InsetSpace ~
37343 \InsetSpace ~
37344 \InsetSpace ~
37345 \InsetSpace ~
37346 \InsetSpace ~
37347 \InsetSpace ~
37348  mov\InsetSpace ~
37349 \InsetSpace ~
37350  _foo_hob3_1_1,c 
37351 \newline
37352 \InsetSpace ~
37353 \InsetSpace ~
37354 \InsetSpace ~
37355 \InsetSpace ~
37356 \InsetSpace ~
37357 \InsetSpace ~
37358 \InsetSpace ~
37359 \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 \InsetSpace ~
37375 \InsetSpace ~
37376 \InsetSpace ~
37377  70 ;\InsetSpace ~
37378  hob.c 10 
37379 \newline
37380 001B E5*01\InsetSpace ~
37381 \InsetSpace ~
37382 \InsetSpace ~
37383 \InsetSpace ~
37384 \InsetSpace ~
37385 \InsetSpace ~
37386 \InsetSpace ~
37387 \InsetSpace ~
37388 \InsetSpace ~
37389 \InsetSpace ~
37390 \InsetSpace ~
37391 \InsetSpace ~
37392 \InsetSpace ~
37393 \InsetSpace ~
37394 \InsetSpace ~
37395  71\InsetSpace ~
37396 \InsetSpace ~
37397 \InsetSpace ~
37398 \InsetSpace ~
37399 \InsetSpace ~
37400 \InsetSpace ~
37401 \InsetSpace ~
37402 \InsetSpace ~
37403  mov\InsetSpace ~
37404 \InsetSpace ~
37405  a,(_gint + 1) 
37406 \newline
37407 001D
37408  03\InsetSpace ~
37409 \InsetSpace ~
37410 \InsetSpace ~
37411 \InsetSpace ~
37412 \InsetSpace ~
37413 \InsetSpace ~
37414 \InsetSpace ~
37415 \InsetSpace ~
37416 \InsetSpace ~
37417 \InsetSpace ~
37418 \InsetSpace ~
37419 \InsetSpace ~
37420 \InsetSpace ~
37421 \InsetSpace ~
37422 \InsetSpace ~
37423 \InsetSpace ~
37424 \InsetSpace ~
37425 \InsetSpace ~
37426  72\InsetSpace ~
37427 \InsetSpace ~
37428 \InsetSpace ~
37429 \InsetSpace ~
37430 \InsetSpace ~
37431 \InsetSpace ~
37432 \InsetSpace ~
37433 \InsetSpace ~
37434  rr\InsetSpace ~
37435 \InsetSpace ~
37436 \InsetSpace ~
37437  a 
37438 \newline
37439 001E 54 01\InsetSpace ~
37440 \InsetSpace ~
37441 \InsetSpace ~
37442 \InsetSpace ~
37443 \InsetSpace ~
37444 \InsetSpace ~
37445 \InsetSpace ~
37446 \InsetSpace ~
37447 \InsetSpace ~
37448 \InsetSpace ~
37449 \InsetSpace ~
37450 \InsetSpace ~
37451 \InsetSpace ~
37452 \InsetSpace ~
37453 \InsetSpace ~
37454  73\InsetSpace ~
37455 \InsetSpace ~
37456 \InsetSpace ~
37457 \InsetSpace ~
37458 \InsetSpace ~
37459 \InsetSpace ~
37460 \InsetSpace ~
37461 \InsetSpace ~
37462  anl\InsetSpace ~
37463 \InsetSpace ~
37464  a,#0x01 
37465 \newline
37466 0020 F5*03\InsetSpace ~
37467 \InsetSpace ~
37468 \InsetSpace ~
37469 \InsetSpace ~
37470 \InsetSpace ~
37471 \InsetSpace ~
37472 \InsetSpace ~
37473 \InsetSpace ~
37474 \InsetSpace ~
37475 \InsetSpace ~
37476 \InsetSpace ~
37477 \InsetSpace ~
37478 \InsetSpace ~
37479 \InsetSpace ~
37480 \InsetSpace ~
37481  74\InsetSpace ~
37482 \InsetSpace ~
37483 \InsetSpace ~
37484 \InsetSpace ~
37485 \InsetSpace ~
37486 \InsetSpace ~
37487 \InsetSpace ~
37488 \InsetSpace ~
37489  mov\InsetSpace ~
37490 \InsetSpace ~
37491  _foo_aob1_1_1,a
37492  
37493 \newline
37494 \InsetSpace ~
37495 \InsetSpace ~
37496 \InsetSpace ~
37497 \InsetSpace ~
37498 \InsetSpace ~
37499 \InsetSpace ~
37500 \InsetSpace ~
37501 \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 \InsetSpace ~
37517 \InsetSpace ~
37518 \InsetSpace ~
37519  75 ;\InsetSpace ~
37520  hob.c 11 
37521 \newline
37522 0022 E5*01\InsetSpace ~
37523 \InsetSpace ~
37524 \InsetSpace ~
37525 \InsetSpace ~
37526 \InsetSpace ~
37527 \InsetSpace ~
37528 \InsetSpace ~
37529 \InsetSpace ~
37530 \InsetSpace ~
37531 \InsetSpace ~
37532 \InsetSpace ~
37533 \InsetSpace ~
37534 \InsetSpace ~
37535 \InsetSpace ~
37536 \InsetSpace ~
37537  76\InsetSpace ~
37538 \InsetSpace ~
37539 \InsetSpace ~
37540 \InsetSpace ~
37541 \InsetSpace ~
37542 \InsetSpace ~
37543 \InsetSpace ~
37544 \InsetSpace ~
37545  mov\InsetSpace ~
37546 \InsetSpace ~
37547  a,(_gint + 1) 
37548 \newline
37549 0024 13\InsetSpace ~
37550 \InsetSpace ~
37551 \InsetSpace ~
37552 \InsetSpace ~
37553 \InsetSpace ~
37554 \InsetSpace ~
37555 \InsetSpace ~
37556 \InsetSpace ~
37557 \InsetSpace ~
37558 \InsetSpace ~
37559 \InsetSpace ~
37560 \InsetSpace ~
37561 \InsetSpace ~
37562 \InsetSpace ~
37563 \InsetSpace ~
37564 \InsetSpace ~
37565 \InsetSpace ~
37566 \InsetSpace ~
37567  77\InsetSpace ~
37568 \InsetSpace ~
37569 \InsetSpace ~
37570 \InsetSpace ~
37571 \InsetSpace ~
37572 \InsetSpace ~
37573 \InsetSpace ~
37574 \InsetSpace ~
37575  rrc\InsetSpace ~
37576 \InsetSpace ~
37577  a 
37578 \newline
37579 0025 92*02\InsetSpace ~
37580 \InsetSpace ~
37581 \InsetSpace ~
37582 \InsetSpace ~
37583 \InsetSpace ~
37584 \InsetSpace ~
37585 \InsetSpace ~
37586 \InsetSpace ~
37587 \InsetSpace ~
37588 \InsetSpace ~
37589 \InsetSpace ~
37590 \InsetSpace ~
37591 \InsetSpace ~
37592 \InsetSpace ~
37593 \InsetSpace ~
37594
37595  78\InsetSpace ~
37596 \InsetSpace ~
37597 \InsetSpace ~
37598 \InsetSpace ~
37599 \InsetSpace ~
37600 \InsetSpace ~
37601 \InsetSpace ~
37602 \InsetSpace ~
37603  mov\InsetSpace ~
37604 \InsetSpace ~
37605  _foo_aob2_1_1,c 
37606 \newline
37607 \InsetSpace ~
37608 \InsetSpace ~
37609 \InsetSpace ~
37610 \InsetSpace ~
37611 \InsetSpace ~
37612 \InsetSpace ~
37613 \InsetSpace ~
37614 \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 \InsetSpace ~
37630 \InsetSpace ~
37631 \InsetSpace ~
37632  79 ;\InsetSpace ~
37633  hob.c 12 
37634 \newline
37635 0027 E5*01\InsetSpace ~
37636 \InsetSpace ~
37637 \InsetSpace ~
37638 \InsetSpace ~
37639 \InsetSpace ~
37640 \InsetSpace ~
37641 \InsetSpace ~
37642 \InsetSpace ~
37643 \InsetSpace ~
37644 \InsetSpace ~
37645 \InsetSpace ~
37646 \InsetSpace ~
37647 \InsetSpace ~
37648 \InsetSpace ~
37649 \InsetSpace ~
37650  80\InsetSpace ~
37651 \InsetSpace ~
37652 \InsetSpace ~
37653 \InsetSpace ~
37654 \InsetSpace ~
37655 \InsetSpace ~
37656 \InsetSpace ~
37657 \InsetSpace ~
37658  mov\InsetSpace ~
37659 \InsetSpace ~
37660  a,(_gint + 1) 
37661 \newline
37662 0029
37663  A2 E3\InsetSpace ~
37664 \InsetSpace ~
37665 \InsetSpace ~
37666 \InsetSpace ~
37667 \InsetSpace ~
37668 \InsetSpace ~
37669 \InsetSpace ~
37670 \InsetSpace ~
37671 \InsetSpace ~
37672 \InsetSpace ~
37673 \InsetSpace ~
37674 \InsetSpace ~
37675 \InsetSpace ~
37676 \InsetSpace ~
37677 \InsetSpace ~
37678  81\InsetSpace ~
37679 \InsetSpace ~
37680 \InsetSpace ~
37681 \InsetSpace ~
37682 \InsetSpace ~
37683 \InsetSpace ~
37684 \InsetSpace ~
37685 \InsetSpace ~
37686  mov\InsetSpace ~
37687 \InsetSpace ~
37688  c,acc[3] 
37689 \newline
37690 002B 92*03\InsetSpace ~
37691 \InsetSpace ~
37692 \InsetSpace ~
37693 \InsetSpace ~
37694 \InsetSpace ~
37695 \InsetSpace ~
37696 \InsetSpace ~
37697 \InsetSpace ~
37698 \InsetSpace ~
37699 \InsetSpace ~
37700 \InsetSpace ~
37701 \InsetSpace ~
37702 \InsetSpace ~
37703 \InsetSpace ~
37704 \InsetSpace ~
37705  82\InsetSpace ~
37706 \InsetSpace ~
37707 \InsetSpace ~
37708 \InsetSpace ~
37709 \InsetSpace ~
37710 \InsetSpace ~
37711 \InsetSpace ~
37712 \InsetSpace ~
37713  mov\InsetSpace ~
37714 \InsetSpace ~
37715  _foo_aob3_1_1,c 
37716 \end_layout
37717
37718 \begin_layout Standard
37719 Other variations of these cases however will 
37720 \emph on
37721 not
37722 \emph default
37723  be recognized.
37724  They are standard C expressions, so I heartily recommend these be the only
37725  way to get the highest order bit, (it is portable).
37726  Of course it will be recognized even if it is embedded in other expressions,
37727  e.g.:
37728 \end_layout
37729
37730 \begin_layout Verse
37731
37732 \family typewriter
37733 xyz = gint + ((gint >> 15) & 1);
37734 \end_layout
37735
37736 \begin_layout Standard
37737 will still be recognized.
37738 \end_layout
37739
37740 \begin_layout Subsection
37741 Higher Order Byte
37742 \begin_inset LatexCommand index
37743 name "Higher Order Byte"
37744
37745 \end_inset
37746
37747  / Higher Order Word
37748 \begin_inset LatexCommand index
37749 name "Higher Order Word"
37750
37751 \end_inset
37752
37753
37754 \end_layout
37755
37756 \begin_layout Standard
37757 It is also frequently required to obtain a higher order byte or word of
37758  a larger integral type (long, int or short types).
37759  SDCC recognizes the following expressions to yield the higher order byte
37760  or word and generates optimized code for it, e.g.:
37761 \end_layout
37762
37763 \begin_layout Verse
37764
37765 \family typewriter
37766 unsigned int gint; 
37767 \newline
37768 unsigned long int glong; 
37769 \newline
37770
37771 \newline
37772 foo () { 
37773 \newline
37774 \InsetSpace ~
37775 \InsetSpace ~
37776 unsigned char hob1,
37777  hob2; 
37778 \newline
37779 \InsetSpace ~
37780 \InsetSpace ~
37781 unsigned int how1, how2; 
37782 \newline
37783 \InsetSpace ~
37784 \InsetSpace ~
37785 ...
37786  
37787 \newline
37788 \InsetSpace ~
37789 \InsetSpace ~
37790 hob1 = (gint >> 8) & 0xFF; 
37791 \newline
37792 \InsetSpace ~
37793 \InsetSpace ~
37794 hob2 = glong >> 24; 
37795 \newline
37796 \InsetSpace ~
37797 \InsetSpace ~
37798 how1 = (glong >> 16) & 0xFFFF;
37799  
37800 \newline
37801 \InsetSpace ~
37802 \InsetSpace ~
37803 how2 = glong >> 8; 
37804 \newline
37805 \InsetSpace ~
37806 \InsetSpace ~
37807 ..
37808  
37809 \newline
37810 }
37811 \end_layout
37812
37813 \begin_layout Standard
37814 will generate the following code:
37815 \end_layout
37816
37817 \begin_layout Verse
37818
37819 \family typewriter
37820 \InsetSpace ~
37821 \InsetSpace ~
37822 \InsetSpace ~
37823 \InsetSpace ~
37824 \InsetSpace ~
37825 \InsetSpace ~
37826 \InsetSpace ~
37827 \InsetSpace ~
37828 \InsetSpace ~
37829 \InsetSpace ~
37830 \InsetSpace ~
37831 \InsetSpace ~
37832 \InsetSpace ~
37833 \InsetSpace ~
37834 \InsetSpace ~
37835 \InsetSpace ~
37836 \InsetSpace ~
37837 \InsetSpace ~
37838 \InsetSpace ~
37839 \InsetSpace ~
37840 \InsetSpace ~
37841 \InsetSpace ~
37842 \InsetSpace ~
37843 \InsetSpace ~
37844 \InsetSpace ~
37845  91 ;\InsetSpace ~
37846  hob.c 15 
37847 \newline
37848 0037 85*01*06\InsetSpace ~
37849 \InsetSpace ~
37850 \InsetSpace ~
37851 \InsetSpace ~
37852 \InsetSpace ~
37853 \InsetSpace ~
37854 \InsetSpace ~
37855 \InsetSpace ~
37856 \InsetSpace ~
37857 \InsetSpace ~
37858 \InsetSpace ~
37859 \InsetSpace ~
37860  92\InsetSpace ~
37861 \InsetSpace ~
37862 \InsetSpace ~
37863 \InsetSpace ~
37864 \InsetSpace ~
37865 \InsetSpace ~
37866 \InsetSpace ~
37867 \InsetSpace ~
37868  mov\InsetSpace ~
37869 \InsetSpace ~
37870  _foo_hob1_1_1,(_gint + 1) 
37871 \newline
37872 \InsetSpace ~
37873 \InsetSpace ~
37874 \InsetSpace ~
37875 \InsetSpace ~
37876 \InsetSpace ~
37877 \InsetSpace ~
37878 \InsetSpace ~
37879 \InsetSpace ~
37880 \InsetSpace ~
37881 \InsetSpace ~
37882 \InsetSpace ~
37883 \InsetSpace ~
37884 \InsetSpace ~
37885 \InsetSpace ~
37886 \InsetSpace ~
37887 \InsetSpace ~
37888 \InsetSpace ~
37889 \InsetSpace ~
37890 \InsetSpace ~
37891 \InsetSpace ~
37892 \InsetSpace ~
37893 \InsetSpace ~
37894 \InsetSpace ~
37895 \InsetSpace ~
37896 \InsetSpace ~
37897  93 ;\InsetSpace ~
37898  hob.c
37899  16 
37900 \newline
37901 003A 85*05*07\InsetSpace ~
37902 \InsetSpace ~
37903 \InsetSpace ~
37904 \InsetSpace ~
37905 \InsetSpace ~
37906 \InsetSpace ~
37907 \InsetSpace ~
37908 \InsetSpace ~
37909 \InsetSpace ~
37910 \InsetSpace ~
37911 \InsetSpace ~
37912 \InsetSpace ~
37913  94\InsetSpace ~
37914 \InsetSpace ~
37915 \InsetSpace ~
37916 \InsetSpace ~
37917 \InsetSpace ~
37918 \InsetSpace ~
37919 \InsetSpace ~
37920 \InsetSpace ~
37921  mov\InsetSpace ~
37922 \InsetSpace ~
37923  _foo_hob2_1_1,(_glong + 3) 
37924 \newline
37925 \InsetSpace ~
37926 \InsetSpace ~
37927 \InsetSpace ~
37928 \InsetSpace ~
37929 \InsetSpace ~
37930 \InsetSpace ~
37931 \InsetSpace ~
37932 \InsetSpace ~
37933 \InsetSpace ~
37934 \InsetSpace ~
37935 \InsetSpace ~
37936 \InsetSpace ~
37937 \InsetSpace ~
37938 \InsetSpace ~
37939 \InsetSpace ~
37940 \InsetSpace ~
37941 \InsetSpace ~
37942 \InsetSpace ~
37943 \InsetSpace ~
37944 \InsetSpace ~
37945 \InsetSpace ~
37946 \InsetSpace ~
37947 \InsetSpace ~
37948 \InsetSpace ~
37949 \InsetSpace ~
37950  95 ;\InsetSpace ~
37951  hob.c 17 
37952 \newline
37953 003D 85*04*08\InsetSpace ~
37954 \InsetSpace ~
37955 \InsetSpace ~
37956 \InsetSpace ~
37957 \InsetSpace ~
37958 \InsetSpace ~
37959 \InsetSpace ~
37960 \InsetSpace ~
37961 \InsetSpace ~
37962 \InsetSpace ~
37963 \InsetSpace ~
37964 \InsetSpace ~
37965
37966  96\InsetSpace ~
37967 \InsetSpace ~
37968 \InsetSpace ~
37969 \InsetSpace ~
37970 \InsetSpace ~
37971 \InsetSpace ~
37972 \InsetSpace ~
37973 \InsetSpace ~
37974  mov\InsetSpace ~
37975 \InsetSpace ~
37976  _foo_how1_1_1,(_glong + 2) 
37977 \newline
37978 0040 85*05*09\InsetSpace ~
37979 \InsetSpace ~
37980 \InsetSpace ~
37981 \InsetSpace ~
37982 \InsetSpace ~
37983 \InsetSpace ~
37984 \InsetSpace ~
37985 \InsetSpace ~
37986 \InsetSpace ~
37987 \InsetSpace ~
37988 \InsetSpace ~
37989 \InsetSpace ~
37990  97\InsetSpace ~
37991 \InsetSpace ~
37992 \InsetSpace ~
37993 \InsetSpace ~
37994 \InsetSpace ~
37995 \InsetSpace ~
37996 \InsetSpace ~
37997 \InsetSpace ~
37998  mov\InsetSpace ~
37999 \InsetSpace ~
38000  (_foo_how1_1_1 +
38001  1),(_glong + 3) 
38002 \newline
38003 0043 85*03*0A\InsetSpace ~
38004 \InsetSpace ~
38005 \InsetSpace ~
38006 \InsetSpace ~
38007 \InsetSpace ~
38008 \InsetSpace ~
38009 \InsetSpace ~
38010 \InsetSpace ~
38011 \InsetSpace ~
38012 \InsetSpace ~
38013 \InsetSpace ~
38014 \InsetSpace ~
38015  98\InsetSpace ~
38016 \InsetSpace ~
38017 \InsetSpace ~
38018 \InsetSpace ~
38019 \InsetSpace ~
38020 \InsetSpace ~
38021 \InsetSpace ~
38022 \InsetSpace ~
38023  mov\InsetSpace ~
38024 \InsetSpace ~
38025  _foo_how2_1_1,(_glong + 1) 
38026 \newline
38027 0046 85*04*0B\InsetSpace ~
38028 \InsetSpace ~
38029 \InsetSpace ~
38030 \InsetSpace ~
38031 \InsetSpace ~
38032 \InsetSpace ~
38033 \InsetSpace ~
38034 \InsetSpace ~
38035 \InsetSpace ~
38036 \InsetSpace ~
38037 \InsetSpace ~
38038 \InsetSpace ~
38039
38040  99\InsetSpace ~
38041 \InsetSpace ~
38042 \InsetSpace ~
38043 \InsetSpace ~
38044 \InsetSpace ~
38045 \InsetSpace ~
38046 \InsetSpace ~
38047 \InsetSpace ~
38048  mov\InsetSpace ~
38049 \InsetSpace ~
38050  (_foo_how2_1_1 + 1),(_glong + 2) 
38051 \end_layout
38052
38053 \begin_layout Standard
38054 Again, variations of these cases may 
38055 \emph on
38056 not
38057 \emph default
38058  be recognized.
38059  They are standard C expressions, so I heartily recommend these be the only
38060  way to get the higher order byte/word, (it is portable).
38061  Of course it will be recognized even if it is embedded in other expressions,
38062  e.g.:
38063 \end_layout
38064
38065 \begin_layout Verse
38066
38067 \family typewriter
38068 xyz = gint + ((gint >> 8) & 0xFF);
38069 \end_layout
38070
38071 \begin_layout Standard
38072 will still be recognized.
38073 \end_layout
38074
38075 \begin_layout Subsection
38076 Peephole Optimizer
38077 \begin_inset LatexCommand label
38078 name "sub:Peephole-Optimizer"
38079
38080 \end_inset
38081
38082
38083 \begin_inset LatexCommand index
38084 name "Peephole optimizer"
38085
38086 \end_inset
38087
38088
38089 \end_layout
38090
38091 \begin_layout Standard
38092 The compiler uses a rule based, pattern matching and re-writing mechanism
38093  for peep-hole optimization.
38094  It is inspired by 
38095 \emph on
38096 copt
38097 \emph default
38098  a peep-hole optimizer by Christopher W.
38099  Fraser (cwfraser\InsetSpace ~
38100 @\InsetSpace ~
38101 microsoft.com).
38102  A default set of rules are compiled into the compiler, additional rules
38103  may be added with the 
38104 \emph on
38105 -
38106 \begin_inset ERT
38107 status collapsed
38108
38109 \begin_layout Standard
38110
38111
38112 \backslash
38113 /
38114 \end_layout
38115
38116 \end_inset
38117
38118 -peep-file
38119 \begin_inset LatexCommand index
38120 name "-\\/-peep-file"
38121
38122 \end_inset
38123
38124  <filename>
38125 \emph default
38126  option.
38127  The rule language is best illustrated with examples.
38128 \end_layout
38129
38130 \begin_layout Verse
38131
38132 \family typewriter
38133 replace { 
38134 \newline
38135 \InsetSpace ~
38136 \InsetSpace ~
38137 mov %1,a 
38138 \newline
38139 \InsetSpace ~
38140 \InsetSpace ~
38141 mov a,%1
38142 \newline
38143 } by {
38144 \newline
38145 \InsetSpace ~
38146 \InsetSpace ~
38147 mov %1,a
38148 \newline
38149 }
38150 \end_layout
38151
38152 \begin_layout Standard
38153 The above rule will change the following assembly
38154 \begin_inset LatexCommand index
38155 name "Assembler routines"
38156
38157 \end_inset
38158
38159  sequence:
38160 \end_layout
38161
38162 \begin_layout Verse
38163
38164 \family typewriter
38165 mov r1,a 
38166 \newline
38167 mov a,r1
38168 \end_layout
38169
38170 \begin_layout Standard
38171 to
38172 \end_layout
38173
38174 \begin_layout Verse
38175
38176 \family typewriter
38177 mov r1,a
38178 \end_layout
38179
38180 \begin_layout Standard
38181 Note: All occurrences of a 
38182 \emph on
38183 %n
38184 \emph default
38185  (pattern variable) must denote the same string.
38186  With the above rule, the assembly sequence:
38187 \end_layout
38188
38189 \begin_layout Verse
38190
38191 \family typewriter
38192 mov r1,a 
38193 \newline
38194 mov a,r2
38195 \end_layout
38196
38197 \begin_layout Standard
38198 will remain unmodified.
38199 \newline
38200
38201 \newline
38202 Other special case optimizations may be added by the
38203  user (via 
38204 \emph on
38205 -
38206 \begin_inset ERT
38207 status collapsed
38208
38209 \begin_layout Standard
38210
38211
38212 \backslash
38213 /
38214 \end_layout
38215
38216 \end_inset
38217
38218 -peep-file option
38219 \emph default
38220 ).
38221  E.g.
38222  some variants of the 8051 MCU
38223 \begin_inset LatexCommand index
38224 name "MCS51 variants"
38225
38226 \end_inset
38227
38228  allow only 
38229 \family typewriter
38230 ajmp
38231 \family default
38232  and 
38233 \family typewriter
38234 acall
38235 \family default
38236 .
38237  The following two rules will change all 
38238 \family typewriter
38239 ljmp
38240 \family default
38241  and 
38242 \family typewriter
38243 lcall
38244 \family default
38245  to 
38246 \family typewriter
38247 ajmp
38248 \family default
38249  and 
38250 \family typewriter
38251 acall
38252 \end_layout
38253
38254 \begin_layout Verse
38255
38256 \family typewriter
38257 replace { lcall %1 } by { acall %1 } 
38258 \newline
38259 replace { ljmp %1 } by { ajmp %1 }
38260 \end_layout
38261
38262 \begin_layout Standard
38263 (NOTE: from version 2.7.3 on, you can use option -
38264 \emph on
38265
38266 \begin_inset ERT
38267 status collapsed
38268
38269 \begin_layout Standard
38270
38271
38272 \backslash
38273 /
38274 \end_layout
38275
38276 \end_inset
38277
38278
38279 \emph default
38280 -acall-ajmp
38281 \begin_inset LatexCommand index
38282 name "-\\/-acall-ajmp"
38283
38284 \end_inset
38285
38286 , which also takes care of aligning the interrupt vectors properly.)
38287 \newline
38288
38289 \end_layout
38290
38291 \begin_layout Standard
38292 The 
38293 \emph on
38294 inline-assembler code
38295 \emph default
38296  is also passed through the peep hole optimizer, thus the peephole optimizer
38297  can also be used as an assembly level macro expander.
38298  The rules themselves are MCU dependent whereas the rule language infra-structur
38299 e is MCU independent.
38300  Peephole optimization rules for other MCU can be easily programmed using
38301  the rule language.
38302 \newline
38303
38304 \newline
38305 The syntax for a rule is as follows:
38306 \end_layout
38307
38308 \begin_layout Verse
38309
38310 \family typewriter
38311 rule := replace [ restart ] '{' <assembly sequence> '
38312 \backslash
38313 n' 
38314 \newline
38315 \InsetSpace ~
38316  \InsetSpace ~
38317  \InsetSpace ~
38318  \InsetSpace ~
38319  \InsetSpace ~
38320  \InsetSpace ~
38321  \InsetSpace ~
38322  \InsetSpace ~
38323  \InsetSpace ~
38324  \InsetSpace ~
38325  \InsetSpace ~
38326  \InsetSpace ~
38327  \InsetSpace ~
38328  \InsetSpace ~
38329  '}' by '{' '
38330 \backslash
38331 n' 
38332 \newline
38333 \InsetSpace ~
38334  \InsetSpace ~
38335  \InsetSpace ~
38336  \InsetSpace ~
38337  \InsetSpace ~
38338  \InsetSpace ~
38339  \InsetSpace ~
38340  \InsetSpace ~
38341  \InsetSpace ~
38342  \InsetSpace ~
38343  \InsetSpace ~
38344  \InsetSpace ~
38345  \InsetSpace ~
38346  \InsetSpace ~
38347  \InsetSpace ~
38348  \InsetSpace ~
38349  <assembly sequence> '
38350 \backslash
38351 n' 
38352 \newline
38353 \InsetSpace ~
38354  \InsetSpace ~
38355  \InsetSpace ~
38356  \InsetSpace ~
38357  \InsetSpace ~
38358  \InsetSpace ~
38359  \InsetSpace ~
38360  \InsetSpace ~
38361  \InsetSpace ~
38362  \InsetSpace ~
38363  \InsetSpace ~
38364  \InsetSpace ~
38365  \InsetSpace ~
38366  \InsetSpace ~
38367  '}' [if <functionName> ] '
38368 \backslash
38369 n' 
38370 \end_layout
38371
38372 \begin_layout Standard
38373 <assembly sequence> := assembly instruction (each instruction including
38374  labels must be on a separate line).
38375 \newline
38376
38377 \newline
38378 The optimizer will apply to the rules
38379  one by one from the top in the sequence of their appearance, it will terminate
38380  when all rules are exhausted.
38381  If the 'restart' option is specified, then the optimizer will start matching
38382  the rules again from the top, this option for a rule is expensive (performance)
38383 , it is intended to be used in situations where a transformation will trigger
38384  the same rule again.
38385  An example of this (not a good one, it has side effects) is the following
38386  rule:
38387 \end_layout
38388
38389 \begin_layout Verse
38390
38391 \family typewriter
38392 replace restart { 
38393 \newline
38394 \InsetSpace ~
38395 \InsetSpace ~
38396 pop %1 
38397 \newline
38398 \InsetSpace ~
38399 \InsetSpace ~
38400 push %1 } by { 
38401 \newline
38402 \InsetSpace ~
38403 \InsetSpace ~
38404 ; nop 
38405 \newline
38406 }
38407 \end_layout
38408
38409 \begin_layout Standard
38410 Note that the replace pattern cannot be a blank, but can be a comment line.
38411  Without the 'restart' option only the innermost 'pop' 'push' pair would
38412  be eliminated, i.e.:
38413 \end_layout
38414
38415 \begin_layout Verse
38416
38417 \family typewriter
38418 pop ar1 
38419 \newline
38420 pop ar2 
38421 \newline
38422 push ar2 
38423 \newline
38424 push ar1
38425 \end_layout
38426
38427 \begin_layout Standard
38428 would result in:
38429 \end_layout
38430
38431 \begin_layout Verse
38432
38433 \family typewriter
38434 pop ar1 
38435 \newline
38436 ; nop 
38437 \newline
38438 push ar1
38439 \end_layout
38440
38441 \begin_layout Standard
38442
38443 \emph on
38444 with
38445 \emph default
38446  the restart option the rule will be applied again to the resulting code
38447  and then all the pop-push pairs will be eliminated to yield:
38448 \end_layout
38449
38450 \begin_layout Verse
38451
38452 \family typewriter
38453 ; nop 
38454 \newline
38455 ; nop
38456 \end_layout
38457
38458 \begin_layout Standard
38459 A conditional function can be attached to a rule.
38460  Attaching rules are somewhat more involved, let me illustrate this with
38461  an example.
38462 \end_layout
38463
38464 \begin_layout Verse
38465
38466 \family typewriter
38467 replace { 
38468 \newline
38469 \InsetSpace ~
38470  \InsetSpace ~
38471  \InsetSpace ~
38472 ljmp %5 
38473 \newline
38474 %2:
38475 \newline
38476 } by { 
38477 \newline
38478 \InsetSpace ~
38479  \InsetSpace ~
38480  \InsetSpace ~
38481 sjmp %5 
38482 \newline
38483 %2:
38484 \newline
38485 } if labelInRange
38486 \end_layout
38487
38488 \begin_layout Standard
38489 The optimizer does a look-up of a function name table defined in function
38490  
38491 \emph on
38492 callFuncByName
38493 \emph default
38494  in the source file SDCCpeeph.c, with the name 
38495 \emph on
38496 labelInRange
38497 \emph default
38498 .
38499  If it finds a corresponding entry the function is called.
38500  Note there can be no parameters specified for these functions, in this
38501  case the use of 
38502 \emph on
38503 %5
38504 \emph default
38505  is crucial, since the function 
38506 \emph on
38507 labelInRange
38508 \emph default
38509  expects to find the label in that particular variable (the hash table containin
38510 g the variable bindings is passed as a parameter).
38511  If you want to code more such functions, take a close look at the function
38512  labelInRange and the calling mechanism in source file SDCCpeeph.c.
38513  Currently implemented are 
38514 \emph on
38515 labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
38516  24bitMode, portIsDS390, 24bitModeAndPortDS390
38517 \emph default
38518  and 
38519 \emph on
38520 notVolatile
38521 \emph default
38522 .
38523 \end_layout
38524
38525 \begin_layout Standard
38526 I know this whole thing is a little kludgey, but maybe some day we will
38527  have some better means.
38528  If you are looking at this file, you will see the default rules that are
38529  compiled into the compiler, you can add your own rules in the default set
38530  there if you get tired of specifying the -
38531 \begin_inset ERT
38532 status collapsed
38533
38534 \begin_layout Standard
38535
38536
38537 \backslash
38538 /
38539 \end_layout
38540
38541 \end_inset
38542
38543 -peep-file option.
38544 \end_layout
38545
38546 \begin_layout Section
38547 ANSI-Compliance
38548 \begin_inset LatexCommand index
38549 name "ANSI-compliance"
38550
38551 \end_inset
38552
38553
38554 \begin_inset LatexCommand label
38555 name "sub:ANSI-Compliance"
38556
38557 \end_inset
38558
38559
38560 \end_layout
38561
38562 \begin_layout Standard
38563 The latest publicly available version of the standard 
38564 \emph on
38565 ISO/IEC 9899 - Programming languages - C
38566 \emph default
38567  should be available at: 
38568 \begin_inset LatexCommand url
38569 target "http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899"
38570
38571 \end_inset
38572
38573 .
38574 \newline
38575
38576 \end_layout
38577
38578 \begin_layout Standard
38579 Deviations from the compliance:
38580 \end_layout
38581
38582 \begin_layout Itemize
38583 functions are not reentrant
38584 \begin_inset LatexCommand index
38585 name "reentrant"
38586
38587 \end_inset
38588
38589  unless explicitly declared as such or the 
38590 \series bold
38591 -
38592 \begin_inset ERT
38593 status collapsed
38594
38595 \begin_layout Standard
38596
38597
38598 \backslash
38599 /
38600 \end_layout
38601
38602 \end_inset
38603
38604 -stack-auto
38605 \begin_inset LatexCommand index
38606 name "-\\/-stack-auto"
38607
38608 \end_inset
38609
38610
38611 \series default
38612  command line option is specified.
38613 \end_layout
38614
38615 \begin_layout Itemize
38616 structures
38617 \begin_inset LatexCommand index
38618 name "struct"
38619
38620 \end_inset
38621
38622  and unions
38623 \begin_inset LatexCommand index
38624 name "union"
38625
38626 \end_inset
38627
38628  cannot be assigned values directly, cannot be passed as function parameters
38629  or assigned to each other and cannot be a return value
38630 \begin_inset LatexCommand index
38631 name "return value"
38632
38633 \end_inset
38634
38635  from a function, e.g.:
38636 \end_layout
38637
38638 \begin_deeper
38639 \begin_layout Verse
38640
38641 \family typewriter
38642 struct s { ...
38643  }; 
38644 \newline
38645 struct s s1, s2; 
38646 \newline
38647 foo() 
38648 \newline
38649
38650 \newline
38651 \InsetSpace ~
38652 \InsetSpace ~
38653 \InsetSpace ~
38654 \InsetSpace ~
38655 ...
38656  
38657 \newline
38658 \InsetSpace ~
38659 \InsetSpace ~
38660 \InsetSpace ~
38661 \InsetSpace ~
38662 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
38663 \newline
38664 \InsetSpace ~
38665 \InsetSpace ~
38666 \InsetSpace ~
38667 \InsetSpace ~
38668 ...
38669  
38670 \newline
38671 }
38672 \newline
38673
38674 \series bold
38675 struct
38676 \family default
38677 \series default
38678  
38679 \family typewriter
38680 s foo1 (
38681 \series bold
38682 struct
38683 \family default
38684 \series default
38685  
38686 \family typewriter
38687 s parms) /* invalid in SDCC although allowed in ANSI */
38688 \newline
38689
38690 \newline
38691 \InsetSpace ~
38692 \InsetSpace ~
38693 \InsetSpace ~
38694 \InsetSpace ~
38695 struct s rets;
38696  
38697 \newline
38698 \InsetSpace ~
38699 \InsetSpace ~
38700 \InsetSpace ~
38701 \InsetSpace ~
38702 ...
38703  
38704 \newline
38705 \InsetSpace ~
38706 \InsetSpace ~
38707 \InsetSpace ~
38708 \InsetSpace ~
38709 return rets; /* is invalid in SDCC although allowed in ANSI */ 
38710 \newline
38711 }
38712 \end_layout
38713
38714 \end_deeper
38715 \begin_layout Itemize
38716 initialization of structure arrays must be fully braced.
38717 \end_layout
38718
38719 \begin_deeper
38720 \begin_layout Verse
38721
38722 \family typewriter
38723 struct s { char x } a[] = {1, 2};\InsetSpace ~
38724 \InsetSpace ~
38725 \InsetSpace ~
38726 \InsetSpace ~
38727 \InsetSpace ~
38728 /* invalid in SDCC */
38729 \newline
38730 struct s { char x
38731  } a[] = {{1}, {2}}; /* OK */
38732 \end_layout
38733
38734 \end_deeper
38735 \begin_layout Itemize
38736 'long long
38737 \begin_inset LatexCommand index
38738 name "long long (not supported)"
38739
38740 \end_inset
38741
38742 ' (64 bit integers
38743 \begin_inset LatexCommand index
38744 name "int (64 bit) (not supported)"
38745
38746 \end_inset
38747
38748 ) not supported.
38749 \end_layout
38750
38751 \begin_layout Itemize
38752 'double
38753 \begin_inset LatexCommand index
38754 name "double (not supported)"
38755
38756 \end_inset
38757
38758 ' precision floating point 
38759 \begin_inset LatexCommand index
38760 name "Floating point support"
38761
38762 \end_inset
38763
38764 not supported.
38765 \end_layout
38766
38767 \begin_layout Itemize
38768 Old K&R style
38769 \begin_inset LatexCommand index
38770 name "K\\&R style"
38771
38772 \end_inset
38773
38774  function declarations are NOT allowed.
38775 \end_layout
38776
38777 \begin_deeper
38778 \begin_layout Verse
38779
38780 \family typewriter
38781 foo(i,j) /* this old style of function declarations */ 
38782 \newline
38783 int i,j; /* is valid
38784  in ANSI but not valid in SDCC */ 
38785 \newline
38786
38787 \newline
38788 \InsetSpace ~
38789 \InsetSpace ~
38790 \InsetSpace ~
38791 \InsetSpace ~
38792 ...
38793  
38794 \newline
38795 }
38796 \end_layout
38797
38798 \end_deeper
38799 \begin_layout Itemize
38800 Most enhancements in C99 are not supported, e.g.:
38801 \end_layout
38802
38803 \begin_deeper
38804 \begin_layout Verse
38805
38806 \family typewriter
38807 for (
38808 \series bold
38809 int
38810 \family default
38811 \series default
38812  
38813 \family typewriter
38814 i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
38815 \end_layout
38816
38817 \end_deeper
38818 \begin_layout Itemize
38819 But some have been added recently in SDCC 2.7.0.
38820  They must be considered alpha quality however.
38821 \end_layout
38822
38823 \begin_deeper
38824 \begin_layout Verse
38825
38826 \family typewriter
38827 \series bold
38828 inline
38829 \begin_inset LatexCommand index
38830 name "inline (not supported)"
38831
38832 \end_inset
38833
38834
38835 \family default
38836 \series default
38837  
38838 \family typewriter
38839 int increment (int a) { return a+1; } /* inlines the increment without function
38840  call overhead */
38841 \newline
38842 int *
38843 \family default
38844  
38845 \family typewriter
38846 \series bold
38847 restrict
38848 \begin_inset LatexCommand index
38849 name "inline (not supported)"
38850
38851 \end_inset
38852
38853
38854 \family default
38855 \series default
38856  
38857 \family typewriter
38858 p; /* accepted but ignored */
38859 \end_layout
38860
38861 \end_deeper
38862 \begin_layout Itemize
38863 Certain words that are valid identifiers in the standard may be reserved
38864  words in SDCC unless the 
38865 \series bold
38866 -
38867 \begin_inset ERT
38868 status collapsed
38869
38870 \begin_layout Standard
38871
38872
38873 \backslash
38874 /
38875 \end_layout
38876
38877 \end_inset
38878
38879 -std-c89
38880 \begin_inset LatexCommand index
38881 name "-\\/-std-c89"
38882
38883 \end_inset
38884
38885
38886 \series default
38887  or 
38888 \series bold
38889 -
38890 \begin_inset ERT
38891 status collapsed
38892
38893 \begin_layout Standard
38894
38895
38896 \backslash
38897 /
38898 \end_layout
38899
38900 \end_inset
38901
38902 -std-c99
38903 \begin_inset LatexCommand index
38904 name "-\\/-std-c99"
38905
38906 \end_inset
38907
38908
38909 \series default
38910  command line options are used.
38911  These may include (depending on the selected processor): 'at', 'banked',
38912  'bit', 'code', 'critical', 'data', 'eeprom', 'far', 'flash', 'idata', 'interrup
38913 t', 'near', 'nonbanked', 'pdata', 'reentrant', 'sbit', 'sfr', 'shadowregs',
38914  'sram', 'using', 'wparam', 'xdata', '_overlay', '_asm', '_endasm', and
38915  '_naked'.
38916  Compliant equivalents of these keywords are always available in a form
38917  that begin with two underscores
38918 \begin_inset LatexCommand index
38919 name "\\_\\_ (prefix for extended keywords)"
38920
38921 \end_inset
38922
38923 , f.e.
38924  '__data' instead of 'data'.
38925 \end_layout
38926
38927 \begin_layout Itemize
38928 Integer promotion of variable arguments is not performed if the argument
38929  is explicitly taypecasted unless the 
38930 \series bold
38931 -
38932 \begin_inset ERT
38933 status collapsed
38934
38935 \begin_layout Standard
38936
38937
38938 \backslash
38939 /
38940 \end_layout
38941
38942 \end_inset
38943
38944 -std-c89
38945 \begin_inset LatexCommand index
38946 name "-\\/-std-c89"
38947
38948 \end_inset
38949
38950
38951 \series default
38952  or 
38953 \series bold
38954 -
38955 \begin_inset ERT
38956 status collapsed
38957
38958 \begin_layout Standard
38959
38960
38961 \backslash
38962 /
38963 \end_layout
38964
38965 \end_inset
38966
38967 -std-c99
38968 \begin_inset LatexCommand index
38969 name "-\\/-std-c99"
38970
38971 \end_inset
38972
38973
38974 \series default
38975  command line options are used.
38976 \end_layout
38977
38978 \begin_deeper
38979 \begin_layout Verse
38980
38981 \family typewriter
38982 void vararg_func (char *str, ...) { str; }
38983 \newline
38984
38985 \newline
38986 void main (void)
38987 \newline
38988 {
38989 \newline
38990 \InsetSpace ~
38991 \InsetSpace ~
38992 char c = 10;
38993 \newline
38994
38995 \newline
38996 \InsetSpace ~
38997 \InsetSpace ~
38998 /* argument
38999  u is promoted to int before
39000 \newline
39001 \InsetSpace ~
39002 \InsetSpace ~
39003 \InsetSpace ~
39004 * passing to function */
39005 \newline
39006 \InsetSpace ~
39007 \InsetSpace ~
39008 vararg_func ("%c", c);
39009 \newline
39010
39011 \newline
39012 \InsetSpace ~
39013 \InsetSpace ~
39014 /*
39015  argument u is not promoted to int,
39016 \newline
39017 \InsetSpace ~
39018 \InsetSpace ~
39019 \InsetSpace ~
39020 * it is passed as char to function
39021 \newline
39022 \InsetSpace ~
39023 \InsetSpace ~
39024 \InsetSpace ~
39025 * if
39026  --std-cXX is not defined;
39027 \newline
39028 \InsetSpace ~
39029 \InsetSpace ~
39030 \InsetSpace ~
39031 * is promoted to int before passing
39032 \newline
39033 \InsetSpace ~
39034 \InsetSpace ~
39035 \InsetSpace ~
39036 * to function
39037  if --std-cXX is defined */
39038 \newline
39039 \InsetSpace ~
39040 \InsetSpace ~
39041 vararg_func ("%bc", (char)u);
39042 \newline
39043 }
39044 \end_layout
39045
39046 \end_deeper
39047 \begin_layout Section
39048 Cyclomatic Complexity
39049 \begin_inset LatexCommand index
39050 name "Cyclomatic complexity"
39051
39052 \end_inset
39053
39054
39055 \end_layout
39056
39057 \begin_layout Standard
39058 Cyclomatic complexity of a function is defined as the number of independent
39059  paths the program can take during execution of the function.
39060  This is an important number since it defines the number test cases you
39061  have to generate to validate the function.
39062  The accepted industry standard for complexity number is 10, if the cyclomatic
39063  complexity reported by SDCC exceeds 10 you should think about simplification
39064  of the function logic.
39065  Note that the complexity level is not related to the number of lines of
39066  code in a function.
39067  Large functions can have low complexity, and small functions can have large
39068  complexity levels.
39069  
39070 \newline
39071
39072 \newline
39073 SDCC uses the following formula to compute the complexity:
39074 \newline
39075
39076 \end_layout
39077
39078 \begin_layout Standard
39079 complexity = (number of edges in control flow graph) - (number of nodes
39080  in control flow graph) + 2;
39081 \newline
39082
39083 \newline
39084 Having said that the industry standard is 10,
39085  you should be aware that in some cases it be may unavoidable to have a
39086  complexity level of less than 10.
39087  For example if you have switch statement with more than 10 case labels,
39088  each case label adds one to the complexity level.
39089  The complexity level is by no means an absolute measure of the algorithmic
39090  complexity of the function, it does however provide a good starting point
39091  for which functions you might look at for further optimization.
39092 \end_layout
39093
39094 \begin_layout Section
39095 Retargetting for other Processors
39096 \end_layout
39097
39098 \begin_layout Standard
39099 The issues for retargetting the compiler are far too numerous to be covered
39100  by this document.
39101  What follows is a brief description of each of the seven phases of the
39102  compiler and its MCU dependency.
39103 \end_layout
39104
39105 \begin_layout Itemize
39106 Parsing the source and building the annotated parse tree.
39107  This phase is largely MCU independent (except for the language extensions).
39108  Syntax & semantic checks are also done in this phase, along with some initial
39109  optimizations like back patching labels and the pattern matching optimizations
39110  like bit-rotation etc.
39111 \end_layout
39112
39113 \begin_layout Itemize
39114 The second phase involves generating an intermediate code which can be easy
39115  manipulated during the later phases.
39116  This phase is entirely MCU independent.
39117  The intermediate code generation assumes the target machine has unlimited
39118  number of registers, and designates them with the name iTemp.
39119  The compiler can be made to dump a human readable form of the code generated
39120  by using the -
39121 \begin_inset ERT
39122 status collapsed
39123
39124 \begin_layout Standard
39125
39126
39127 \backslash
39128 /
39129 \end_layout
39130
39131 \end_inset
39132
39133 -dumpraw option.
39134 \end_layout
39135
39136 \begin_layout Itemize
39137 This phase does the bulk of the standard optimizations and is also MCU independe
39138 nt.
39139  This phase can be broken down into several sub-phases:
39140 \newline
39141
39142 \newline
39143 Break down intermediate
39144  code (iCode) into basic blocks.
39145 \newline
39146 Do control flow & data flow analysis on the
39147  basic blocks.
39148 \newline
39149 Do local common subexpression elimination, then global subexpressio
39150 n elimination
39151 \newline
39152 Dead code elimination
39153 \newline
39154 Loop optimizations
39155 \newline
39156 If loop optimizations
39157  caused any changes then do 'global subexpression elimination' and 'dead
39158  code elimination' again.
39159 \end_layout
39160
39161 \begin_layout Itemize
39162 This phase determines the live-ranges; by live range I mean those iTemp
39163  variables defined by the compiler that still survive after all the optimization
39164 s.
39165  Live range analysis
39166 \begin_inset LatexCommand index
39167 name "Live range analysis"
39168
39169 \end_inset
39170
39171  is essential for register allocation, since these computation determines
39172  which of these iTemps will be assigned to registers, and for how long.
39173 \end_layout
39174
39175 \begin_layout Itemize
39176 Phase five is register allocation.
39177  There are two parts to this process.
39178 \newline
39179
39180 \newline
39181 The first part I call 'register packing'
39182  (for lack of a better term).
39183  In this case several MCU specific expression folding is done to reduce
39184  register pressure.
39185 \newline
39186
39187 \newline
39188 The second part is more MCU independent and deals with
39189  allocating registers to the remaining live ranges.
39190  A lot of MCU specific code does creep into this phase because of the limited
39191  number of index registers available in the 8051.
39192 \end_layout
39193
39194 \begin_layout Itemize
39195 The Code generation phase is (unhappily), entirely MCU dependent and very
39196  little (if any at all) of this code can be reused for other MCU.
39197  However the scheme for allocating a homogenized assembler operand for each
39198  iCode operand may be reused.
39199 \end_layout
39200
39201 \begin_layout Itemize
39202 As mentioned in the optimization section the peep-hole optimizer is rule
39203  based system, which can reprogrammed for other MCUs.
39204 \end_layout
39205
39206 \begin_layout Standard
39207 More information is available on SDCC Wiki
39208 \begin_inset LatexCommand index
39209 name "wiki"
39210
39211 \end_inset
39212
39213  (preliminary link 
39214 \begin_inset LatexCommand url
39215 target "http://sdcc.wiki.sourceforge.net/SDCC+internals+and+porting"
39216
39217 \end_inset
39218
39219 ) and in the thread 
39220 \begin_inset LatexCommand url
39221 target "http://sf.net/mailarchive/message.php?msg_id=13954144"
39222
39223 \end_inset
39224
39225  .
39226 \end_layout
39227
39228 \begin_layout Chapter
39229 Compiler internals
39230 \begin_inset LatexCommand index
39231 name "Compiler internals"
39232
39233 \end_inset
39234
39235
39236 \end_layout
39237
39238 \begin_layout Section
39239 The anatomy of the compiler
39240 \begin_inset LatexCommand label
39241 name "sub:The-anatomy-of"
39242
39243 \end_inset
39244
39245
39246 \end_layout
39247
39248 \begin_layout Standard
39249
39250 \shape italic
39251 This is an excerpt from an article published in Circuit Cellar Magazine
39252  in
39253 \shape default
39254  
39255 \series bold
39256 \shape italic
39257 August 2000
39258 \series default
39259 .
39260  It's a little outdated (the compiler is much more efficient now and user/develo
39261 per friendly), but pretty well exposes the guts of it all.
39262 \shape default
39263
39264 \newline
39265
39266 \newline
39267 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
39268  It is fairly easy to retarget for other 8-bit MCU.
39269  Here we take a look at some of the internals of the compiler.
39270  
39271 \end_layout
39272
39273 \begin_layout Paragraph*
39274 Parsing
39275 \begin_inset LatexCommand index
39276 name "Parsing"
39277
39278 \end_inset
39279
39280  
39281 \end_layout
39282
39283 \begin_layout Standard
39284 Parsing the input source file and creating an AST (Annotated Syntax Tree
39285 \begin_inset LatexCommand index
39286 name "Annotated syntax tree"
39287
39288 \end_inset
39289
39290 ).
39291  This phase also involves propagating types (annotating each node of the
39292  parse tree with type information) and semantic analysis.
39293  There are some MCU specific parsing rules.
39294  For example the storage classes, the extended storage classes are MCU specific
39295  while there may be a xdata storage class for 8051 there is no such storage
39296  class for z80 or Atmel AVR.
39297  SDCC allows MCU specific storage class extensions, i.e.
39298  xdata will be treated as a storage class specifier when parsing 8051 C
39299  code but will be treated as a C identifier when parsing z80 or ATMEL AVR
39300  C code.
39301 \end_layout
39302
39303 \begin_layout Paragraph*
39304 Generating iCode
39305 \begin_inset LatexCommand index
39306 name "iCode"
39307
39308 \end_inset
39309
39310
39311 \end_layout
39312
39313 \begin_layout Standard
39314 Intermediate code generation.
39315  In this phase the AST is broken down into three-operand form (iCode).
39316  These three operand forms are represented as doubly linked lists.
39317  ICode is the term given to the intermediate form generated by the compiler.
39318  ICode example section shows some examples of iCode generated for some simple
39319  C source functions.
39320 \end_layout
39321
39322 \begin_layout Paragraph*
39323 Optimizations
39324 \begin_inset LatexCommand index
39325 name "Optimizations"
39326
39327 \end_inset
39328
39329 .
39330 \end_layout
39331
39332 \begin_layout Standard
39333 Bulk of the target independent optimizations is performed in this phase.
39334  The optimizations include constant propagation, common sub-expression eliminati
39335 on, loop invariant code movement, strength reduction of loop induction variables
39336  and dead-code elimination.
39337 \end_layout
39338
39339 \begin_layout Paragraph*
39340 Live range analysis
39341 \begin_inset LatexCommand index
39342 name "Live range analysis"
39343
39344 \end_inset
39345
39346
39347 \end_layout
39348
39349 \begin_layout Standard
39350 During intermediate code generation phase, the compiler assumes the target
39351  machine has infinite number of registers and generates a lot of temporary
39352  variables.
39353  The live range computation determines the lifetime of each of these compiler-ge
39354 nerated temporaries.
39355  A picture speaks a thousand words.
39356  ICode example sections show the live range annotations for each of the
39357  operand.
39358  It is important to note here, each iCode is assigned a number in the order
39359  of its execution in the function.
39360  The live ranges are computed in terms of these numbers.
39361  The from number is the number of the iCode which first defines the operand
39362  and the to number signifies the iCode which uses this operand last.
39363 \end_layout
39364
39365 \begin_layout Paragraph*
39366 Register Allocation
39367 \begin_inset LatexCommand index
39368 name "Register allocation"
39369
39370 \end_inset
39371
39372
39373 \end_layout
39374
39375 \begin_layout Standard
39376 The register allocation determines the type and number of registers needed
39377  by each operand.
39378  In most MCUs only a few registers can be used for indirect addressing.
39379  In case of 8051 for example the registers R0 & R1 can be used to indirectly
39380  address the internal ram and DPTR to indirectly address the external ram.
39381  The compiler will try to allocate the appropriate register to pointer variables
39382  if it can.
39383  ICode example section shows the operands annotated with the registers assigned
39384  to them.
39385  The compiler will try to keep operands in registers as much as possible;
39386  there are several schemes the compiler uses to do achieve this.
39387  When the compiler runs out of registers the compiler will check to see
39388  if there are any live operands which is not used or defined in the current
39389  basic block being processed, if there are any found then it will push that
39390  operand and use the registers in this block, the operand will then be popped
39391  at the end of the basic block.
39392  
39393 \end_layout
39394
39395 \begin_layout Standard
39396 There are other MCU specific considerations in this phase.
39397  Some MCUs have an accumulator; very short-lived operands could be assigned
39398  to the accumulator instead of a general-purpose register.
39399 \end_layout
39400
39401 \begin_layout Paragraph*
39402 Code generation
39403 \end_layout
39404
39405 \begin_layout Standard
39406 Figure II gives a table of iCode
39407 \begin_inset LatexCommand index
39408 name "iCode"
39409
39410 \end_inset
39411
39412  operations supported by the compiler.
39413  The code generation involves translating these operations into corresponding
39414  assembly code for the processor.
39415  This sounds overly simple but that is the essence of code generation.
39416  Some of the iCode operations are generated on a MCU specific manner for
39417  example, the z80 port does not use registers to pass parameters so the
39418  SEND and RECV iCode operations will not be generated, and it also does
39419  not support JUMPTABLES.
39420  
39421 \newline
39422
39423 \end_layout
39424
39425 \begin_layout Standard
39426
39427 \size footnotesize
39428 Figure II 
39429 \begin_inset Tabular
39430 <lyxtabular version="3" rows="39" columns="4">
39431 <features islongtable="true" headBottomDL="true">
39432 <column alignment="block" valignment="top" leftline="true" width="13col%">
39433 <column alignment="left" valignment="top" leftline="true" width="13col%">
39434 <column alignment="block" valignment="top" leftline="true" width="22col%">
39435 <column alignment="block" valignment="top" leftline="true" rightline="true" width="40col%">
39436 <row topline="true" bottomline="true" endhead="true">
39437 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39438 \begin_inset Text
39439
39440 \begin_layout Standard
39441
39442 \series bold
39443 iCode
39444 \series default
39445
39446 \begin_inset LatexCommand index
39447 name "iCode"
39448
39449 \end_inset
39450
39451
39452 \end_layout
39453
39454 \end_inset
39455 </cell>
39456 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39457 \begin_inset Text
39458
39459 \begin_layout Standard
39460
39461 \series bold
39462 Operands
39463 \end_layout
39464
39465 \end_inset
39466 </cell>
39467 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39468 \begin_inset Text
39469
39470 \begin_layout Standard
39471
39472 \series bold
39473 Description
39474 \end_layout
39475
39476 \end_inset
39477 </cell>
39478 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39479 \begin_inset Text
39480
39481 \begin_layout Standard
39482
39483 \series bold
39484 C Equivalent
39485 \end_layout
39486
39487 \end_inset
39488 </cell>
39489 </row>
39490 <row topline="true">
39491 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39492 \begin_inset Text
39493
39494 \begin_layout Standard
39495
39496 \size footnotesize
39497 '!'
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 \size footnotesize
39508 IC_LEFT() IC_RESULT()
39509 \end_layout
39510
39511 \end_inset
39512 </cell>
39513 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39514 \begin_inset Text
39515
39516 \begin_layout Standard
39517
39518 \size footnotesize
39519 NOT operation 
39520 \end_layout
39521
39522 \end_inset
39523 </cell>
39524 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39525 \begin_inset Text
39526
39527 \begin_layout Standard
39528
39529 \size footnotesize
39530 IC_RESULT = ! IC_LEFT;
39531 \end_layout
39532
39533 \end_inset
39534 </cell>
39535 </row>
39536 <row topline="true">
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 '~'
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 IC_LEFT() IC_RESULT()
39555 \end_layout
39556
39557 \end_inset
39558 </cell>
39559 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39560 \begin_inset Text
39561
39562 \begin_layout Standard
39563
39564 \size footnotesize
39565 Bitwise complement of 
39566 \end_layout
39567
39568 \end_inset
39569 </cell>
39570 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39571 \begin_inset Text
39572
39573 \begin_layout Standard
39574
39575 \size footnotesize
39576 IC_RESULT = ~IC_LEFT;
39577 \end_layout
39578
39579 \end_inset
39580 </cell>
39581 </row>
39582 <row topline="true">
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 RRC
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 IC_LEFT() IC_RESULT()
39601 \end_layout
39602
39603 \end_inset
39604 </cell>
39605 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39606 \begin_inset Text
39607
39608 \begin_layout Standard
39609
39610 \size footnotesize
39611 Rotate right with carry
39612 \end_layout
39613
39614 \end_inset
39615 </cell>
39616 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39617 \begin_inset Text
39618
39619 \begin_layout Standard
39620
39621 \size footnotesize
39622 IC_RESULT = (IC_LEFT << 1) | (IC_LEFT >> (sizeof(IC_LEFT)*8-1));
39623 \end_layout
39624
39625 \end_inset
39626 </cell>
39627 </row>
39628 <row topline="true">
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 RLC
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 IC_LEFT() IC_RESULT()
39647 \end_layout
39648
39649 \end_inset
39650 </cell>
39651 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39652 \begin_inset Text
39653
39654 \begin_layout Standard
39655
39656 \size footnotesize
39657 Rotate left with carry
39658 \end_layout
39659
39660 \end_inset
39661 </cell>
39662 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39663 \begin_inset Text
39664
39665 \begin_layout Standard
39666
39667 \size footnotesize
39668 IC_RESULT = (IC_LEFT << (sizeof(LC_LEFT)*8-1) ) | (IC_LEFT >> 1);
39669 \end_layout
39670
39671 \end_inset
39672 </cell>
39673 </row>
39674 <row topline="true">
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 GETHBIT
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 IC_LEFT() IC_RESULT()
39693 \end_layout
39694
39695 \end_inset
39696 </cell>
39697 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39698 \begin_inset Text
39699
39700 \begin_layout Standard
39701
39702 \size footnotesize
39703 Get the highest order bit of IC_LEFT
39704 \end_layout
39705
39706 \end_inset
39707 </cell>
39708 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39709 \begin_inset Text
39710
39711 \begin_layout Standard
39712
39713 \size footnotesize
39714 IC_RESULT = (IC_LEFT >> (sizeof(IC_LEFT)*8 -1));
39715 \end_layout
39716
39717 \end_inset
39718 </cell>
39719 </row>
39720 <row topline="true">
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 UNARYMINUS
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 IC_LEFT() IC_RESULT()
39739 \end_layout
39740
39741 \end_inset
39742 </cell>
39743 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39744 \begin_inset Text
39745
39746 \begin_layout Standard
39747
39748 \size footnotesize
39749 Unary minus
39750 \end_layout
39751
39752 \end_inset
39753 </cell>
39754 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39755 \begin_inset Text
39756
39757 \begin_layout Standard
39758
39759 \size footnotesize
39760 IC_RESULT = - IC_LEFT;
39761 \end_layout
39762
39763 \end_inset
39764 </cell>
39765 </row>
39766 <row topline="true">
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 IPUSH
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 IC_LEFT()
39785 \end_layout
39786
39787 \end_inset
39788 </cell>
39789 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39790 \begin_inset Text
39791
39792 \begin_layout Standard
39793
39794 \size footnotesize
39795 Push the operand into stack
39796 \end_layout
39797
39798 \end_inset
39799 </cell>
39800 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39801 \begin_inset Text
39802
39803 \begin_layout Standard
39804
39805 \size footnotesize
39806 NONE
39807 \end_layout
39808
39809 \end_inset
39810 </cell>
39811 </row>
39812 <row topline="true">
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 IPOP
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 IC_LEFT()
39831 \end_layout
39832
39833 \end_inset
39834 </cell>
39835 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39836 \begin_inset Text
39837
39838 \begin_layout Standard
39839
39840 \size footnotesize
39841 Pop the operand from the stack 
39842 \end_layout
39843
39844 \end_inset
39845 </cell>
39846 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39847 \begin_inset Text
39848
39849 \begin_layout Standard
39850
39851 \size footnotesize
39852 NONE
39853 \end_layout
39854
39855 \end_inset
39856 </cell>
39857 </row>
39858 <row topline="true">
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 CALL
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 IC_LEFT() IC_RESULT()
39877 \end_layout
39878
39879 \end_inset
39880 </cell>
39881 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39882 \begin_inset Text
39883
39884 \begin_layout Standard
39885
39886 \size footnotesize
39887 Call the function represented by IC_LEFT 
39888 \end_layout
39889
39890 \end_inset
39891 </cell>
39892 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39893 \begin_inset Text
39894
39895 \begin_layout Standard
39896
39897 \size footnotesize
39898 IC_RESULT = IC_LEFT();
39899 \end_layout
39900
39901 \end_inset
39902 </cell>
39903 </row>
39904 <row topline="true">
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 PCALL
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 IC_LEFT() IC_RESULT()
39923 \end_layout
39924
39925 \end_inset
39926 </cell>
39927 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39928 \begin_inset Text
39929
39930 \begin_layout Standard
39931
39932 \size footnotesize
39933 Call via function pointer
39934 \end_layout
39935
39936 \end_inset
39937 </cell>
39938 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39939 \begin_inset Text
39940
39941 \begin_layout Standard
39942
39943 \size footnotesize
39944 IC_RESULT = (*IC_LEFT)();
39945 \end_layout
39946
39947 \end_inset
39948 </cell>
39949 </row>
39950 <row topline="true">
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 RETURN
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 IC_LEFT()
39969 \end_layout
39970
39971 \end_inset
39972 </cell>
39973 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39974 \begin_inset Text
39975
39976 \begin_layout Standard
39977
39978 \size footnotesize
39979 Return the value in operand IC_LEFT 
39980 \end_layout
39981
39982 \end_inset
39983 </cell>
39984 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39985 \begin_inset Text
39986
39987 \begin_layout Standard
39988
39989 \size footnotesize
39990 return IC_LEFT;
39991 \end_layout
39992
39993 \end_inset
39994 </cell>
39995 </row>
39996 <row topline="true">
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 LABEL
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 IC_LABEL() 
40015 \end_layout
40016
40017 \end_inset
40018 </cell>
40019 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40020 \begin_inset Text
40021
40022 \begin_layout Standard
40023
40024 \size footnotesize
40025 Label
40026 \end_layout
40027
40028 \end_inset
40029 </cell>
40030 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40031 \begin_inset Text
40032
40033 \begin_layout Standard
40034
40035 \size footnotesize
40036 IC_LABEL:
40037 \end_layout
40038
40039 \end_inset
40040 </cell>
40041 </row>
40042 <row topline="true">
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 GOTO
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 IC_LABEL() 
40061 \end_layout
40062
40063 \end_inset
40064 </cell>
40065 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40066 \begin_inset Text
40067
40068 \begin_layout Standard
40069
40070 \size footnotesize
40071 Goto label
40072 \end_layout
40073
40074 \end_inset
40075 </cell>
40076 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40077 \begin_inset Text
40078
40079 \begin_layout Standard
40080
40081 \size footnotesize
40082 goto IC_LABEL();
40083 \end_layout
40084
40085 \end_inset
40086 </cell>
40087 </row>
40088 <row topline="true">
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 '+'
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 IC_LEFT() IC_RIGHT() IC_RESULT()
40107 \end_layout
40108
40109 \end_inset
40110 </cell>
40111 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40112 \begin_inset Text
40113
40114 \begin_layout Standard
40115
40116 \size footnotesize
40117 Addition
40118 \end_layout
40119
40120 \end_inset
40121 </cell>
40122 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40123 \begin_inset Text
40124
40125 \begin_layout Standard
40126
40127 \size footnotesize
40128 IC_RESULT = IC_LEFT + IC_RIGHT
40129 \end_layout
40130
40131 \end_inset
40132 </cell>
40133 </row>
40134 <row topline="true">
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 '-'
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 IC_LEFT() IC_RIGHT() IC_RESULT()
40153 \end_layout
40154
40155 \end_inset
40156 </cell>
40157 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40158 \begin_inset Text
40159
40160 \begin_layout Standard
40161
40162 \size footnotesize
40163 Subtraction
40164 \end_layout
40165
40166 \end_inset
40167 </cell>
40168 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40169 \begin_inset Text
40170
40171 \begin_layout Standard
40172
40173 \size footnotesize
40174 IC_RESULT = IC_LEFT - IC_RIGHT 
40175 \end_layout
40176
40177 \end_inset
40178 </cell>
40179 </row>
40180 <row topline="true">
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 '*'
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 IC_LEFT() IC_RIGHT() IC_RESULT()
40199 \end_layout
40200
40201 \end_inset
40202 </cell>
40203 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40204 \begin_inset Text
40205
40206 \begin_layout Standard
40207
40208 \size footnotesize
40209 Multiplication 
40210 \end_layout
40211
40212 \end_inset
40213 </cell>
40214 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40215 \begin_inset Text
40216
40217 \begin_layout Standard
40218
40219 \size footnotesize
40220 IC_RESULT = IC_LEFT * IC_RIGHT;
40221 \end_layout
40222
40223 \end_inset
40224 </cell>
40225 </row>
40226 <row topline="true">
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 '/'
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 IC_LEFT() IC_RIGHT() IC_RESULT()
40245 \end_layout
40246
40247 \end_inset
40248 </cell>
40249 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40250 \begin_inset Text
40251
40252 \begin_layout Standard
40253
40254 \size footnotesize
40255 Division
40256 \end_layout
40257
40258 \end_inset
40259 </cell>
40260 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40261 \begin_inset Text
40262
40263 \begin_layout Standard
40264
40265 \size footnotesize
40266 IC_RESULT = IC_LEFT / IC_RIGHT;
40267 \end_layout
40268
40269 \end_inset
40270 </cell>
40271 </row>
40272 <row topline="true">
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 '%'
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 IC_LEFT() IC_RIGHT() IC_RESULT()
40291 \end_layout
40292
40293 \end_inset
40294 </cell>
40295 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40296 \begin_inset Text
40297
40298 \begin_layout Standard
40299
40300 \size footnotesize
40301 Modulus
40302 \end_layout
40303
40304 \end_inset
40305 </cell>
40306 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40307 \begin_inset Text
40308
40309 \begin_layout Standard
40310
40311 \size footnotesize
40312 IC_RESULT = IC_LEFT % IC_RIGHT;
40313 \end_layout
40314
40315 \end_inset
40316 </cell>
40317 </row>
40318 <row topline="true">
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 '<'
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 IC_LEFT() IC_RIGHT() IC_RESULT()
40337 \end_layout
40338
40339 \end_inset
40340 </cell>
40341 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40342 \begin_inset Text
40343
40344 \begin_layout Standard
40345
40346 \size footnotesize
40347 Less than
40348 \end_layout
40349
40350 \end_inset
40351 </cell>
40352 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40353 \begin_inset Text
40354
40355 \begin_layout Standard
40356
40357 \size footnotesize
40358 IC_RESULT = IC_LEFT < IC_RIGHT;
40359 \end_layout
40360
40361 \end_inset
40362 </cell>
40363 </row>
40364 <row topline="true">
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 '>'
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 IC_LEFT() IC_RIGHT() IC_RESULT()
40383 \end_layout
40384
40385 \end_inset
40386 </cell>
40387 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40388 \begin_inset Text
40389
40390 \begin_layout Standard
40391
40392 \size footnotesize
40393 Greater than 
40394 \end_layout
40395
40396 \end_inset
40397 </cell>
40398 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40399 \begin_inset Text
40400
40401 \begin_layout Standard
40402
40403 \size footnotesize
40404 IC_RESULT = IC_LEFT > IC_RIGHT;
40405 \end_layout
40406
40407 \end_inset
40408 </cell>
40409 </row>
40410 <row topline="true">
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 EQ_OP
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 IC_LEFT() IC_RIGHT() IC_RESULT()
40429 \end_layout
40430
40431 \end_inset
40432 </cell>
40433 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40434 \begin_inset Text
40435
40436 \begin_layout Standard
40437
40438 \size footnotesize
40439 Equal to 
40440 \end_layout
40441
40442 \end_inset
40443 </cell>
40444 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40445 \begin_inset Text
40446
40447 \begin_layout Standard
40448
40449 \size footnotesize
40450 IC_RESULT = IC_LEFT == IC_RIGHT;
40451 \end_layout
40452
40453 \end_inset
40454 </cell>
40455 </row>
40456 <row topline="true">
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 AND_OP
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 IC_LEFT() IC_RIGHT() IC_RESULT() 
40475 \end_layout
40476
40477 \end_inset
40478 </cell>
40479 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40480 \begin_inset Text
40481
40482 \begin_layout Standard
40483
40484 \size footnotesize
40485 Logical and operation
40486 \end_layout
40487
40488 \end_inset
40489 </cell>
40490 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40491 \begin_inset Text
40492
40493 \begin_layout Standard
40494
40495 \size footnotesize
40496 IC_RESULT = IC_LEFT && IC_RIGHT; 
40497 \end_layout
40498
40499 \end_inset
40500 </cell>
40501 </row>
40502 <row topline="true">
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 OR_OP
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 IC_LEFT() IC_RIGHT() IC_RESULT() 
40521 \end_layout
40522
40523 \end_inset
40524 </cell>
40525 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40526 \begin_inset Text
40527
40528 \begin_layout Standard
40529
40530 \size footnotesize
40531 Logical or operation 
40532 \end_layout
40533
40534 \end_inset
40535 </cell>
40536 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40537 \begin_inset Text
40538
40539 \begin_layout Standard
40540
40541 \size footnotesize
40542 IC_RESULT = IC_LEFT || IC_RIGHT; 
40543 \end_layout
40544
40545 \end_inset
40546 </cell>
40547 </row>
40548 <row topline="true">
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 '^'
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 IC_LEFT() IC_RIGHT() IC_RESULT() 
40567 \end_layout
40568
40569 \end_inset
40570 </cell>
40571 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40572 \begin_inset Text
40573
40574 \begin_layout Standard
40575
40576 \size footnotesize
40577 Exclusive OR
40578 \end_layout
40579
40580 \end_inset
40581 </cell>
40582 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40583 \begin_inset Text
40584
40585 \begin_layout Standard
40586
40587 \size footnotesize
40588 IC_RESULT = IC_LEFT ^ IC_RIGHT;
40589 \end_layout
40590
40591 \end_inset
40592 </cell>
40593 </row>
40594 <row topline="true">
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 '|'
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 IC_LEFT() IC_RIGHT() IC_RESULT() 
40613 \end_layout
40614
40615 \end_inset
40616 </cell>
40617 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40618 \begin_inset Text
40619
40620 \begin_layout Standard
40621
40622 \size footnotesize
40623 Bitwise OR 
40624 \end_layout
40625
40626 \end_inset
40627 </cell>
40628 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40629 \begin_inset Text
40630
40631 \begin_layout Standard
40632
40633 \size footnotesize
40634 IC_RESULT = IC_LEFT | IC_RIGHT;
40635 \end_layout
40636
40637 \end_inset
40638 </cell>
40639 </row>
40640 <row topline="true">
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 BITWISEAND
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 IC_LEFT() IC_RIGHT() IC_RESULT()
40659 \end_layout
40660
40661 \end_inset
40662 </cell>
40663 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40664 \begin_inset Text
40665
40666 \begin_layout Standard
40667
40668 \size footnotesize
40669 Bitwise AND 
40670 \end_layout
40671
40672 \end_inset
40673 </cell>
40674 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40675 \begin_inset Text
40676
40677 \begin_layout Standard
40678
40679 \size footnotesize
40680 IC_RESULT = IC_LEFT & IC_RIGHT;
40681 \end_layout
40682
40683 \end_inset
40684 </cell>
40685 </row>
40686 <row topline="true">
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 LEFT_OP
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 IC_LEFT() IC_RIGHT() IC_RESULT()
40705 \end_layout
40706
40707 \end_inset
40708 </cell>
40709 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40710 \begin_inset Text
40711
40712 \begin_layout Standard
40713
40714 \size footnotesize
40715 Left shift 
40716 \end_layout
40717
40718 \end_inset
40719 </cell>
40720 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40721 \begin_inset Text
40722
40723 \begin_layout Standard
40724
40725 \size footnotesize
40726 IC_RESULT = IC_LEFT << IC_RIGHT 
40727 \end_layout
40728
40729 \end_inset
40730 </cell>
40731 </row>
40732 <row topline="true">
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 RIGHT_OP
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 IC_LEFT() IC_RIGHT() IC_RESULT()
40751 \end_layout
40752
40753 \end_inset
40754 </cell>
40755 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40756 \begin_inset Text
40757
40758 \begin_layout Standard
40759
40760 \size footnotesize
40761 Right shift
40762 \end_layout
40763
40764 \end_inset
40765 </cell>
40766 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40767 \begin_inset Text
40768
40769 \begin_layout Standard
40770
40771 \size footnotesize
40772 IC_RESULT = IC_LEFT >> IC_RIGHT 
40773 \end_layout
40774
40775 \end_inset
40776 </cell>
40777 </row>
40778 <row topline="true">
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 GET_VALUE_
40786 \newline
40787 AT_ ADDRESS
40788 \end_layout
40789
40790 \end_inset
40791 </cell>
40792 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40793 \begin_inset Text
40794
40795 \begin_layout Standard
40796
40797 \size footnotesize
40798 IC_LEFT() IC_RESULT()
40799 \end_layout
40800
40801 \end_inset
40802 </cell>
40803 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40804 \begin_inset Text
40805
40806 \begin_layout Standard
40807
40808 \size footnotesize
40809 Indirect fetch 
40810 \end_layout
40811
40812 \end_inset
40813 </cell>
40814 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40815 \begin_inset Text
40816
40817 \begin_layout Standard
40818
40819 \size footnotesize
40820 IC_RESULT = (*IC_LEFT);
40821 \end_layout
40822
40823 \end_inset
40824 </cell>
40825 </row>
40826 <row topline="true">
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 POINTER_SET
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 IC_RIGHT() IC_RESULT() 
40845 \end_layout
40846
40847 \end_inset
40848 </cell>
40849 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40850 \begin_inset Text
40851
40852 \begin_layout Standard
40853
40854 \size footnotesize
40855 Indirect set
40856 \end_layout
40857
40858 \end_inset
40859 </cell>
40860 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40861 \begin_inset Text
40862
40863 \begin_layout Standard
40864
40865 \size footnotesize
40866 (*IC_RESULT) = IC_RIGHT;
40867 \end_layout
40868
40869 \end_inset
40870 </cell>
40871 </row>
40872 <row topline="true">
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 '='
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 IC_RIGHT() IC_RESULT()
40891 \end_layout
40892
40893 \end_inset
40894 </cell>
40895 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40896 \begin_inset Text
40897
40898 \begin_layout Standard
40899
40900 \size footnotesize
40901 Assignment
40902 \end_layout
40903
40904 \end_inset
40905 </cell>
40906 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40907 \begin_inset Text
40908
40909 \begin_layout Standard
40910
40911 \size footnotesize
40912 IC_RESULT = IC_RIGHT;
40913 \end_layout
40914
40915 \end_inset
40916 </cell>
40917 </row>
40918 <row topline="true">
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 IFX
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 IC_COND IC_TRUE IC_LABEL
40937 \end_layout
40938
40939 \end_inset
40940 </cell>
40941 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40942 \begin_inset Text
40943
40944 \begin_layout Standard
40945
40946 \size footnotesize
40947 Conditional jump.
40948  If true label is present then jump to true label if condition is true else
40949  jump to false label if condition is false 
40950 \end_layout
40951
40952 \end_inset
40953 </cell>
40954 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40955 \begin_inset Text
40956
40957 \begin_layout Standard
40958
40959 \size footnotesize
40960 if (IC_COND) goto IC_TRUE; 
40961 \newline
40962 \InsetSpace ~
40963 \InsetSpace ~
40964 Or 
40965 \newline
40966 If (!IC_COND) goto IC_FALSE;
40967 \end_layout
40968
40969 \end_inset
40970 </cell>
40971 </row>
40972 <row topline="true">
40973 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40974 \begin_inset Text
40975
40976 \begin_layout Standard
40977
40978 \size footnotesize
40979 ADDRESS_OF
40980 \end_layout
40981
40982 \end_inset
40983 </cell>
40984 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40985 \begin_inset Text
40986
40987 \begin_layout Standard
40988
40989 \size footnotesize
40990 IC_LEFT() IC_RESULT()
40991 \end_layout
40992
40993 \end_inset
40994 </cell>
40995 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40996 \begin_inset Text
40997
40998 \begin_layout Standard
40999
41000 \size footnotesize
41001 Address of 
41002 \end_layout
41003
41004 \end_inset
41005 </cell>
41006 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41007 \begin_inset Text
41008
41009 \begin_layout Standard
41010
41011 \size footnotesize
41012 IC_RESULT = &IC_LEFT();
41013 \end_layout
41014
41015 \end_inset
41016 </cell>
41017 </row>
41018 <row topline="true">
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 JUMPTABLE
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 IC_JTCOND IC_JTLABELS
41037 \end_layout
41038
41039 \end_inset
41040 </cell>
41041 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41042 \begin_inset Text
41043
41044 \begin_layout Standard
41045
41046 \size footnotesize
41047 Jump to list of labels depending on the value of JTCOND
41048 \end_layout
41049
41050 \end_inset
41051 </cell>
41052 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41053 \begin_inset Text
41054
41055 \begin_layout Standard
41056
41057 \size footnotesize
41058 Switch statement
41059 \end_layout
41060
41061 \end_inset
41062 </cell>
41063 </row>
41064 <row topline="true">
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 CAST
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 IC_RIGHT() IC_LEFT() IC_RESULT()
41083 \end_layout
41084
41085 \end_inset
41086 </cell>
41087 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41088 \begin_inset Text
41089
41090 \begin_layout Standard
41091
41092 \size footnotesize
41093 Cast types 
41094 \end_layout
41095
41096 \end_inset
41097 </cell>
41098 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41099 \begin_inset Text
41100
41101 \begin_layout Standard
41102
41103 \size footnotesize
41104 IC_RESULT = (typeof IC_LEFT) IC_RIGHT;
41105 \end_layout
41106
41107 \end_inset
41108 </cell>
41109 </row>
41110 <row topline="true">
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 SEND
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 IC_LEFT()
41129 \end_layout
41130
41131 \end_inset
41132 </cell>
41133 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41134 \begin_inset Text
41135
41136 \begin_layout Standard
41137
41138 \size footnotesize
41139 This is used for passing parameters in registers; 
41140 \newline
41141 move IC_LEFT to the next
41142  available parameter register.
41143 \end_layout
41144
41145 \end_inset
41146 </cell>
41147 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41148 \begin_inset Text
41149
41150 \begin_layout Standard
41151
41152 \size footnotesize
41153 None
41154 \end_layout
41155
41156 \end_inset
41157 </cell>
41158 </row>
41159 <row topline="true">
41160 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41161 \begin_inset Text
41162
41163 \begin_layout Standard
41164
41165 \size footnotesize
41166 RECV
41167 \end_layout
41168
41169 \end_inset
41170 </cell>
41171 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41172 \begin_inset Text
41173
41174 \begin_layout Standard
41175
41176 \size footnotesize
41177 IC_RESULT()
41178 \end_layout
41179
41180 \end_inset
41181 </cell>
41182 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41183 \begin_inset Text
41184
41185 \begin_layout Standard
41186
41187 \size footnotesize
41188 This is used for receiving parameters passed in registers;
41189 \newline
41190 Move the values
41191  in the next parameter register to IC_RESULT 
41192 \end_layout
41193
41194 \end_inset
41195 </cell>
41196 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41197 \begin_inset Text
41198
41199 \begin_layout Standard
41200
41201 \size footnotesize
41202 None
41203 \end_layout
41204
41205 \end_inset
41206 </cell>
41207 </row>
41208 <row topline="true" bottomline="true">
41209 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41210 \begin_inset Text
41211
41212 \begin_layout Standard
41213
41214 \shape slanted
41215 \size footnotesize
41216 (some more have been added)
41217 \end_layout
41218
41219 \end_inset
41220 </cell>
41221 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41222 \begin_inset Text
41223
41224 \begin_layout Standard
41225
41226 \end_layout
41227
41228 \end_inset
41229 </cell>
41230 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41231 \begin_inset Text
41232
41233 \begin_layout Standard
41234
41235 \end_layout
41236
41237 \end_inset
41238 </cell>
41239 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41240 \begin_inset Text
41241
41242 \begin_layout Standard
41243
41244 \shape slanted
41245 \size footnotesize
41246 see f.e.
41247
41248 \shape default
41249  
41250 \family typewriter
41251 \shape slanted
41252 gen51Code()
41253 \family default
41254 \shape default
41255  
41256 \shape slanted
41257 in
41258 \shape default
41259  
41260 \family typewriter
41261 \shape slanted
41262 src/mcs51/gen.c
41263 \end_layout
41264
41265 \end_inset
41266 </cell>
41267 </row>
41268 </lyxtabular>
41269
41270 \end_inset
41271
41272
41273 \end_layout
41274
41275 \begin_layout Standard
41276 \begin_inset Note Note
41277 status collapsed
41278
41279 \begin_layout Standard
41280 In the original article Figure II was announced to be downloadable on 
41281 \shape italic
41282 Circuit Cellar
41283 \shape default
41284 's web site.
41285  ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2000/121/dutta.ZIP
41286 \end_layout
41287
41288 \end_inset
41289
41290
41291 \end_layout
41292
41293 \begin_layout Paragraph*
41294 ICode Example
41295 \begin_inset LatexCommand index
41296 name "iCode"
41297
41298 \end_inset
41299
41300
41301 \end_layout
41302
41303 \begin_layout Standard
41304 This section shows some details of iCode.
41305  The example C code does not do anything useful; it is used as an example
41306  to illustrate the intermediate code generated by the compiler.
41307 \end_layout
41308
41309 \begin_layout Verse
41310
41311 \family typewriter
41312 1.\InsetSpace ~
41313 xdata int * p;
41314 \newline
41315 2.\InsetSpace ~
41316 int gint;
41317 \newline
41318 3.\InsetSpace ~
41319 /* This function does nothing useful.
41320  It is used
41321 \newline
41322 4.\InsetSpace ~
41323 \InsetSpace ~
41324 \InsetSpace ~
41325 \InsetSpace ~
41326 for the purpose of explaining iCode */
41327 \newline
41328 5.\InsetSpace ~
41329 short function (data
41330  int *x)
41331 \newline
41332 6.\InsetSpace ~
41333 {
41334 \newline
41335 7.\InsetSpace ~
41336 \InsetSpace ~
41337 \InsetSpace ~
41338 short i=10; \InsetSpace ~
41339 \InsetSpace ~
41340 /* dead initialization eliminated */
41341 \newline
41342 8.\InsetSpace ~
41343 \InsetSpace ~
41344 \InsetSpace ~
41345 short sum=10;
41346  /* dead initialization eliminated */
41347 \newline
41348 9.\InsetSpace ~
41349 \InsetSpace ~
41350 \InsetSpace ~
41351 short mul;
41352 \newline
41353 10.\InsetSpace ~
41354 \InsetSpace ~
41355 int j ;
41356 \newline
41357 11.\InsetSpace ~
41358 \InsetSpace ~
41359 while (*x) *x++
41360  = *p++; 
41361 \newline
41362 12.\InsetSpace ~
41363 \InsetSpace ~
41364 \InsetSpace ~
41365 \InsetSpace ~
41366 sum = 0 ; 
41367 \newline
41368 13.\InsetSpace ~
41369 \InsetSpace ~
41370 mul = 0;
41371 \newline
41372 14.\InsetSpace ~
41373 \InsetSpace ~
41374 /* compiler detects i,j to be induction
41375  variables */
41376 \newline
41377 15.\InsetSpace ~
41378 \InsetSpace ~
41379 for (i = 0, j = 10 ; i < 10 ; i++, j
41380 \family default
41381 -
41382 \begin_inset ERT
41383 status collapsed
41384
41385 \begin_layout Standard
41386
41387
41388 \backslash
41389 /
41390 \end_layout
41391
41392 \end_inset
41393
41394 -
41395 \family typewriter
41396 ) {
41397 \newline
41398 16.\InsetSpace ~
41399 \InsetSpace ~
41400 \InsetSpace ~
41401 \InsetSpace ~
41402 sum += i;
41403 \newline
41404 17.\InsetSpace ~
41405 \InsetSpace ~
41406 \InsetSpace ~
41407 \InsetSpace ~
41408 mul += i * 3; \InsetSpace ~
41409 \InsetSpace ~
41410 /* this multiplication remains */
41411 \newline
41412 18.\InsetSpace ~
41413 \InsetSpace ~
41414 \InsetSpace ~
41415 \InsetSpace ~
41416 gint +=
41417  j * 3;\InsetSpace ~
41418 \InsetSpace ~
41419 /* this multiplication changed to addition */
41420 \newline
41421 19.\InsetSpace ~
41422 \InsetSpace ~
41423 }
41424 \newline
41425 20.\InsetSpace ~
41426 \InsetSpace ~
41427 return sum+mul;
41428 \newline
41429 21.\InsetSpace ~
41430 }
41431 \end_layout
41432
41433 \begin_layout Standard
41434 In addition to the operands each iCode contains information about the filename
41435  and line it corresponds to in the source file.
41436  The first field in the listing should be interpreted as follows:
41437 \newline
41438
41439 \shape italic
41440 \size footnotesize
41441 Filename(linenumber: iCode Execution sequence number : ICode hash table
41442  key : loop depth of the iCode).
41443 \shape default
41444 \size default
41445
41446 \newline
41447 Then follows the human readable form of the ICode operation.
41448  Each operand of this triplet form can be of three basic types a) compiler
41449  generated temporary b) user defined variable c) a constant value.
41450  Note that local variables and parameters are replaced by compiler generated
41451  temporaries.
41452  Live ranges
41453 \begin_inset LatexCommand index
41454 name "Live range analysis"
41455
41456 \end_inset
41457
41458  are computed only for temporaries (i.e.
41459  live ranges are not computed for global variables).
41460  Registers
41461 \begin_inset LatexCommand index
41462 name "Register allocation"
41463
41464 \end_inset
41465
41466  are allocated for temporaries only.
41467  Operands are formatted in the following manner:
41468 \newline
41469
41470 \shape italic
41471 \size footnotesize
41472 Operand Name [lr live-from : live-to ] { type information } [ registers
41473  allocated ].
41474 \shape default
41475 \size default
41476
41477 \newline
41478 As mentioned earlier the live ranges are computed in terms of the execution
41479  sequence number of the iCodes, for example 
41480 \newline
41481 the iTemp0 is live from (i.e.
41482  first defined in iCode with execution sequence number 3, and is last used
41483  in the iCode with sequence number 5).
41484  For induction variables such as iTemp21 the live range computation extends
41485  the lifetime from the start to the end of the loop.
41486 \newline
41487 The register allocator
41488  used the live range information to allocate registers, the same registers
41489  may be used for different temporaries if their live ranges do not overlap,
41490  for example r0 is allocated to both iTemp6 and to iTemp17 since their live
41491  ranges do not overlap.
41492  In addition the allocator also takes into consideration the type and usage
41493  of a temporary, for example itemp6 is a pointer to near space and is used
41494  as to fetch data from (i.e.
41495  used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer register (r0).
41496  Some short lived temporaries are allocated to special registers which have
41497  meaning to the code generator e.g.
41498  iTemp13 is allocated to a pseudo register CC which tells the back end that
41499  the temporary is used only for a conditional jump the code generation makes
41500  use of this information to optimize a compare and jump ICode.
41501 \newline
41502 There are several
41503  loop optimizations
41504 \begin_inset LatexCommand index
41505 name "Loop optimization"
41506
41507 \end_inset
41508
41509  performed by the compiler.
41510  It can detect induction variables iTemp21(i) and iTemp23(j).
41511  Also note the compiler does selective strength reduction
41512 \begin_inset LatexCommand index
41513 name "Strength reduction"
41514
41515 \end_inset
41516
41517 , i.e.
41518  the multiplication of an induction variable in line 18 (gint = j * 3) is
41519  changed to addition, a new temporary iTemp17 is allocated and assigned
41520  a initial value, a constant 3 is then added for each iteration of the loop.
41521  The compiler does not change the multiplication
41522 \begin_inset LatexCommand index
41523 name "Multiplication"
41524
41525 \end_inset
41526
41527  in line 17 however since the processor does support an 8 * 8 bit multiplication.
41528 \newline
41529
41530 Note the dead code elimination
41531 \begin_inset LatexCommand index
41532 name "Dead-code elimination"
41533
41534 \end_inset
41535
41536  optimization eliminated the dead assignments in line 7 & 8 to I and sum
41537  respectively.
41538 \newline
41539
41540 \end_layout
41541
41542 \begin_layout Standard
41543
41544 \size footnotesize
41545 Sample.c (5:1:0:0) _entry($9) :
41546 \end_layout
41547
41548 \begin_layout Standard
41549
41550 \size footnotesize
41551 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
41552 \end_layout
41553
41554 \begin_layout Standard
41555
41556 \size footnotesize
41557 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv 
41558 \end_layout
41559
41560 \begin_layout Standard
41561
41562 \size footnotesize
41563 Sample.c(11:4:53:0) preHeaderLbl0($11) :
41564 \end_layout
41565
41566 \begin_layout Standard
41567
41568 \size footnotesize
41569 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
41570  * int}[r2]
41571 \end_layout
41572
41573 \begin_layout Standard
41574
41575 \size footnotesize
41576 Sample.c(11:6:5:1) _whilecontinue_0($1) :
41577 \end_layout
41578
41579 \begin_layout Standard
41580
41581 \size footnotesize
41582 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
41583  int}[r0]]
41584 \end_layout
41585
41586 \begin_layout Standard
41587
41588 \size footnotesize
41589 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
41590 \end_layout
41591
41592 \begin_layout Standard
41593
41594 \size footnotesize
41595 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
41596  * int}
41597 \end_layout
41598
41599 \begin_layout Standard
41600
41601 \size footnotesize
41602 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
41603  {short}
41604 \end_layout
41605
41606 \begin_layout Standard
41607
41608 \size footnotesize
41609 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
41610  * int}[DPTR]]
41611 \end_layout
41612
41613 \begin_layout Standard
41614
41615 \size footnotesize
41616 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
41617 }[r2 r3]
41618 \end_layout
41619
41620 \begin_layout Standard
41621
41622 \size footnotesize
41623 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
41624  * int}[r0] + 0x2 {short}
41625 \end_layout
41626
41627 \begin_layout Standard
41628
41629 \size footnotesize
41630 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
41631 \end_layout
41632
41633 \begin_layout Standard
41634
41635 \size footnotesize
41636 Sample.c(11:17:21:0)_whilebreak_0($3) :
41637 \end_layout
41638
41639 \begin_layout Standard
41640
41641 \size footnotesize
41642 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
41643 \end_layout
41644
41645 \begin_layout Standard
41646
41647 \size footnotesize
41648 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
41649 \end_layout
41650
41651 \begin_layout Standard
41652
41653 \size footnotesize
41654 Sample.c(15:20:54:0)preHeaderLbl1($13) :
41655 \end_layout
41656
41657 \begin_layout Standard
41658
41659 \size footnotesize
41660 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
41661 \end_layout
41662
41663 \begin_layout Standard
41664
41665 \size footnotesize
41666 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
41667 \end_layout
41668
41669 \begin_layout Standard
41670
41671 \size footnotesize
41672 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
41673 \end_layout
41674
41675 \begin_layout Standard
41676
41677 \size footnotesize
41678 Sample.c(15:24:26:1)_forcond_0($4) :
41679 \end_layout
41680
41681 \begin_layout Standard
41682
41683 \size footnotesize
41684 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
41685  < 0xa {short}
41686 \end_layout
41687
41688 \begin_layout Standard
41689
41690 \size footnotesize
41691 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
41692 \end_layout
41693
41694 \begin_layout Standard
41695
41696 \size footnotesize
41697 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
41698  + ITemp21 [lr21:38]{short}[r4]
41699 \end_layout
41700
41701 \begin_layout Standard
41702
41703 \size footnotesize
41704 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
41705  * 0x3 {short}
41706 \end_layout
41707
41708 \begin_layout Standard
41709
41710 \size footnotesize
41711 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
41712  + iTemp15 [lr29:30]{short}[r1]
41713 \end_layout
41714
41715 \begin_layout Standard
41716
41717 \size footnotesize
41718 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
41719  r0]- 0x3 {short}
41720 \end_layout
41721
41722 \begin_layout Standard
41723
41724 \size footnotesize
41725 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
41726 int}[r7 r0]
41727 \end_layout
41728
41729 \begin_layout Standard
41730
41731 \size footnotesize
41732 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
41733  + 0x1 {short}
41734 \end_layout
41735
41736 \begin_layout Standard
41737
41738 \size footnotesize
41739 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
41740  r6]- 0x1 {short}
41741 \end_layout
41742
41743 \begin_layout Standard
41744
41745 \size footnotesize
41746 Sample.c(19:38:47:1) goto _forcond_0($4)
41747 \end_layout
41748
41749 \begin_layout Standard
41750
41751 \size footnotesize
41752 Sample.c(19:39:48:0)_forbreak_0($7) :
41753 \end_layout
41754
41755 \begin_layout Standard
41756
41757 \size footnotesize
41758 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
41759  + ITemp11 [lr19:40]{short}[r3]
41760 \end_layout
41761
41762 \begin_layout Standard
41763
41764 \size footnotesize
41765 Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
41766 \end_layout
41767
41768 \begin_layout Standard
41769
41770 \size footnotesize
41771 Sample.c(20:42:51:0)_return($8) :
41772 \end_layout
41773
41774 \begin_layout Standard
41775
41776 \size footnotesize
41777 Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
41778 \size default
41779
41780 \newline
41781
41782 \newline
41783 Finally the code generated for this function:
41784 \newline
41785
41786 \end_layout
41787
41788 \begin_layout Standard
41789
41790 \size footnotesize
41791 .area DSEG (DATA)
41792 \end_layout
41793
41794 \begin_layout Standard
41795
41796 \size footnotesize
41797 _p::
41798 \end_layout
41799
41800 \begin_layout Standard
41801
41802 \size footnotesize
41803 \InsetSpace ~
41804 \InsetSpace ~
41805 .ds 2
41806 \end_layout
41807
41808 \begin_layout Standard
41809
41810 \size footnotesize
41811 _gint::
41812 \end_layout
41813
41814 \begin_layout Standard
41815
41816 \size footnotesize
41817 \InsetSpace ~
41818 \InsetSpace ~
41819 .ds 2
41820 \end_layout
41821
41822 \begin_layout Standard
41823
41824 \size footnotesize
41825 ; sample.c 5
41826 \end_layout
41827
41828 \begin_layout Standard
41829
41830 \size footnotesize
41831 ; ----------------------------------------------
41832 \end_layout
41833
41834 \begin_layout Standard
41835
41836 \size footnotesize
41837 ; function function
41838 \end_layout
41839
41840 \begin_layout Standard
41841
41842 \size footnotesize
41843 ; ----------------------------------------------
41844 \end_layout
41845
41846 \begin_layout Standard
41847
41848 \size footnotesize
41849 _function:
41850 \end_layout
41851
41852 \begin_layout Standard
41853
41854 \size footnotesize
41855 ; iTemp0 [lr3:5]{_near * int}[r2] = recv 
41856 \end_layout
41857
41858 \begin_layout Standard
41859
41860 \size footnotesize
41861 \InsetSpace ~
41862 \InsetSpace ~
41863 mov r2,dpl
41864 \end_layout
41865
41866 \begin_layout Standard
41867
41868 \size footnotesize
41869 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
41870 \end_layout
41871
41872 \begin_layout Standard
41873
41874 \size footnotesize
41875 \InsetSpace ~
41876 \InsetSpace ~
41877 mov ar0,r2
41878 \end_layout
41879
41880 \begin_layout Standard
41881
41882 \size footnotesize
41883 ;_whilecontinue_0($1) :
41884 \end_layout
41885
41886 \begin_layout Standard
41887
41888 \size footnotesize
41889 00101$:
41890 \end_layout
41891
41892 \begin_layout Standard
41893
41894 \size footnotesize
41895 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
41896 \end_layout
41897
41898 \begin_layout Standard
41899
41900 \size footnotesize
41901 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
41902 \end_layout
41903
41904 \begin_layout Standard
41905
41906 \size footnotesize
41907 \InsetSpace ~
41908 \InsetSpace ~
41909 mov ar2,@r0
41910 \end_layout
41911
41912 \begin_layout Standard
41913
41914 \size footnotesize
41915 \InsetSpace ~
41916 \InsetSpace ~
41917 inc r0
41918 \end_layout
41919
41920 \begin_layout Standard
41921
41922 \size footnotesize
41923 \InsetSpace ~
41924 \InsetSpace ~
41925 mov ar3,@r0
41926 \end_layout
41927
41928 \begin_layout Standard
41929
41930 \size footnotesize
41931 \InsetSpace ~
41932 \InsetSpace ~
41933 dec r0
41934 \end_layout
41935
41936 \begin_layout Standard
41937
41938 \size footnotesize
41939 \InsetSpace ~
41940 \InsetSpace ~
41941 mov a,r2
41942 \end_layout
41943
41944 \begin_layout Standard
41945
41946 \size footnotesize
41947 \InsetSpace ~
41948 \InsetSpace ~
41949 orl a,r3
41950 \end_layout
41951
41952 \begin_layout Standard
41953
41954 \size footnotesize
41955 \InsetSpace ~
41956 \InsetSpace ~
41957 jz 00103$
41958 \end_layout
41959
41960 \begin_layout Standard
41961
41962 \size footnotesize
41963 00114$:
41964 \end_layout
41965
41966 \begin_layout Standard
41967
41968 \size footnotesize
41969 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
41970 \end_layout
41971
41972 \begin_layout Standard
41973
41974 \size footnotesize
41975 \InsetSpace ~
41976 \InsetSpace ~
41977 mov dpl,_p
41978 \end_layout
41979
41980 \begin_layout Standard
41981
41982 \size footnotesize
41983 \InsetSpace ~
41984 \InsetSpace ~
41985 mov dph,(_p + 1)
41986 \end_layout
41987
41988 \begin_layout Standard
41989
41990 \size footnotesize
41991 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
41992 \end_layout
41993
41994 \begin_layout Standard
41995
41996 \size footnotesize
41997 \InsetSpace ~
41998 \InsetSpace ~
41999 mov a,#0x02
42000 \end_layout
42001
42002 \begin_layout Standard
42003
42004 \size footnotesize
42005 \InsetSpace ~
42006 \InsetSpace ~
42007 add a,_p
42008 \end_layout
42009
42010 \begin_layout Standard
42011
42012 \size footnotesize
42013 \InsetSpace ~
42014 \InsetSpace ~
42015 mov _p,a
42016 \end_layout
42017
42018 \begin_layout Standard
42019
42020 \size footnotesize
42021 \InsetSpace ~
42022 \InsetSpace ~
42023 clr a
42024 \end_layout
42025
42026 \begin_layout Standard
42027
42028 \size footnotesize
42029 \InsetSpace ~
42030 \InsetSpace ~
42031 addc a,(_p + 1)
42032 \end_layout
42033
42034 \begin_layout Standard
42035
42036 \size footnotesize
42037 \InsetSpace ~
42038 \InsetSpace ~
42039 mov (_p + 1),a
42040 \end_layout
42041
42042 \begin_layout Standard
42043
42044 \size footnotesize
42045 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
42046 \end_layout
42047
42048 \begin_layout Standard
42049
42050 \size footnotesize
42051 \InsetSpace ~
42052 \InsetSpace ~
42053 movx a,@dptr
42054 \end_layout
42055
42056 \begin_layout Standard
42057
42058 \size footnotesize
42059 \InsetSpace ~
42060 \InsetSpace ~
42061 mov r2,a
42062 \end_layout
42063
42064 \begin_layout Standard
42065
42066 \size footnotesize
42067 \InsetSpace ~
42068 \InsetSpace ~
42069 inc dptr
42070 \end_layout
42071
42072 \begin_layout Standard
42073
42074 \size footnotesize
42075 \InsetSpace ~
42076 \InsetSpace ~
42077 movx a,@dptr
42078 \end_layout
42079
42080 \begin_layout Standard
42081
42082 \size footnotesize
42083 \InsetSpace ~
42084 \InsetSpace ~
42085 mov r3,a
42086 \end_layout
42087
42088 \begin_layout Standard
42089
42090 \size footnotesize
42091 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
42092 \end_layout
42093
42094 \begin_layout Standard
42095
42096 \size footnotesize
42097 \InsetSpace ~
42098 \InsetSpace ~
42099 mov @r0,ar2
42100 \end_layout
42101
42102 \begin_layout Standard
42103
42104 \size footnotesize
42105 \InsetSpace ~
42106 \InsetSpace ~
42107 inc r0
42108 \end_layout
42109
42110 \begin_layout Standard
42111
42112 \size footnotesize
42113 \InsetSpace ~
42114 \InsetSpace ~
42115 mov @r0,ar3
42116 \end_layout
42117
42118 \begin_layout Standard
42119
42120 \size footnotesize
42121 ; iTemp6 [lr5:16]{_near * int}[r0] = 
42122 \end_layout
42123
42124 \begin_layout Standard
42125
42126 \size footnotesize
42127 ; iTemp6 [lr5:16]{_near * int}[r0] + 
42128 \end_layout
42129
42130 \begin_layout Standard
42131
42132 \size footnotesize
42133 ; 0x2 {short}
42134 \end_layout
42135
42136 \begin_layout Standard
42137
42138 \size footnotesize
42139 \InsetSpace ~
42140 \InsetSpace ~
42141 inc r0
42142 \end_layout
42143
42144 \begin_layout Standard
42145
42146 \size footnotesize
42147 ; goto _whilecontinue_0($1)
42148 \end_layout
42149
42150 \begin_layout Standard
42151
42152 \size footnotesize
42153 \InsetSpace ~
42154 \InsetSpace ~
42155 sjmp 00101$
42156 \end_layout
42157
42158 \begin_layout Standard
42159
42160 \size footnotesize
42161 ; _whilebreak_0($3) :
42162 \end_layout
42163
42164 \begin_layout Standard
42165
42166 \size footnotesize
42167 00103$:
42168 \end_layout
42169
42170 \begin_layout Standard
42171
42172 \size footnotesize
42173 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
42174 \end_layout
42175
42176 \begin_layout Standard
42177
42178 \size footnotesize
42179 \InsetSpace ~
42180 \InsetSpace ~
42181 mov r2,#0x00
42182 \end_layout
42183
42184 \begin_layout Standard
42185
42186 \size footnotesize
42187 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
42188 \end_layout
42189
42190 \begin_layout Standard
42191
42192 \size footnotesize
42193 \InsetSpace ~
42194 \InsetSpace ~
42195 mov r3,#0x00
42196 \end_layout
42197
42198 \begin_layout Standard
42199
42200 \size footnotesize
42201 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
42202 \end_layout
42203
42204 \begin_layout Standard
42205
42206 \size footnotesize
42207 \InsetSpace ~
42208 \InsetSpace ~
42209 mov r4,#0x00
42210 \end_layout
42211
42212 \begin_layout Standard
42213
42214 \size footnotesize
42215 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
42216 \end_layout
42217
42218 \begin_layout Standard
42219
42220 \size footnotesize
42221 \InsetSpace ~
42222 \InsetSpace ~
42223 mov r5,#0x0A
42224 \end_layout
42225
42226 \begin_layout Standard
42227
42228 \size footnotesize
42229 \InsetSpace ~
42230 \InsetSpace ~
42231 mov r6,#0x00
42232 \end_layout
42233
42234 \begin_layout Standard
42235
42236 \size footnotesize
42237 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
42238 \end_layout
42239
42240 \begin_layout Standard
42241
42242 \size footnotesize
42243 \InsetSpace ~
42244 \InsetSpace ~
42245 mov r7,#0x1E
42246 \end_layout
42247
42248 \begin_layout Standard
42249
42250 \size footnotesize
42251 \InsetSpace ~
42252 \InsetSpace ~
42253 mov r0,#0x00
42254 \end_layout
42255
42256 \begin_layout Standard
42257
42258 \size footnotesize
42259 ; _forcond_0($4) :
42260 \end_layout
42261
42262 \begin_layout Standard
42263
42264 \size footnotesize
42265 00104$:
42266 \end_layout
42267
42268 \begin_layout Standard
42269
42270 \size footnotesize
42271 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
42272 \end_layout
42273
42274 \begin_layout Standard
42275
42276 \size footnotesize
42277 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
42278 \end_layout
42279
42280 \begin_layout Standard
42281
42282 \size footnotesize
42283 \InsetSpace ~
42284 \InsetSpace ~
42285 clr c
42286 \end_layout
42287
42288 \begin_layout Standard
42289
42290 \size footnotesize
42291 \InsetSpace ~
42292 \InsetSpace ~
42293 mov a,r4
42294 \end_layout
42295
42296 \begin_layout Standard
42297
42298 \size footnotesize
42299 \InsetSpace ~
42300 \InsetSpace ~
42301 xrl a,#0x80
42302 \end_layout
42303
42304 \begin_layout Standard
42305
42306 \size footnotesize
42307 \InsetSpace ~
42308 \InsetSpace ~
42309 subb a,#0x8a
42310 \end_layout
42311
42312 \begin_layout Standard
42313
42314 \size footnotesize
42315 \InsetSpace ~
42316 \InsetSpace ~
42317 jnc 00107$
42318 \end_layout
42319
42320 \begin_layout Standard
42321
42322 \size footnotesize
42323 00115$:
42324 \end_layout
42325
42326 \begin_layout Standard
42327
42328 \size footnotesize
42329 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + 
42330 \end_layout
42331
42332 \begin_layout Standard
42333
42334 \size footnotesize
42335 ; iTemp21 [lr21:38]{short}[r4]
42336 \end_layout
42337
42338 \begin_layout Standard
42339
42340 \size footnotesize
42341 \InsetSpace ~
42342 \InsetSpace ~
42343 mov a,r4
42344 \end_layout
42345
42346 \begin_layout Standard
42347
42348 \size footnotesize
42349 \InsetSpace ~
42350 \InsetSpace ~
42351 add a,r2
42352 \end_layout
42353
42354 \begin_layout Standard
42355
42356 \size footnotesize
42357 \InsetSpace ~
42358 \InsetSpace ~
42359 mov r2,a
42360 \end_layout
42361
42362 \begin_layout Standard
42363
42364 \size footnotesize
42365 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
42366 \end_layout
42367
42368 \begin_layout Standard
42369
42370 \size footnotesize
42371 \InsetSpace ~
42372 \InsetSpace ~
42373 mov b,#0x03
42374 \end_layout
42375
42376 \begin_layout Standard
42377
42378 \size footnotesize
42379 \InsetSpace ~
42380 \InsetSpace ~
42381 mov a,r4
42382 \end_layout
42383
42384 \begin_layout Standard
42385
42386 \size footnotesize
42387 \InsetSpace ~
42388 \InsetSpace ~
42389 mul ab
42390 \end_layout
42391
42392 \begin_layout Standard
42393
42394 \size footnotesize
42395 \InsetSpace ~
42396 \InsetSpace ~
42397 mov r1,a
42398 \end_layout
42399
42400 \begin_layout Standard
42401
42402 \size footnotesize
42403 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + 
42404 \end_layout
42405
42406 \begin_layout Standard
42407
42408 \size footnotesize
42409 ; iTemp15 [lr29:30]{short}[r1]
42410 \end_layout
42411
42412 \begin_layout Standard
42413
42414 \size footnotesize
42415 \InsetSpace ~
42416 \InsetSpace ~
42417 add a,r3
42418 \end_layout
42419
42420 \begin_layout Standard
42421
42422 \size footnotesize
42423 \InsetSpace ~
42424 \InsetSpace ~
42425 mov r3,a
42426 \end_layout
42427
42428 \begin_layout Standard
42429
42430 \size footnotesize
42431 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
42432 \end_layout
42433
42434 \begin_layout Standard
42435
42436 \size footnotesize
42437 \InsetSpace ~
42438 \InsetSpace ~
42439 mov a,r7
42440 \end_layout
42441
42442 \begin_layout Standard
42443
42444 \size footnotesize
42445 \InsetSpace ~
42446 \InsetSpace ~
42447 add a,#0xfd
42448 \end_layout
42449
42450 \begin_layout Standard
42451
42452 \size footnotesize
42453 \InsetSpace ~
42454 \InsetSpace ~
42455 mov r7,a
42456 \end_layout
42457
42458 \begin_layout Standard
42459
42460 \size footnotesize
42461 \InsetSpace ~
42462 \InsetSpace ~
42463 mov a,r0
42464 \end_layout
42465
42466 \begin_layout Standard
42467
42468 \size footnotesize
42469 \InsetSpace ~
42470 \InsetSpace ~
42471 addc a,#0xff
42472 \end_layout
42473
42474 \begin_layout Standard
42475
42476 \size footnotesize
42477 \InsetSpace ~
42478 \InsetSpace ~
42479 mov r0,a
42480 \end_layout
42481
42482 \begin_layout Standard
42483
42484 \size footnotesize
42485 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
42486 \end_layout
42487
42488 \begin_layout Standard
42489
42490 \size footnotesize
42491 \InsetSpace ~
42492 \InsetSpace ~
42493 mov a,r7
42494 \end_layout
42495
42496 \begin_layout Standard
42497
42498 \size footnotesize
42499 \InsetSpace ~
42500 \InsetSpace ~
42501 add a,_gint
42502 \end_layout
42503
42504 \begin_layout Standard
42505
42506 \size footnotesize
42507 \InsetSpace ~
42508 \InsetSpace ~
42509 mov _gint,a
42510 \end_layout
42511
42512 \begin_layout Standard
42513
42514 \size footnotesize
42515 \InsetSpace ~
42516 \InsetSpace ~
42517 mov a,r0
42518 \end_layout
42519
42520 \begin_layout Standard
42521
42522 \size footnotesize
42523 \InsetSpace ~
42524 \InsetSpace ~
42525 addc a,(_gint + 1)
42526 \end_layout
42527
42528 \begin_layout Standard
42529
42530 \size footnotesize
42531 \InsetSpace ~
42532 \InsetSpace ~
42533 mov (_gint + 1),a
42534 \end_layout
42535
42536 \begin_layout Standard
42537
42538 \size footnotesize
42539 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
42540 \end_layout
42541
42542 \begin_layout Standard
42543
42544 \size footnotesize
42545 \InsetSpace ~
42546 \InsetSpace ~
42547 inc r4
42548 \end_layout
42549
42550 \begin_layout Standard
42551
42552 \size footnotesize
42553 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
42554 \end_layout
42555
42556 \begin_layout Standard
42557
42558 \size footnotesize
42559 \InsetSpace ~
42560 \InsetSpace ~
42561 dec r5
42562 \end_layout
42563
42564 \begin_layout Standard
42565
42566 \size footnotesize
42567 \InsetSpace ~
42568 \InsetSpace ~
42569 cjne r5,#0xff,00104$
42570 \end_layout
42571
42572 \begin_layout Standard
42573
42574 \size footnotesize
42575 \InsetSpace ~
42576 \InsetSpace ~
42577 dec r6
42578 \end_layout
42579
42580 \begin_layout Standard
42581
42582 \size footnotesize
42583 ; goto _forcond_0($4)
42584 \end_layout
42585
42586 \begin_layout Standard
42587
42588 \size footnotesize
42589 \InsetSpace ~
42590 \InsetSpace ~
42591 sjmp 00104$
42592 \end_layout
42593
42594 \begin_layout Standard
42595
42596 \size footnotesize
42597 ; _forbreak_0($7) :
42598 \end_layout
42599
42600 \begin_layout Standard
42601
42602 \size footnotesize
42603 00107$:
42604 \end_layout
42605
42606 \begin_layout Standard
42607
42608 \size footnotesize
42609 ; ret iTemp24 [lr40:41]{short}
42610 \end_layout
42611
42612 \begin_layout Standard
42613
42614 \size footnotesize
42615 \InsetSpace ~
42616 \InsetSpace ~
42617 mov a,r3
42618 \end_layout
42619
42620 \begin_layout Standard
42621
42622 \size footnotesize
42623 \InsetSpace ~
42624 \InsetSpace ~
42625 add a,r2
42626 \end_layout
42627
42628 \begin_layout Standard
42629
42630 \size footnotesize
42631 \InsetSpace ~
42632 \InsetSpace ~
42633 mov dpl,a
42634 \end_layout
42635
42636 \begin_layout Standard
42637
42638 \size footnotesize
42639 ; _return($8) :
42640 \end_layout
42641
42642 \begin_layout Standard
42643
42644 \size footnotesize
42645 00108$:
42646 \end_layout
42647
42648 \begin_layout Standard
42649
42650 \size footnotesize
42651 \InsetSpace ~
42652 \InsetSpace ~
42653 ret
42654 \newline
42655
42656 \end_layout
42657
42658 \begin_layout Section
42659 A few words about basic block successors, predecessors and dominators
42660 \end_layout
42661
42662 \begin_layout Standard
42663 Successors are basic blocks
42664 \begin_inset LatexCommand index
42665 name "Basic blocks"
42666
42667 \end_inset
42668
42669  that might execute after this basic block.
42670 \newline
42671 Predecessors are basic blocks
42672  that might execute before reaching this basic block.
42673 \newline
42674 Dominators are basic
42675  blocks that WILL execute before reaching this basic block.
42676 \newline
42677
42678 \end_layout
42679
42680 \begin_layout Standard
42681 [basic block 1]
42682 \end_layout
42683
42684 \begin_layout Standard
42685 if (something)
42686 \end_layout
42687
42688 \begin_layout Standard
42689 \InsetSpace ~
42690 \InsetSpace ~
42691 \InsetSpace ~
42692 \InsetSpace ~
42693 [basic block 2]
42694 \end_layout
42695
42696 \begin_layout Standard
42697 else
42698 \end_layout
42699
42700 \begin_layout Standard
42701 \InsetSpace ~
42702 \InsetSpace ~
42703 \InsetSpace ~
42704 \InsetSpace ~
42705 [basic block 3]
42706 \end_layout
42707
42708 \begin_layout Standard
42709 [basic block 4]
42710 \newline
42711
42712 \end_layout
42713
42714 \begin_layout Standard
42715 a) succList of [BB2] = [BB4], of [BB3] = [BB4], of [BB1] = [BB2,BB3]
42716 \end_layout
42717
42718 \begin_layout Standard
42719 b) predList of [BB2] = [BB1], of [BB3] = [BB1], of [BB4] = [BB2,BB3]
42720 \end_layout
42721
42722 \begin_layout Standard
42723 c) domVect of [BB4] = BB1 ...
42724  here we are not sure if BB2 or BB3 was executed but we are SURE that BB1
42725  was executed.
42726 \end_layout
42727
42728 \begin_layout Chapter
42729 Acknowledgments
42730 \end_layout
42731
42732 \begin_layout Standard
42733 \begin_inset LatexCommand url
42734 target "http://sdcc.sourceforge.net/#Who"
42735
42736 \end_inset
42737
42738
42739 \newline
42740
42741 \newline
42742
42743 \emph on
42744 Thanks to all the other volunteer developers who have helped with coding,
42745  testing, web-page creation, distribution sets, etc.
42746  You know who you are :-)
42747 \emph default
42748
42749 \newline
42750
42751 \newline
42752
42753 \emph on
42754 Thanks to Sourceforge 
42755 \begin_inset LatexCommand url
42756 target "http://www.sf.net"
42757
42758 \end_inset
42759
42760  which has hosted the project since 1999 and donates significant download
42761  bandwidth.
42762 \emph default
42763
42764 \newline
42765
42766 \newline
42767
42768 \emph on
42769 Also thanks to all SDCC Distributed Compile Farm members for donating CPU
42770  cycles and bandwidth for snapshot builds.
42771 \newline
42772
42773 \end_layout
42774
42775 \begin_layout Standard
42776 This document was initially written by Sandeep Dutta
42777 \end_layout
42778
42779 \begin_layout Standard
42780 All product names mentioned herein may be trademarks
42781 \begin_inset LatexCommand index
42782 name "Trademarks"
42783
42784 \end_inset
42785
42786  of their respective companies.
42787  
42788 \end_layout
42789
42790 \begin_layout Section*
42791 Alphabetical index
42792 \end_layout
42793
42794 \begin_layout Standard
42795 To avoid confusion, the installation and building options for SDCC itself
42796  (chapter 2) are not part of the index.
42797 \end_layout
42798
42799 \begin_layout Standard
42800 \begin_inset LatexCommand printindex
42801
42802 \end_inset
42803
42804
42805 \end_layout
42806
42807 \end_body
42808 \end_document