doc/adccman.lyx: documented RFE #1901171: inerger promotion of casted varargs
[fw/sdcc] / doc / sdccman.lyx
1 #LyX 1.4.5 created this file. For more info see http://www.lyx.org/
2 \lyxformat 245
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 \fontscheme pslatex
26 \graphics default
27 \paperfontsize default
28 \spacing single
29 \papersize letterpaper
30 \use_geometry true
31 \use_amsmath 1
32 \cite_engine basic
33 \use_bibtopic false
34 \paperorientation portrait
35 \leftmargin 30mm
36 \topmargin 20mm
37 \rightmargin 25mm
38 \bottommargin 20mm
39 \secnumdepth 3
40 \tocdepth 3
41 \paragraph_separation indent
42 \defskip medskip
43 \quotes_language swedish
44 \papercolumns 1
45 \papersides 1
46 \paperpagestyle fancy
47 \tracking_changes false
48 \output_changes true
49 \end_header
50
51 \begin_body
52
53 \begin_layout Standard
54 \begin_inset Note Note
55 status collapsed
56
57 \begin_layout Standard
58 Please note: double dashed longoptions (e.g.
59  --version) are written this way: -
60 \begin_inset ERT
61 status collapsed
62
63 \begin_layout Standard
64
65
66 \backslash
67 /
68 \end_layout
69
70 \end_inset
71
72 -
73 \end_layout
74
75 \begin_layout Standard
76 Two resp.
77  three consecutive dashes would otherwise result in a long resp.
78  extra long dash.
79 \end_layout
80
81 \begin_layout Standard
82 Architecture specific stuff (like memory models, code examples) should maybe
83  later go
84 \end_layout
85
86 \begin_layout Standard
87 into seperate sections/chapters/appendices (it is hard to document PIC or
88  Z80 in
89 \end_layout
90
91 \begin_layout Standard
92 a 8051 centered document) - for now simply add.
93 \end_layout
94
95 \end_inset
96
97
98 \end_layout
99
100 \begin_layout Title
101 SDCC Compiler User Guide
102 \end_layout
103
104 \begin_layout Date
105
106 \size normal
107 SDCC 2.7.5
108 \size footnotesize
109
110 \newline
111 $Date::             $
112 \newline
113 $Revision$
114 \end_layout
115
116 \begin_layout Standard
117 \begin_inset Note Note
118 status collapsed
119
120 \begin_layout Standard
121 The above strings enclosed in $ are automatically updated by Subversion
122 \end_layout
123
124 \end_inset
125
126
127 \end_layout
128
129 \begin_layout Standard
130 \begin_inset LatexCommand \tableofcontents{}
131
132 \end_inset
133
134
135 \end_layout
136
137 \begin_layout Chapter
138 Introduction
139 \end_layout
140
141 \begin_layout Section
142 About SDCC
143 \end_layout
144
145 \begin_layout Standard
146
147 \series bold
148 SDCC
149 \series default
150  (
151 \emph on
152 S
153 \emph default
154 mall
155 \emph on
156 D
157 \emph default
158 evice
159 \emph on
160 CC
161 \emph default
162 ompiler) is free open source, retargettable, optimizing ANSI-C compiler
163  by
164 \series bold
165 Sandeep Dutta
166 \series default
167  designed for 8 bit Microprocessors.
168  The current version targets Intel MCS51 based Microprocessors (8031, 8032,
169  8051, 8052
170 \begin_inset LatexCommand \index{8031, 8032, 8051, 8052, mcs51 CPU}
171
172 \end_inset
173
174 , etc.), Dallas DS80C390 variants, Freescale (formerly Motorola) HC08 and
175  Zilog Z80 based MCUs.
176  It can be retargeted for other microprocessors, support for Microchip PIC,
177  Atmel AVR is under development.
178  The entire source code for the compiler is distributed under GPL.
179  SDCC uses ASXXXX
180 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
181
182 \end_inset
183
184  & ASLINK
185 \begin_inset LatexCommand \index{aslink}
186
187 \end_inset
188
189 , an open source retargetable assembler & linker.
190  SDCC has extensive language extensions suitable for utilizing various microcont
191 rollers and underlying hardware effectively.
192 \newline
193
194 \newline
195 In addition to the MCU specific
196  optimizations SDCC also does a host of standard optimizations like:
197 \end_layout
198
199 \begin_layout Itemize
200 global sub expression elimination,
201 \end_layout
202
203 \begin_layout Itemize
204 loop optimizations (loop invariant, strength reduction of induction variables
205  and loop reversing),
206 \end_layout
207
208 \begin_layout Itemize
209 constant folding & propagation,
210 \end_layout
211
212 \begin_layout Itemize
213 copy propagation,
214 \end_layout
215
216 \begin_layout Itemize
217 dead code elimination
218 \end_layout
219
220 \begin_layout Itemize
221 jump tables for
222 \emph on
223 switch
224 \emph default
225  statements.
226 \end_layout
227
228 \begin_layout Standard
229 For the back-end SDCC uses a global register allocation scheme which should
230  be well suited for other 8 bit MCUs.
231 \newline
232
233 \newline
234 The peep hole optimizer uses a rule
235  based substitution mechanism which is MCU independent.
236 \newline
237
238 \newline
239 Supported data-types
240  are:
241 \end_layout
242
243 \begin_layout Standard
244 \begin_inset Tabular
245 <lyxtabular version="3" rows="8" columns="5">
246 <features>
247 <column alignment="center" valignment="top" leftline="true" width="0">
248 <column alignment="center" valignment="top" leftline="true" width="0">
249 <column alignment="center" valignment="top" leftline="true" width="0">
250 <column alignment="center" valignment="top" leftline="true" width="0">
251 <column alignment="block" valignment="top" leftline="true" rightline="true" width="20text%">
252 <row topline="true" bottomline="true">
253 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
254 \begin_inset Text
255
256 \begin_layout Standard
257 type
258 \end_layout
259
260 \end_inset
261 </cell>
262 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
263 \begin_inset Text
264
265 \begin_layout Standard
266 width
267 \end_layout
268
269 \end_inset
270 </cell>
271 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
272 \begin_inset Text
273
274 \begin_layout Standard
275 default
276 \end_layout
277
278 \end_inset
279 </cell>
280 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
281 \begin_inset Text
282
283 \begin_layout Standard
284 signed range
285 \end_layout
286
287 \end_inset
288 </cell>
289 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
290 \begin_inset Text
291
292 \begin_layout Standard
293 unsigned range
294 \end_layout
295
296 \end_inset
297 </cell>
298 </row>
299 <row topline="true">
300 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
301 \begin_inset Text
302
303 \begin_layout Standard
304 bool
305 \end_layout
306
307 \end_inset
308 </cell>
309 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
310 \begin_inset Text
311
312 \begin_layout Standard
313 1 bit
314 \end_layout
315
316 \end_inset
317 </cell>
318 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
319 \begin_inset Text
320
321 \begin_layout Standard
322 unsigned
323 \end_layout
324
325 \end_inset
326 </cell>
327 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
328 \begin_inset Text
329
330 \begin_layout Standard
331 -
332 \end_layout
333
334 \end_inset
335 </cell>
336 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
337 \begin_inset Text
338
339 \begin_layout Standard
340 0, 1
341 \end_layout
342
343 \end_inset
344 </cell>
345 </row>
346 <row topline="true">
347 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
348 \begin_inset Text
349
350 \begin_layout Standard
351 char
352 \end_layout
353
354 \end_inset
355 </cell>
356 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
357 \begin_inset Text
358
359 \begin_layout Standard
360 8 bits, 1 byte
361 \end_layout
362
363 \end_inset
364 </cell>
365 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
366 \begin_inset Text
367
368 \begin_layout Standard
369 signed
370 \end_layout
371
372 \end_inset
373 </cell>
374 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
375 \begin_inset Text
376
377 \begin_layout Standard
378 -128, +127
379 \end_layout
380
381 \end_inset
382 </cell>
383 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
384 \begin_inset Text
385
386 \begin_layout Standard
387 0, +255
388 \end_layout
389
390 \end_inset
391 </cell>
392 </row>
393 <row topline="true">
394 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
395 \begin_inset Text
396
397 \begin_layout Standard
398 short
399 \end_layout
400
401 \end_inset
402 </cell>
403 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
404 \begin_inset Text
405
406 \begin_layout Standard
407 16 bits, 2 bytes
408 \end_layout
409
410 \end_inset
411 </cell>
412 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
413 \begin_inset Text
414
415 \begin_layout Standard
416 signed
417 \end_layout
418
419 \end_inset
420 </cell>
421 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
422 \begin_inset Text
423
424 \begin_layout Standard
425 -32.768, +32.767
426 \end_layout
427
428 \end_inset
429 </cell>
430 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
431 \begin_inset Text
432
433 \begin_layout Standard
434 0, +65.535
435 \end_layout
436
437 \end_inset
438 </cell>
439 </row>
440 <row topline="true">
441 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
442 \begin_inset Text
443
444 \begin_layout Standard
445 int
446 \end_layout
447
448 \end_inset
449 </cell>
450 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
451 \begin_inset Text
452
453 \begin_layout Standard
454 16 bits, 2 bytes
455 \end_layout
456
457 \end_inset
458 </cell>
459 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
460 \begin_inset Text
461
462 \begin_layout Standard
463 signed
464 \end_layout
465
466 \end_inset
467 </cell>
468 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
469 \begin_inset Text
470
471 \begin_layout Standard
472 -32.768, +32.767
473 \end_layout
474
475 \end_inset
476 </cell>
477 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
478 \begin_inset Text
479
480 \begin_layout Standard
481 0, +65.535
482 \end_layout
483
484 \end_inset
485 </cell>
486 </row>
487 <row topline="true" bottomline="true">
488 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
489 \begin_inset Text
490
491 \begin_layout Standard
492 long
493 \end_layout
494
495 \end_inset
496 </cell>
497 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
498 \begin_inset Text
499
500 \begin_layout Standard
501 32 bits, 4 bytes
502 \end_layout
503
504 \end_inset
505 </cell>
506 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
507 \begin_inset Text
508
509 \begin_layout Standard
510 signed
511 \end_layout
512
513 \end_inset
514 </cell>
515 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
516 \begin_inset Text
517
518 \begin_layout Standard
519 -2.147.483.648, +2.147.483.647
520 \end_layout
521
522 \end_inset
523 </cell>
524 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
525 \begin_inset Text
526
527 \begin_layout Standard
528 0, +4.294.967.295
529 \end_layout
530
531 \end_inset
532 </cell>
533 </row>
534 <row topline="true" bottomline="true">
535 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
536 \begin_inset Text
537
538 \begin_layout Standard
539 float
540 \end_layout
541
542 \end_inset
543 </cell>
544 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
545 \begin_inset Text
546
547 \begin_layout Standard
548 4 bytes IEEE 754
549 \end_layout
550
551 \end_inset
552 </cell>
553 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
554 \begin_inset Text
555
556 \begin_layout Standard
557 signed
558 \end_layout
559
560 \end_inset
561 </cell>
562 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
563 \begin_inset Text
564
565 \begin_layout Standard
566
567 \end_layout
568
569 \end_inset
570 </cell>
571 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
572 \begin_inset Text
573
574 \begin_layout Standard
575 1.175494351E-38,
576 \family roman
577 \series medium
578 \shape up
579 \size normal
580 \emph off
581 \bar no
582 \noun off
583 \color none
584 3.402823466E+38
585 \end_layout
586
587 \end_inset
588 </cell>
589 </row>
590 <row topline="true" bottomline="true">
591 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
592 \begin_inset Text
593
594 \begin_layout Standard
595 pointer
596 \end_layout
597
598 \end_inset
599 </cell>
600 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
601 \begin_inset Text
602
603 \begin_layout Standard
604 1, 2, 3 or 4 bytes
605 \end_layout
606
607 \end_inset
608 </cell>
609 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
610 \begin_inset Text
611
612 \begin_layout Standard
613 generic
614 \end_layout
615
616 \end_inset
617 </cell>
618 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
619 \begin_inset Text
620
621 \begin_layout Standard
622
623 \end_layout
624
625 \end_inset
626 </cell>
627 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
628 \begin_inset Text
629
630 \begin_layout Standard
631
632 \end_layout
633
634 \end_inset
635 </cell>
636 </row>
637 </lyxtabular>
638
639 \end_inset
640
641
642 \newline
643 The compiler also allows
644 \emph on
645 inline assembler code
646 \emph default
647  to be embedded anywhere in a function.
648  In addition, routines developed in assembly can also be called.
649 \newline
650
651 \newline
652 SDCC also
653  provides an option (-
654 \begin_inset ERT
655 status collapsed
656
657 \begin_layout Standard
658
659
660 \backslash
661 /
662 \end_layout
663
664 \end_inset
665
666 -cyclomatic) to report the relative complexity of a function.
667  These functions can then be further optimized, or hand coded in assembly
668  if needed.
669 \newline
670
671 \newline
672 SDCC also comes with a companion source level debugger SDCDB.
673  The debugger currently uses ucSim, a free open source simulator for 8051
674  and other micro-controllers.
675 \newline
676
677 \newline
678 The latest SDCC version can be downloaded from
679 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
680
681 \end_inset
682
683 .
684 \emph on
685 Please note: the compiler will probably always be some steps ahead of this
686  documentation
687 \series bold
688 \emph default
689
690 \begin_inset LatexCommand \index{Status of documentation}
691
692 \end_inset
693
694
695 \begin_inset Foot
696 status open
697
698 \begin_layout Standard
699 Obviously this has pros and cons
700 \end_layout
701
702 \end_inset
703
704 .
705 \end_layout
706
707 \begin_layout Section
708 Open Source
709 \end_layout
710
711 \begin_layout Standard
712 All packages used in this compiler system are
713 \emph on
714 open source
715 \emph default
716  and
717 \emph on
718 freeware
719 \emph default
720 ; source code for all the sub-packages (pre-processor, assemblers, linkers
721  etc.) is distributed with the package.
722  This documentation is maintained using a free open source word processor
723  (LyX).
724 \newline
725 This program is free software; you can redistribute it and/or modify
726  it under the terms of the GNU General Public License
727 \begin_inset LatexCommand \index{GNU General Public License, GPL}
728
729 \end_inset
730
731  as published by the Free Software Foundation; either version 2, or (at
732  your option) any later version.
733  This program is distributed in the hope that it will be useful, but WITHOUT
734  ANY WARRANTY; without even the implied warranty
735 \begin_inset LatexCommand \index{warranty}
736
737 \end_inset
738
739  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
740  See the GNU General Public License for more details.
741  You should have received a copy of the GNU General Public License along
742  with this program; if not, write to the Free Software Foundation, 59 Temple
743  Place - Suite 330, Boston, MA 02111-1307, USA.
744  In other words, you are welcome to use, share and improve this program.
745  You are forbidden to forbid anyone else to use, share and improve what
746  you give them.
747  Help stamp out software-hoarding!
748 \end_layout
749
750 \begin_layout Section
751 Typographic conventions
752 \begin_inset LatexCommand \index{Typographic conventions}
753
754 \end_inset
755
756
757 \end_layout
758
759 \begin_layout Standard
760 Throughout this manual, we will use the following convention.
761  Commands you have to type in are printed in
762 \family sans
763 \series bold
764 "sans serif"
765 \series default
766 .
767
768 \family default
769  Code samples are printed in
770 \family typewriter
771 typewriter font.
772
773 \family default
774  Interesting items and new terms are printed in
775 \emph on
776 italic.
777 \end_layout
778
779 \begin_layout Section
780 Compatibility
781 \begin_inset LatexCommand \label{sec:Compatibility-with-previous}
782
783 \end_inset
784
785  with previous versions
786 \begin_inset LatexCommand \index{Compatibility with previous versions}
787
788 \end_inset
789
790
791 \end_layout
792
793 \begin_layout Standard
794 Newer versions have usually numerous bug fixes compared with the previous
795  version.
796  But we also sometimes introduce some incompatibilities with older versions.
797  Not just for the fun of it, but to make the compiler more stable, efficient
798  and ANSI compliant
799 \begin_inset LatexCommand \index{ANSI-compliance}
800
801 \end_inset
802
803  (see section
804 \begin_inset LatexCommand \ref{sub:ANSI-Compliance}
805
806 \end_inset
807
808  for ANSI-Compliance).
809 \begin_inset Note Note
810 status collapsed
811
812 \begin_layout Standard
813 It would be fine to add to each item, in which version was it changed.
814 \end_layout
815
816 \end_inset
817
818
819 \newline
820
821 \end_layout
822
823 \begin_layout Itemize
824 short is now equivalent to int (16 bits), it used to be equivalent to char
825  (8 bits) which is not ANSI compliant.
826  To maintain compatibility, old programs may be compiled using the -
827 \begin_inset ERT
828 status collapsed
829
830 \begin_layout Standard
831
832
833 \backslash
834 /
835 \end_layout
836
837 \end_inset
838
839 -short-is-8bits commandline option (see
840 \begin_inset LatexCommand \vref{lyx:--short-is-8bits}
841
842 \end_inset
843
844 ).
845 \end_layout
846
847 \begin_layout Itemize
848 the default directory for gcc-builds where include, library and documentation
849  files are stored is now in /usr/local/share.
850 \end_layout
851
852 \begin_layout Itemize
853 char type parameters to vararg
854 \begin_inset LatexCommand \index{vararg, va\_arg}
855
856 \end_inset
857
858  functions are casted to int unless explicitly casted
859 \begin_inset Marginal
860 status collapsed
861
862 \begin_layout Standard
863
864 \series bold
865 \InsetSpace ~
866 !
867 \end_layout
868
869 \end_inset
870
871 , e.g.:
872 \newline
873
874 \family typewriter
875 \InsetSpace ~
876 \InsetSpace ~
877 char a=3;
878 \newline
879 \InsetSpace ~
880 \InsetSpace ~
881 printf ("%d %c
882 \backslash
883 n", a, (char)a);
884 \family default
885
886 \newline
887  will push a as an int and as a char resp.
888 \end_layout
889
890 \begin_layout Itemize
891 option -
892 \begin_inset ERT
893 status collapsed
894
895 \begin_layout Standard
896
897
898 \backslash
899 /
900 \end_layout
901
902 \end_inset
903
904 -regextend has been removed.
905 \end_layout
906
907 \begin_layout Itemize
908 option -
909 \begin_inset ERT
910 status collapsed
911
912 \begin_layout Standard
913
914
915 \backslash
916 /
917 \end_layout
918
919 \end_inset
920
921 -noregparms has been removed.
922 \end_layout
923
924 \begin_layout Itemize
925 option -
926 \begin_inset ERT
927 status collapsed
928
929 \begin_layout Standard
930
931
932 \backslash
933 /
934 \end_layout
935
936 \end_inset
937
938 -stack-after-data has been removed.
939 \end_layout
940
941 \begin_layout Itemize
942 bit
943 \begin_inset LatexCommand \index{bit}
944
945 \end_inset
946
947  and sbit
948 \begin_inset LatexCommand \index{sbit}
949
950 \end_inset
951
952
953 \begin_inset LatexCommand \index{\_\_sbit}
954
955 \end_inset
956
957  types now consistently behave like the C99 _Bool type with respect to type
958  conversion
959 \begin_inset LatexCommand \index{type conversion}
960
961 \end_inset
962
963
964 \begin_inset LatexCommand \index{type promotion}
965
966 \end_inset
967
968 .
969  The most common incompatibility resulting from this change is related to
970  bit toggling
971 \begin_inset LatexCommand \index{Bit toggling}
972
973 \end_inset
974
975  idioms, e.g.:
976 \newline
977
978 \family typewriter
979 \InsetSpace ~
980 \InsetSpace ~
981 bit b;
982 \newline
983 \InsetSpace ~
984 \InsetSpace ~
985 b = ~
986 \begin_inset LatexCommand \index{\~\/ Operator}
987
988 \end_inset
989
990 b; /* equivalent to b=1 instead of toggling b */
991 \begin_inset Marginal
992 status collapsed
993
994 \begin_layout Standard
995
996 \series bold
997 \InsetSpace ~
998 !
999 \end_layout
1000
1001 \end_inset
1002
1003
1004 \newline
1005 \InsetSpace ~
1006 \InsetSpace ~
1007 b = !b; /* toggles b */
1008 \newline
1009
1010 \family default
1011 In previous versions, both forms would have toggled the bit.
1012 \end_layout
1013
1014 \begin_layout Standard
1015
1016 \emph on
1017 <pending: more incompatibilities?>
1018 \end_layout
1019
1020 \begin_layout Section
1021 System Requirements
1022 \end_layout
1023
1024 \begin_layout Standard
1025 What do you need before you start installation of SDCC? A computer, and
1026  a desire to compute.
1027  The preferred method of installation is to compile SDCC from source using
1028  GNU gcc and make.
1029  For Windows some pre-compiled binary distributions are available for your
1030  convenience.
1031  You should have some experience with command line tools and compiler use.
1032 \end_layout
1033
1034 \begin_layout Section
1035 Other Resources
1036 \end_layout
1037
1038 \begin_layout Standard
1039 The SDCC home page at
1040 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/}
1041
1042 \end_inset
1043
1044  is a great place to find distribution sets.
1045  You can also find links to the user mailing lists that offer help or discuss
1046  SDCC with other SDCC users.
1047  Web links to other SDCC related sites can also be found here.
1048  This document can be found in the DOC directory of the source package as
1049  a text or HTML file.
1050  A pdf version of this document is available at
1051 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
1052
1053 \end_inset
1054
1055 .
1056  Some of the other tools (simulator and assembler) included with SDCC contain
1057  their own documentation and can be found in the source distribution.
1058  If you want the latest unreleased software, the complete source package
1059  is available directly from Subversion on https://sdcc.svn.sourceforge.net/svnroot/
1060 sdcc/trunk/sdcc.
1061 \end_layout
1062
1063 \begin_layout Section
1064 Wishes for the future
1065 \end_layout
1066
1067 \begin_layout Standard
1068 There are (and always will be) some things that could be done.
1069  Here are some I can think of:
1070 \newline
1071
1072 \end_layout
1073
1074 \begin_layout Standard
1075
1076 \family typewriter
1077 char KernelFunction3(char p) at 0x340;
1078 \newline
1079
1080 \end_layout
1081
1082 \begin_layout Standard
1083
1084 \family typewriter
1085 better code banking
1086 \begin_inset LatexCommand \index{code banking (limited support)}
1087
1088 \end_inset
1089
1090  support for mcs51
1091 \newline
1092
1093 \newline
1094
1095 \family default
1096 If you can think of some more, please see the section
1097 \begin_inset LatexCommand \ref{sub:Requesting-Features}
1098
1099 \end_inset
1100
1101  about filing feature requests
1102 \begin_inset LatexCommand \index{Requesting features}
1103
1104 \end_inset
1105
1106
1107 \begin_inset LatexCommand \index{Feature request}
1108
1109 \end_inset
1110
1111 .
1112 \newline
1113
1114 \end_layout
1115
1116 \begin_layout Chapter
1117 Installing SDCC
1118 \begin_inset LatexCommand \index{Installation}
1119
1120 \end_inset
1121
1122
1123 \end_layout
1124
1125 \begin_layout Standard
1126 For most users it is sufficient to skip to either section
1127 \begin_inset LatexCommand \ref{sub:Building-SDCC-on-Linux}
1128
1129 \end_inset
1130
1131  (Unix) or section
1132 \begin_inset LatexCommand \ref{sub:Windows-Install}
1133
1134 \end_inset
1135
1136  (Windows).
1137  More detailed instructions follow below.
1138 \end_layout
1139
1140 \begin_layout Section
1141 Configure Options
1142 \begin_inset LatexCommand \index{Options SDCC configuration}
1143
1144 \end_inset
1145
1146
1147 \end_layout
1148
1149 \begin_layout Standard
1150 The install paths, search paths and other options are defined when running
1151  'configure'.
1152  The defaults can be overridden by:
1153 \end_layout
1154
1155 \begin_layout List
1156 \labelwidthstring 00.00.0000
1157 -
1158 \begin_inset ERT
1159 status collapsed
1160
1161 \begin_layout Standard
1162
1163
1164 \backslash
1165 /
1166 \end_layout
1167
1168 \end_inset
1169
1170 -prefix see table below
1171 \end_layout
1172
1173 \begin_layout List
1174 \labelwidthstring 00.00.0000
1175 -
1176 \begin_inset ERT
1177 status collapsed
1178
1179 \begin_layout Standard
1180
1181
1182 \backslash
1183 /
1184 \end_layout
1185
1186 \end_inset
1187
1188 -exec_prefix see table below
1189 \end_layout
1190
1191 \begin_layout List
1192 \labelwidthstring 00.00.0000
1193 -
1194 \begin_inset ERT
1195 status collapsed
1196
1197 \begin_layout Standard
1198
1199
1200 \backslash
1201 /
1202 \end_layout
1203
1204 \end_inset
1205
1206 -bindir see table below
1207 \end_layout
1208
1209 \begin_layout List
1210 \labelwidthstring 00.00.0000
1211 -
1212 \begin_inset ERT
1213 status collapsed
1214
1215 \begin_layout Standard
1216
1217
1218 \backslash
1219 /
1220 \end_layout
1221
1222 \end_inset
1223
1224 -datadir see table below
1225 \end_layout
1226
1227 \begin_layout List
1228 \labelwidthstring 00.00.0000
1229 -
1230 \begin_inset ERT
1231 status collapsed
1232
1233 \begin_layout Standard
1234
1235
1236 \backslash
1237 /
1238 \end_layout
1239
1240 \end_inset
1241
1242 -datarootdir see table below
1243 \newline
1244
1245 \end_layout
1246
1247 \begin_layout List
1248 \labelwidthstring 00.00.0000
1249 \InsetSpace ~
1250 \InsetSpace ~
1251 docdir environment variable, see table below
1252 \end_layout
1253
1254 \begin_layout List
1255 \labelwidthstring 00.00.0000
1256 \InsetSpace ~
1257 \InsetSpace ~
1258 include_dir_suffix environment variable, see table below
1259 \end_layout
1260
1261 \begin_layout List
1262 \labelwidthstring 00.00.0000
1263 \InsetSpace ~
1264 \InsetSpace ~
1265 lib_dir_suffix environment variable, see table below
1266 \end_layout
1267
1268 \begin_layout List
1269 \labelwidthstring 00.00.0000
1270 \InsetSpace ~
1271 \InsetSpace ~
1272 sdccconf_h_dir_separator environment variable, either / or
1273 \backslash
1274
1275 \backslash
1276  makes sense here.
1277  This character will only be used in sdccconf.h; don't forget it's a C-header,
1278  therefore a double-backslash is needed there.
1279 \newline
1280
1281 \end_layout
1282
1283 \begin_layout List
1284 \labelwidthstring 00.00.0000
1285 -
1286 \begin_inset ERT
1287 status collapsed
1288
1289 \begin_layout Standard
1290
1291
1292 \backslash
1293 /
1294 \end_layout
1295
1296 \end_inset
1297
1298 -disable-mcs51-port Excludes the Intel mcs51 port
1299 \end_layout
1300
1301 \begin_layout List
1302 \labelwidthstring 00.00.0000
1303 -
1304 \begin_inset ERT
1305 status collapsed
1306
1307 \begin_layout Standard
1308
1309
1310 \backslash
1311 /
1312 \end_layout
1313
1314 \end_inset
1315
1316 -disable-gbz80-port Excludes the Gameboy gbz80 port
1317 \end_layout
1318
1319 \begin_layout List
1320 \labelwidthstring 00.00.0000
1321 -
1322 \begin_inset ERT
1323 status collapsed
1324
1325 \begin_layout Standard
1326
1327
1328 \backslash
1329 /
1330 \end_layout
1331
1332 \end_inset
1333
1334 -disable-z80-port Excludes the z80 port
1335 \end_layout
1336
1337 \begin_layout List
1338 \labelwidthstring 00.00.0000
1339 -
1340 \begin_inset ERT
1341 status collapsed
1342
1343 \begin_layout Standard
1344
1345
1346 \backslash
1347 /
1348 \end_layout
1349
1350 \end_inset
1351
1352 -disable-avr-port Excludes the AVR port
1353 \end_layout
1354
1355 \begin_layout List
1356 \labelwidthstring 00.00.0000
1357 -
1358 \begin_inset ERT
1359 status collapsed
1360
1361 \begin_layout Standard
1362
1363
1364 \backslash
1365 /
1366 \end_layout
1367
1368 \end_inset
1369
1370 -disable-ds390-port Excludes the DS390 port
1371 \end_layout
1372
1373 \begin_layout List
1374 \labelwidthstring 00.00.0000
1375 -
1376 \begin_inset ERT
1377 status collapsed
1378
1379 \begin_layout Standard
1380
1381
1382 \backslash
1383 /
1384 \end_layout
1385
1386 \end_inset
1387
1388 -disable-hc08-port Excludes the HC08 port
1389 \end_layout
1390
1391 \begin_layout List
1392 \labelwidthstring 00.00.0000
1393 -
1394 \begin_inset ERT
1395 status collapsed
1396
1397 \begin_layout Standard
1398
1399
1400 \backslash
1401 /
1402 \end_layout
1403
1404 \end_inset
1405
1406 -disable-pic-port Excludes the PIC14 port
1407 \end_layout
1408
1409 \begin_layout List
1410 \labelwidthstring 00.00.0000
1411 -
1412 \begin_inset ERT
1413 status collapsed
1414
1415 \begin_layout Standard
1416
1417
1418 \backslash
1419 /
1420 \end_layout
1421
1422 \end_inset
1423
1424 -disable-pic16-port Excludes the PIC16 port
1425 \end_layout
1426
1427 \begin_layout List
1428 \labelwidthstring 00.00.0000
1429 -
1430 \begin_inset ERT
1431 status collapsed
1432
1433 \begin_layout Standard
1434
1435
1436 \backslash
1437 /
1438 \end_layout
1439
1440 \end_inset
1441
1442 -disable-xa51-port Excludes the XA51 port
1443 \end_layout
1444
1445 \begin_layout List
1446 \labelwidthstring 00.00.0000
1447 -
1448 \begin_inset ERT
1449 status collapsed
1450
1451 \begin_layout Standard
1452
1453
1454 \backslash
1455 /
1456 \end_layout
1457
1458 \end_inset
1459
1460 -disable-ucsim Disables configuring and building of ucsim
1461 \end_layout
1462
1463 \begin_layout List
1464 \labelwidthstring 00.00.0000
1465 -
1466 \begin_inset ERT
1467 status collapsed
1468
1469 \begin_layout Standard
1470
1471
1472 \backslash
1473 /
1474 \end_layout
1475
1476 \end_inset
1477
1478 -disable-device-lib Disables automatically building device libraries
1479 \end_layout
1480
1481 \begin_layout List
1482 \labelwidthstring 00.00.0000
1483 -
1484 \begin_inset ERT
1485 status collapsed
1486
1487 \begin_layout Standard
1488
1489
1490 \backslash
1491 /
1492 \end_layout
1493
1494 \end_inset
1495
1496 -disable-packihx Disables building packihx
1497 \newline
1498
1499 \end_layout
1500
1501 \begin_layout List
1502 \labelwidthstring 00.00.0000
1503 -
1504 \begin_inset ERT
1505 status collapsed
1506
1507 \begin_layout Standard
1508
1509
1510 \backslash
1511 /
1512 \end_layout
1513
1514 \end_inset
1515
1516 -enable-doc Build pdf, html and txt files from the lyx sources
1517 \end_layout
1518
1519 \begin_layout List
1520 \labelwidthstring 00.00.0000
1521 -
1522 \begin_inset ERT
1523 status collapsed
1524
1525 \begin_layout Standard
1526
1527
1528 \backslash
1529 /
1530 \end_layout
1531
1532 \end_inset
1533
1534 -enable-libgc Use the Bohem memory allocator.
1535  Lower runtime footprint.
1536 \end_layout
1537
1538 \begin_layout Standard
1539 Furthermore the environment variables CC, CFLAGS, ...
1540  the tools and their arguments can be influenced.
1541  Please see `configure -
1542 \begin_inset ERT
1543 status collapsed
1544
1545 \begin_layout Standard
1546
1547
1548 \backslash
1549 /
1550 \end_layout
1551
1552 \end_inset
1553
1554 -help' and the man/info pages of `configure' for details.
1555 \newline
1556
1557 \newline
1558 The names of the
1559  standard libraries STD_LIB, STD_INT_LIB, STD_LONG_LIB, STD_FP_LIB, STD_DS390_LI
1560 B, STD_XA51_LIB and the environment variables SDCC_DIR_NAME, SDCC_INCLUDE_NAME,
1561  SDCC_LIB_NAME are defined by `configure' too.
1562  At the moment it's not possible to change the default settings (it was
1563  simply never required).
1564 \newline
1565
1566 \newline
1567 These configure options are compiled into the binaries,
1568  and can only be changed by rerunning 'configure' and recompiling SDCC.
1569  The configure options are written in
1570 \emph on
1571 italics
1572 \emph default
1573  to distinguish them from run time environment variables (see section search
1574  paths).
1575 \newline
1576
1577 \newline
1578 The settings for
1579 \begin_inset Quotes sld
1580 \end_inset
1581
1582 Win32 builds
1583 \begin_inset Quotes srd
1584 \end_inset
1585
1586  are used by the SDCC team to build the official Win32 binaries.
1587  The SDCC team uses Mingw32 to build the official Windows binaries, because
1588  it's
1589 \end_layout
1590
1591 \begin_layout Enumerate
1592 open source,
1593 \end_layout
1594
1595 \begin_layout Enumerate
1596 a gcc compiler and last but not least
1597 \end_layout
1598
1599 \begin_layout Enumerate
1600 the binaries can be built by cross compiling on SDCC Distributed Compile
1601  Farm.
1602 \end_layout
1603
1604 \begin_layout Standard
1605 See the examples, how to pass the Win32 settings to 'configure'.
1606  The other Win32 builds using Borland, VC or whatever don't use 'configure',
1607  but a header file sdcc_vc_in.h is the same as sdccconf.h built by 'configure'
1608  for Win32.
1609 \newline
1610
1611 \newline
1612 These defaults are:
1613 \newline
1614
1615 \end_layout
1616
1617 \begin_layout Standard
1618 \align center
1619 \begin_inset Tabular
1620 <lyxtabular version="3" rows="9" columns="3">
1621 <features>
1622 <column alignment="block" valignment="top" leftline="true" width="0in">
1623 <column alignment="block" valignment="top" leftline="true" width="0in">
1624 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1625 <row topline="true" bottomline="true">
1626 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1627 \begin_inset Text
1628
1629 \begin_layout Standard
1630 Variable
1631 \end_layout
1632
1633 \end_inset
1634 </cell>
1635 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1636 \begin_inset Text
1637
1638 \begin_layout Standard
1639 default
1640 \end_layout
1641
1642 \end_inset
1643 </cell>
1644 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1645 \begin_inset Text
1646
1647 \begin_layout Standard
1648 Win32 builds
1649 \end_layout
1650
1651 \end_inset
1652 </cell>
1653 </row>
1654 <row topline="true">
1655 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1656 \begin_inset Text
1657
1658 \begin_layout Standard
1659
1660 \emph on
1661 PREFIX
1662 \end_layout
1663
1664 \end_inset
1665 </cell>
1666 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1667 \begin_inset Text
1668
1669 \begin_layout Standard
1670 /usr/local
1671 \end_layout
1672
1673 \end_inset
1674 </cell>
1675 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1676 \begin_inset Text
1677
1678 \begin_layout Standard
1679
1680 \backslash
1681 sdcc
1682 \end_layout
1683
1684 \end_inset
1685 </cell>
1686 </row>
1687 <row topline="true">
1688 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1689 \begin_inset Text
1690
1691 \begin_layout Standard
1692
1693 \emph on
1694 EXEC_PREFIX
1695 \end_layout
1696
1697 \end_inset
1698 </cell>
1699 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1700 \begin_inset Text
1701
1702 \begin_layout Standard
1703
1704 \emph on
1705 $PREFIX
1706 \end_layout
1707
1708 \end_inset
1709 </cell>
1710 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1711 \begin_inset Text
1712
1713 \begin_layout Standard
1714
1715 \emph on
1716 $PREFIX
1717 \end_layout
1718
1719 \end_inset
1720 </cell>
1721 </row>
1722 <row topline="true">
1723 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1724 \begin_inset Text
1725
1726 \begin_layout Standard
1727
1728 \emph on
1729 BINDIR
1730 \end_layout
1731
1732 \end_inset
1733 </cell>
1734 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1735 \begin_inset Text
1736
1737 \begin_layout Standard
1738
1739 \emph on
1740 $EXEC_PREFIX
1741 \emph default
1742 /bin
1743 \end_layout
1744
1745 \end_inset
1746 </cell>
1747 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1748 \begin_inset Text
1749
1750 \begin_layout Standard
1751
1752 \emph on
1753 $EXEC_PREFIX
1754 \emph default
1755
1756 \backslash
1757 bin
1758 \end_layout
1759
1760 \end_inset
1761 </cell>
1762 </row>
1763 <row topline="true">
1764 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1765 \begin_inset Text
1766
1767 \begin_layout Standard
1768
1769 \emph on
1770 DATADIR
1771 \end_layout
1772
1773 \end_inset
1774 </cell>
1775 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1776 \begin_inset Text
1777
1778 \begin_layout Standard
1779
1780 \emph on
1781 $DATAROOTDIR
1782 \end_layout
1783
1784 \end_inset
1785 </cell>
1786 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1787 \begin_inset Text
1788
1789 \begin_layout Standard
1790
1791 \emph on
1792 $DATAROOTDIR
1793 \end_layout
1794
1795 \end_inset
1796 </cell>
1797 </row>
1798 <row topline="true">
1799 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1800 \begin_inset Text
1801
1802 \begin_layout Standard
1803
1804 \emph on
1805 DATAROOTDIR
1806 \end_layout
1807
1808 \end_inset
1809 </cell>
1810 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1811 \begin_inset Text
1812
1813 \begin_layout Standard
1814
1815 \emph on
1816 $PREFIX
1817 \emph default
1818 /share
1819 \end_layout
1820
1821 \end_inset
1822 </cell>
1823 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1824 \begin_inset Text
1825
1826 \begin_layout Standard
1827
1828 \emph on
1829 $PREFIX
1830 \end_layout
1831
1832 \end_inset
1833 </cell>
1834 </row>
1835 <row topline="true">
1836 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1837 \begin_inset Text
1838
1839 \begin_layout Standard
1840
1841 \emph on
1842 DOCDIR
1843 \end_layout
1844
1845 \end_inset
1846 </cell>
1847 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1848 \begin_inset Text
1849
1850 \begin_layout Standard
1851
1852 \emph on
1853 $DATAROOTDIR
1854 \emph default
1855 /sdcc/doc
1856 \end_layout
1857
1858 \end_inset
1859 </cell>
1860 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1861 \begin_inset Text
1862
1863 \begin_layout Standard
1864
1865 \emph on
1866 $DATAROOTDIR
1867 \emph default
1868
1869 \backslash
1870 doc
1871 \end_layout
1872
1873 \end_inset
1874 </cell>
1875 </row>
1876 <row topline="true">
1877 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1878 \begin_inset Text
1879
1880 \begin_layout Standard
1881
1882 \emph on
1883 INCLUDE_DIR_SUFFIX
1884 \end_layout
1885
1886 \end_inset
1887 </cell>
1888 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1889 \begin_inset Text
1890
1891 \begin_layout Standard
1892 sdcc/include
1893 \end_layout
1894
1895 \end_inset
1896 </cell>
1897 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1898 \begin_inset Text
1899
1900 \begin_layout Standard
1901 include
1902 \end_layout
1903
1904 \end_inset
1905 </cell>
1906 </row>
1907 <row topline="true" bottomline="true">
1908 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1909 \begin_inset Text
1910
1911 \begin_layout Standard
1912
1913 \emph on
1914 LIB_DIR_SUFFIX
1915 \end_layout
1916
1917 \end_inset
1918 </cell>
1919 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1920 \begin_inset Text
1921
1922 \begin_layout Standard
1923 sdcc/lib
1924 \end_layout
1925
1926 \end_inset
1927 </cell>
1928 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1929 \begin_inset Text
1930
1931 \begin_layout Standard
1932 lib
1933 \end_layout
1934
1935 \end_inset
1936 </cell>
1937 </row>
1938 </lyxtabular>
1939
1940 \end_inset
1941
1942
1943 \newline
1944
1945 \end_layout
1946
1947 \begin_layout Standard
1948 \noindent
1949 'configure' also computes relative paths.
1950  This is needed for full relocatability of a binary package and to complete
1951  search paths (see section search paths below):
1952 \newline
1953
1954 \end_layout
1955
1956 \begin_layout Standard
1957 \align center
1958 \begin_inset Tabular
1959 <lyxtabular version="3" rows="4" columns="3">
1960 <features>
1961 <column alignment="block" valignment="top" leftline="true" width="0in">
1962 <column alignment="block" valignment="top" leftline="true" width="0in">
1963 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1964 <row topline="true" bottomline="true">
1965 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1966 \begin_inset Text
1967
1968 \begin_layout Standard
1969 Variable (computed)
1970 \end_layout
1971
1972 \end_inset
1973 </cell>
1974 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1975 \begin_inset Text
1976
1977 \begin_layout Standard
1978 default
1979 \end_layout
1980
1981 \end_inset
1982 </cell>
1983 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1984 \begin_inset Text
1985
1986 \begin_layout Standard
1987 Win32 builds
1988 \end_layout
1989
1990 \end_inset
1991 </cell>
1992 </row>
1993 <row topline="true" bottomline="true">
1994 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1995 \begin_inset Text
1996
1997 \begin_layout Standard
1998
1999 \emph on
2000 BIN2DATA_DIR
2001 \end_layout
2002
2003 \end_inset
2004 </cell>
2005 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2006 \begin_inset Text
2007
2008 \begin_layout Standard
2009 ../share
2010 \end_layout
2011
2012 \end_inset
2013 </cell>
2014 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2015 \begin_inset Text
2016
2017 \begin_layout Standard
2018 ..
2019 \end_layout
2020
2021 \end_inset
2022 </cell>
2023 </row>
2024 <row bottomline="true">
2025 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2026 \begin_inset Text
2027
2028 \begin_layout Standard
2029
2030 \emph on
2031 PREFIX2BIN_DIR
2032 \end_layout
2033
2034 \end_inset
2035 </cell>
2036 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2037 \begin_inset Text
2038
2039 \begin_layout Standard
2040 bin
2041 \end_layout
2042
2043 \end_inset
2044 </cell>
2045 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2046 \begin_inset Text
2047
2048 \begin_layout Standard
2049 bin
2050 \end_layout
2051
2052 \end_inset
2053 </cell>
2054 </row>
2055 <row bottomline="true">
2056 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2057 \begin_inset Text
2058
2059 \begin_layout Standard
2060
2061 \emph on
2062 PREFIX2DATA_DIR
2063 \end_layout
2064
2065 \end_inset
2066 </cell>
2067 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2068 \begin_inset Text
2069
2070 \begin_layout Standard
2071 share/sdcc
2072 \end_layout
2073
2074 \end_inset
2075 </cell>
2076 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2077 \begin_inset Text
2078
2079 \begin_layout Standard
2080
2081 \end_layout
2082
2083 \end_inset
2084 </cell>
2085 </row>
2086 </lyxtabular>
2087
2088 \end_inset
2089
2090
2091 \newline
2092
2093 \end_layout
2094
2095 \begin_layout Standard
2096 \noindent
2097 Examples:
2098 \end_layout
2099
2100 \begin_layout LyX-Code
2101 ./configure
2102 \newline
2103 ./configure -
2104 \begin_inset ERT
2105 status collapsed
2106
2107 \begin_layout Standard
2108
2109
2110 \backslash
2111 /
2112 \end_layout
2113
2114 \end_inset
2115
2116 -prefix=
2117 \begin_inset Quotes srd
2118 \end_inset
2119
2120 /usr/bin
2121 \begin_inset Quotes srd
2122 \end_inset
2123
2124  -
2125 \begin_inset ERT
2126 status collapsed
2127
2128 \begin_layout Standard
2129
2130
2131 \backslash
2132 /
2133 \end_layout
2134
2135 \end_inset
2136
2137 -datarootdir=
2138 \begin_inset Quotes srd
2139 \end_inset
2140
2141 /usr/share
2142 \begin_inset Quotes srd
2143 \end_inset
2144
2145
2146 \newline
2147 ./configure -
2148 \begin_inset ERT
2149 status collapsed
2150
2151 \begin_layout Standard
2152
2153
2154 \backslash
2155 /
2156 \end_layout
2157
2158 \end_inset
2159
2160 -disable-avr-port -
2161 \begin_inset ERT
2162 status collapsed
2163
2164 \begin_layout Standard
2165
2166
2167 \backslash
2168 /
2169 \end_layout
2170
2171 \end_inset
2172
2173 -disable-xa51-port
2174 \end_layout
2175
2176 \begin_layout Standard
2177 To cross compile on linux for Mingw32 (see also 'sdcc/support/scripts/sdcc_mingw
2178 32'):
2179 \end_layout
2180
2181 \begin_layout LyX-Code
2182 ./configure
2183 \backslash
2184
2185 \newline
2186 CC=
2187 \begin_inset Quotes srd
2188 \end_inset
2189
2190 i586-mingw32msvc-gcc
2191 \begin_inset Quotes srd
2192 \end_inset
2193
2194  CXX=
2195 \begin_inset Quotes srd
2196 \end_inset
2197
2198 i586-mingw32msvc-g++
2199 \begin_inset Quotes srd
2200 \end_inset
2201
2202
2203 \backslash
2204
2205 \newline
2206 RANLIB=
2207 \begin_inset Quotes srd
2208 \end_inset
2209
2210 i586-mingw32msvc-ranlib
2211 \begin_inset Quotes srd
2212 \end_inset
2213
2214
2215 \backslash
2216
2217 \newline
2218 STRIP=
2219 \begin_inset Quotes srd
2220 \end_inset
2221
2222 i586-mingw32msvc-strip
2223 \begin_inset Quotes srd
2224 \end_inset
2225
2226
2227 \backslash
2228
2229 \newline
2230 -
2231 \begin_inset ERT
2232 status collapsed
2233
2234 \begin_layout Standard
2235
2236
2237 \backslash
2238 /
2239 \end_layout
2240
2241 \end_inset
2242
2243 -prefix=
2244 \begin_inset Quotes srd
2245 \end_inset
2246
2247 /sdcc
2248 \begin_inset Quotes srd
2249 \end_inset
2250
2251
2252 \backslash
2253
2254 \newline
2255 -
2256 \begin_inset ERT
2257 status collapsed
2258
2259 \begin_layout Standard
2260
2261
2262 \backslash
2263 /
2264 \end_layout
2265
2266 \end_inset
2267
2268 -datarootdir=
2269 \begin_inset Quotes srd
2270 \end_inset
2271
2272 /sdcc
2273 \begin_inset Quotes srd
2274 \end_inset
2275
2276
2277 \backslash
2278
2279 \newline
2280 docdir=
2281 \begin_inset Quotes srd
2282 \end_inset
2283
2284
2285 \backslash
2286 ${datarootdir}/doc
2287 \begin_inset Quotes srd
2288 \end_inset
2289
2290
2291 \backslash
2292
2293 \newline
2294 include_dir_suffix=
2295 \begin_inset Quotes srd
2296 \end_inset
2297
2298 include
2299 \begin_inset Quotes srd
2300 \end_inset
2301
2302
2303 \backslash
2304
2305 \newline
2306 lib_dir_suffix=
2307 \begin_inset Quotes srd
2308 \end_inset
2309
2310 lib
2311 \begin_inset Quotes srd
2312 \end_inset
2313
2314
2315 \backslash
2316
2317 \newline
2318 sdccconf_h_dir_separator=
2319 \begin_inset Quotes srd
2320 \end_inset
2321
2322
2323 \backslash
2324
2325 \backslash
2326
2327 \backslash
2328
2329 \backslash
2330
2331 \begin_inset Quotes srd
2332 \end_inset
2333
2334
2335 \backslash
2336
2337 \newline
2338 -
2339 \begin_inset ERT
2340 status collapsed
2341
2342 \begin_layout Standard
2343
2344
2345 \backslash
2346 /
2347 \end_layout
2348
2349 \end_inset
2350
2351 -disable-device-lib
2352 \backslash
2353
2354 \newline
2355 -
2356 \begin_inset ERT
2357 status collapsed
2358
2359 \begin_layout Standard
2360
2361
2362 \backslash
2363 /
2364 \end_layout
2365
2366 \end_inset
2367
2368 -host=i586-mingw32msvc
2369 \backslash
2370
2371 \newline
2372 -
2373 \begin_inset ERT
2374 status collapsed
2375
2376 \begin_layout Standard
2377
2378
2379 \backslash
2380 /
2381 \end_layout
2382
2383 \end_inset
2384
2385 -build=unknown-unknown-linux-gnu
2386 \end_layout
2387
2388 \begin_layout Standard
2389 To
2390 \begin_inset Quotes sld
2391 \end_inset
2392
2393 cross
2394 \begin_inset Quotes srd
2395 \end_inset
2396
2397 compile on Cygwin for Mingw32 (see also sdcc/support/scripts/sdcc_cygwin_mingw32
2398 ):
2399 \end_layout
2400
2401 \begin_layout LyX-Code
2402 ./configure -C
2403 \backslash
2404
2405 \newline
2406 -
2407 \begin_inset ERT
2408 status collapsed
2409
2410 \begin_layout Standard
2411
2412
2413 \backslash
2414 /
2415 \end_layout
2416
2417 \end_inset
2418
2419 -prefix=
2420 \begin_inset Quotes srd
2421 \end_inset
2422
2423 /sdcc
2424 \begin_inset Quotes srd
2425 \end_inset
2426
2427
2428 \backslash
2429
2430 \newline
2431 -
2432 \begin_inset ERT
2433 status collapsed
2434
2435 \begin_layout Standard
2436
2437
2438 \backslash
2439 /
2440 \end_layout
2441
2442 \end_inset
2443
2444 -datarootdir=
2445 \begin_inset Quotes srd
2446 \end_inset
2447
2448 /sdcc
2449 \begin_inset Quotes srd
2450 \end_inset
2451
2452
2453 \backslash
2454
2455 \newline
2456 docdir=
2457 \begin_inset Quotes srd
2458 \end_inset
2459
2460
2461 \backslash
2462 ${datarootdir}/doc
2463 \begin_inset Quotes srd
2464 \end_inset
2465
2466
2467 \backslash
2468
2469 \newline
2470 include_dir_suffix=
2471 \begin_inset Quotes srd
2472 \end_inset
2473
2474 include
2475 \begin_inset Quotes srd
2476 \end_inset
2477
2478
2479 \backslash
2480
2481 \newline
2482 lib_dir_suffix=
2483 \begin_inset Quotes srd
2484 \end_inset
2485
2486 lib
2487 \begin_inset Quotes srd
2488 \end_inset
2489
2490
2491 \backslash
2492
2493 \newline
2494 sdccconf_h_dir_separator=
2495 \begin_inset Quotes srd
2496 \end_inset
2497
2498
2499 \backslash
2500
2501 \backslash
2502
2503 \backslash
2504
2505 \backslash
2506
2507 \begin_inset Quotes srd
2508 \end_inset
2509
2510
2511 \backslash
2512
2513 \newline
2514 CC=
2515 \begin_inset Quotes srd
2516 \end_inset
2517
2518 gcc -mno-cygwin
2519 \begin_inset Quotes srd
2520 \end_inset
2521
2522
2523 \backslash
2524
2525 \newline
2526 CXX=
2527 \begin_inset Quotes srd
2528 \end_inset
2529
2530 g++ -mno-cygwin
2531 \begin_inset Quotes srd
2532 \end_inset
2533
2534
2535 \end_layout
2536
2537 \begin_layout Standard
2538 'configure' is quite slow on Cygwin (at least on windows before Win2000/XP).
2539  The option '-
2540 \begin_inset ERT
2541 status collapsed
2542
2543 \begin_layout Standard
2544
2545
2546 \backslash
2547 /
2548 \end_layout
2549
2550 \end_inset
2551
2552 -C' turns on caching, which gives a little bit extra speed.
2553  However if options are changed, it can be necessary to delete the config.cache
2554  file.
2555 \end_layout
2556
2557 \begin_layout Section
2558 Install paths
2559 \begin_inset LatexCommand \label{sub:Install-paths}
2560
2561 \end_inset
2562
2563
2564 \begin_inset LatexCommand \index{Install paths}
2565
2566 \end_inset
2567
2568
2569 \end_layout
2570
2571 \begin_layout Standard
2572 \begin_inset VSpace medskip
2573 \end_inset
2574
2575
2576 \end_layout
2577
2578 \begin_layout Standard
2579 \align center
2580 \begin_inset Tabular
2581 <lyxtabular version="3" rows="5" columns="4">
2582 <features>
2583 <column alignment="left" valignment="top" leftline="true" width="0">
2584 <column alignment="left" valignment="top" leftline="true" width="0">
2585 <column alignment="left" valignment="top" leftline="true" width="0">
2586 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
2587 <row topline="true" bottomline="true">
2588 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2589 \begin_inset Text
2590
2591 \begin_layout Standard
2592
2593 \series bold
2594 Description
2595 \end_layout
2596
2597 \end_inset
2598 </cell>
2599 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2600 \begin_inset Text
2601
2602 \begin_layout Standard
2603
2604 \series bold
2605 Path
2606 \end_layout
2607
2608 \end_inset
2609 </cell>
2610 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2611 \begin_inset Text
2612
2613 \begin_layout Standard
2614
2615 \series bold
2616 Default
2617 \end_layout
2618
2619 \end_inset
2620 </cell>
2621 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2622 \begin_inset Text
2623
2624 \begin_layout Standard
2625
2626 \series bold
2627 Win32 builds
2628 \end_layout
2629
2630 \end_inset
2631 </cell>
2632 </row>
2633 <row topline="true">
2634 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2635 \begin_inset Text
2636
2637 \begin_layout Standard
2638 Binary files*
2639 \end_layout
2640
2641 \end_inset
2642 </cell>
2643 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2644 \begin_inset Text
2645
2646 \begin_layout Standard
2647
2648 \emph on
2649 $EXEC_PREFIX
2650 \end_layout
2651
2652 \end_inset
2653 </cell>
2654 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2655 \begin_inset Text
2656
2657 \begin_layout Standard
2658 /usr/local/bin
2659 \end_layout
2660
2661 \end_inset
2662 </cell>
2663 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2664 \begin_inset Text
2665
2666 \begin_layout Standard
2667
2668 \backslash
2669 sdcc
2670 \backslash
2671 bin
2672 \end_layout
2673
2674 \end_inset
2675 </cell>
2676 </row>
2677 <row topline="true">
2678 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2679 \begin_inset Text
2680
2681 \begin_layout Standard
2682 Include files
2683 \end_layout
2684
2685 \end_inset
2686 </cell>
2687 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2688 \begin_inset Text
2689
2690 \begin_layout Standard
2691
2692 \emph on
2693 $DATADIR/ $INCLUDE_DIR_SUFFIX
2694 \end_layout
2695
2696 \end_inset
2697 </cell>
2698 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2699 \begin_inset Text
2700
2701 \begin_layout Standard
2702 /usr/local/share/sdcc/include
2703 \end_layout
2704
2705 \end_inset
2706 </cell>
2707 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2708 \begin_inset Text
2709
2710 \begin_layout Standard
2711
2712 \backslash
2713 sdcc
2714 \backslash
2715 include
2716 \end_layout
2717
2718 \end_inset
2719 </cell>
2720 </row>
2721 <row topline="true">
2722 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2723 \begin_inset Text
2724
2725 \begin_layout Standard
2726 Library file**
2727 \end_layout
2728
2729 \end_inset
2730 </cell>
2731 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2732 \begin_inset Text
2733
2734 \begin_layout Standard
2735
2736 \emph on
2737 $DATADIR/$LIB_DIR_SUFFIX
2738 \end_layout
2739
2740 \end_inset
2741 </cell>
2742 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2743 \begin_inset Text
2744
2745 \begin_layout Standard
2746 /usr/local/share/sdcc/lib
2747 \end_layout
2748
2749 \end_inset
2750 </cell>
2751 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2752 \begin_inset Text
2753
2754 \begin_layout Standard
2755
2756 \backslash
2757 sdcc
2758 \backslash
2759 lib
2760 \end_layout
2761
2762 \end_inset
2763 </cell>
2764 </row>
2765 <row topline="true" bottomline="true">
2766 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2767 \begin_inset Text
2768
2769 \begin_layout Standard
2770 Documentation
2771 \end_layout
2772
2773 \end_inset
2774 </cell>
2775 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2776 \begin_inset Text
2777
2778 \begin_layout Standard
2779
2780 \emph on
2781 $DOCDIR
2782 \end_layout
2783
2784 \end_inset
2785 </cell>
2786 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2787 \begin_inset Text
2788
2789 \begin_layout Standard
2790 /usr/local/share/sdcc/doc
2791 \end_layout
2792
2793 \end_inset
2794 </cell>
2795 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2796 \begin_inset Text
2797
2798 \begin_layout Standard
2799
2800 \backslash
2801 sdcc
2802 \backslash
2803 doc
2804 \end_layout
2805
2806 \end_inset
2807 </cell>
2808 </row>
2809 </lyxtabular>
2810
2811 \end_inset
2812
2813
2814 \end_layout
2815
2816 \begin_layout Verse
2817
2818 \size footnotesize
2819 *compiler, preprocessor, assembler, and linker
2820 \newline
2821 **the
2822 \shape italic
2823 model
2824 \shape default
2825  is auto-appended by the compiler, e.g.
2826  small, large, z80, ds390 etc
2827 \end_layout
2828
2829 \begin_layout Standard
2830 \noindent
2831 The install paths can still be changed during `make install' with e.g.:
2832 \end_layout
2833
2834 \begin_layout LyX-Code
2835 make install prefix=$(HOME)/local/sdcc
2836 \end_layout
2837
2838 \begin_layout Standard
2839 Of course this doesn't change the search paths compiled into the binaries.
2840 \newline
2841
2842 \newline
2843 Moreove
2844 r the install path can be changed by defining DESTDIR
2845 \begin_inset LatexCommand \index{DESTDIR}
2846
2847 \end_inset
2848
2849 :
2850 \end_layout
2851
2852 \begin_layout LyX-Code
2853 make install DESTDIR=$(HOME)/sdcc.rpm/
2854 \end_layout
2855
2856 \begin_layout Standard
2857 Please note that DESTDIR must have a trailing slash!
2858 \end_layout
2859
2860 \begin_layout Section
2861 Search Paths
2862 \begin_inset LatexCommand \label{sub:Search-Paths}
2863
2864 \end_inset
2865
2866
2867 \begin_inset LatexCommand \index{Search path}
2868
2869 \end_inset
2870
2871
2872 \end_layout
2873
2874 \begin_layout Standard
2875 Some search paths or parts of them are determined by configure variables
2876  (in
2877 \emph on
2878 italics
2879 \emph default
2880 , see section above).
2881  Further search paths are determined by environment variables during runtime.
2882 \newline
2883 The
2884  paths searched when running the compiler are as follows (the first catch
2885  wins):
2886 \newline
2887
2888 \newline
2889 1.
2890  Binary files (preprocessor, assembler and linker)
2891 \newline
2892
2893 \end_layout
2894
2895 \begin_layout Standard
2896 \align center
2897 \begin_inset Tabular
2898 <lyxtabular version="3" rows="4" columns="3">
2899 <features>
2900 <column alignment="block" valignment="top" leftline="true" width="0in">
2901 <column alignment="block" valignment="top" leftline="true" width="0in">
2902 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
2903 <row topline="true" bottomline="true">
2904 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2905 \begin_inset Text
2906
2907 \begin_layout Standard
2908 Search path
2909 \end_layout
2910
2911 \end_inset
2912 </cell>
2913 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2914 \begin_inset Text
2915
2916 \begin_layout Standard
2917 default
2918 \end_layout
2919
2920 \end_inset
2921 </cell>
2922 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2923 \begin_inset Text
2924
2925 \begin_layout Standard
2926 Win32 builds
2927 \end_layout
2928
2929 \end_inset
2930 </cell>
2931 </row>
2932 <row topline="true">
2933 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2934 \begin_inset Text
2935
2936 \begin_layout Standard
2937 $SDCC_HOME/
2938 \emph on
2939 $PPREFIX2BIN_DIR
2940 \end_layout
2941
2942 \end_inset
2943 </cell>
2944 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2945 \begin_inset Text
2946
2947 \begin_layout Standard
2948 $SDCC_HOME/bin
2949 \end_layout
2950
2951 \end_inset
2952 </cell>
2953 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2954 \begin_inset Text
2955
2956 \begin_layout Standard
2957 $SDCC_HOME
2958 \backslash
2959 bin
2960 \end_layout
2961
2962 \end_inset
2963 </cell>
2964 </row>
2965 <row topline="true">
2966 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2967 \begin_inset Text
2968
2969 \begin_layout Standard
2970 Path of argv[0] (if available)
2971 \end_layout
2972
2973 \end_inset
2974 </cell>
2975 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2976 \begin_inset Text
2977
2978 \begin_layout Standard
2979 Path of argv[0]
2980 \end_layout
2981
2982 \end_inset
2983 </cell>
2984 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2985 \begin_inset Text
2986
2987 \begin_layout Standard
2988 Path of argv[0]
2989 \end_layout
2990
2991 \end_inset
2992 </cell>
2993 </row>
2994 <row topline="true" bottomline="true">
2995 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2996 \begin_inset Text
2997
2998 \begin_layout Standard
2999 $PATH
3000 \end_layout
3001
3002 \end_inset
3003 </cell>
3004 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3005 \begin_inset Text
3006
3007 \begin_layout Standard
3008 $PATH
3009 \end_layout
3010
3011 \end_inset
3012 </cell>
3013 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3014 \begin_inset Text
3015
3016 \begin_layout Standard
3017 $PATH
3018 \end_layout
3019
3020 \end_inset
3021 </cell>
3022 </row>
3023 </lyxtabular>
3024
3025 \end_inset
3026
3027
3028 \newline
3029
3030 \end_layout
3031
3032 \begin_layout Standard
3033 \noindent
3034 2.
3035  Include files
3036 \newline
3037
3038 \end_layout
3039
3040 \begin_layout Standard
3041 \align center
3042 \begin_inset Tabular
3043 <lyxtabular version="3" rows="6" columns="3">
3044 <features>
3045 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3046 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3047 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
3048 <row topline="true" bottomline="true">
3049 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3050 \begin_inset Text
3051
3052 \begin_layout Standard
3053 Search path
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 default
3063 \end_layout
3064
3065 \end_inset
3066 </cell>
3067 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3068 \begin_inset Text
3069
3070 \begin_layout Standard
3071 Win32 builds
3072 \end_layout
3073
3074 \end_inset
3075 </cell>
3076 </row>
3077 <row topline="true">
3078 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3079 \begin_inset Text
3080
3081 \begin_layout Standard
3082 -
3083 \begin_inset ERT
3084 status collapsed
3085
3086 \begin_layout Standard
3087
3088
3089 \backslash
3090 /
3091 \end_layout
3092
3093 \end_inset
3094
3095 -I dir
3096 \end_layout
3097
3098 \end_inset
3099 </cell>
3100 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3101 \begin_inset Text
3102
3103 \begin_layout Standard
3104 -
3105 \begin_inset ERT
3106 status collapsed
3107
3108 \begin_layout Standard
3109
3110
3111 \backslash
3112 /
3113 \end_layout
3114
3115 \end_inset
3116
3117 -I dir
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 \begin_inset ERT
3128 status collapsed
3129
3130 \begin_layout Standard
3131
3132
3133 \backslash
3134 /
3135 \end_layout
3136
3137 \end_inset
3138
3139 -I dir
3140 \end_layout
3141
3142 \end_inset
3143 </cell>
3144 </row>
3145 <row topline="true">
3146 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3147 \begin_inset Text
3148
3149 \begin_layout Standard
3150 $SDCC_INCLUDE
3151 \end_layout
3152
3153 \end_inset
3154 </cell>
3155 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3156 \begin_inset Text
3157
3158 \begin_layout Standard
3159 $SDCC_INCLUDE
3160 \end_layout
3161
3162 \end_inset
3163 </cell>
3164 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3165 \begin_inset Text
3166
3167 \begin_layout Standard
3168 $SDCC_INCLUDE
3169 \end_layout
3170
3171 \end_inset
3172 </cell>
3173 </row>
3174 <row topline="true">
3175 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3176 \begin_inset Text
3177
3178 \begin_layout Standard
3179 $SDCC_HOME/
3180 \newline
3181
3182 \emph on
3183 $PREFIX2DATA_DIR/
3184 \newline
3185 $INCLUDE_DIR_SUFFIX
3186 \end_layout
3187
3188 \end_inset
3189 </cell>
3190 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3191 \begin_inset Text
3192
3193 \begin_layout Standard
3194 $SDCC_ HOME/
3195 \newline
3196 share/sdcc/
3197 \newline
3198 include
3199 \end_layout
3200
3201 \end_inset
3202 </cell>
3203 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3204 \begin_inset Text
3205
3206 \begin_layout Standard
3207 $SDCC_HOME
3208 \backslash
3209 include
3210 \end_layout
3211
3212 \end_inset
3213 </cell>
3214 </row>
3215 <row topline="true">
3216 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3217 \begin_inset Text
3218
3219 \begin_layout Standard
3220 path(argv[0])/
3221 \newline
3222
3223 \emph on
3224 $BIN2DATADIR/
3225 \emph default
3226
3227 \newline
3228
3229 \emph on
3230 $INCLUDE_DIR_SUFFIX
3231 \end_layout
3232
3233 \end_inset
3234 </cell>
3235 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3236 \begin_inset Text
3237
3238 \begin_layout Standard
3239 path(argv[0])/
3240 \newline
3241 ../sdcc/include
3242 \newline
3243 \InsetSpace ~
3244 \InsetSpace ~
3245 \InsetSpace ~
3246 \InsetSpace ~
3247 \InsetSpace ~
3248 \InsetSpace ~
3249 \InsetSpace ~
3250 \InsetSpace ~
3251 \InsetSpace ~
3252 \InsetSpace ~
3253 \InsetSpace ~
3254 \InsetSpace ~
3255 \InsetSpace ~
3256 \InsetSpace ~
3257 \InsetSpace ~
3258 \InsetSpace ~
3259 \InsetSpace ~
3260 \InsetSpace ~
3261 \InsetSpace ~
3262 \InsetSpace ~
3263 \InsetSpace ~
3264 \InsetSpace ~
3265 \InsetSpace ~
3266 \InsetSpace ~
3267 \InsetSpace ~
3268 \InsetSpace ~
3269 \InsetSpace ~
3270 \InsetSpace ~
3271 \InsetSpace ~
3272 \InsetSpace ~
3273 \InsetSpace ~
3274 \InsetSpace ~
3275 \InsetSpace ~
3276 \InsetSpace ~
3277 \InsetSpace ~
3278 \InsetSpace ~
3279 \InsetSpace ~
3280 \InsetSpace ~
3281
3282 \end_layout
3283
3284 \end_inset
3285 </cell>
3286 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3287 \begin_inset Text
3288
3289 \begin_layout Standard
3290 path(argv[0])
3291 \backslash
3292 ..
3293 \backslash
3294 include
3295 \end_layout
3296
3297 \end_inset
3298 </cell>
3299 </row>
3300 <row topline="true" bottomline="true">
3301 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3302 \begin_inset Text
3303
3304 \begin_layout Standard
3305
3306 \emph on
3307 $DATADIR/
3308 \emph default
3309
3310 \newline
3311
3312 \emph on
3313 $INCLUDE_DIR_SUFFIX
3314 \end_layout
3315
3316 \end_inset
3317 </cell>
3318 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3319 \begin_inset Text
3320
3321 \begin_layout Standard
3322 /usr/local/share/sdcc/
3323 \newline
3324 include
3325 \end_layout
3326
3327 \end_inset
3328 </cell>
3329 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3330 \begin_inset Text
3331
3332 \begin_layout Standard
3333 (not on Win32)
3334 \end_layout
3335
3336 \end_inset
3337 </cell>
3338 </row>
3339 </lyxtabular>
3340
3341 \end_inset
3342
3343
3344 \newline
3345
3346 \end_layout
3347
3348 \begin_layout Standard
3349 \noindent
3350 The option -
3351 \begin_inset ERT
3352 status collapsed
3353
3354 \begin_layout Standard
3355
3356
3357 \backslash
3358 /
3359 \end_layout
3360
3361 \end_inset
3362
3363 -nostdinc disables the last two search paths.
3364 \newline
3365
3366 \newline
3367 3.
3368  Library files
3369 \newline
3370
3371 \end_layout
3372
3373 \begin_layout Standard
3374 With the exception of
3375 \begin_inset Quotes sld
3376 \end_inset
3377
3378 -
3379 \begin_inset ERT
3380 status collapsed
3381
3382 \begin_layout Standard
3383
3384
3385 \backslash
3386 /
3387 \end_layout
3388
3389 \end_inset
3390
3391 -L dir
3392 \begin_inset Quotes srd
3393 \end_inset
3394
3395  the
3396 \shape italic
3397 model
3398 \shape default
3399  is auto-appended by the compiler (e.g.
3400  small, large, z80, ds390 etc.).
3401 \newline
3402
3403 \end_layout
3404
3405 \begin_layout Standard
3406 \align center
3407 \begin_inset Tabular
3408 <lyxtabular version="3" rows="6" columns="3">
3409 <features>
3410 <column alignment="block" valignment="top" leftline="true" width="1.7in">
3411 <column alignment="block" valignment="top" leftline="true" width="1.2in">
3412 <column alignment="block" valignment="top" leftline="true" rightline="true" width="1.2in">
3413 <row topline="true" bottomline="true">
3414 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3415 \begin_inset Text
3416
3417 \begin_layout Standard
3418 Search path
3419 \end_layout
3420
3421 \end_inset
3422 </cell>
3423 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3424 \begin_inset Text
3425
3426 \begin_layout Standard
3427 default
3428 \end_layout
3429
3430 \end_inset
3431 </cell>
3432 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3433 \begin_inset Text
3434
3435 \begin_layout Standard
3436 Win32 builds
3437 \end_layout
3438
3439 \end_inset
3440 </cell>
3441 </row>
3442 <row topline="true">
3443 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3444 \begin_inset Text
3445
3446 \begin_layout Standard
3447 -
3448 \begin_inset ERT
3449 status collapsed
3450
3451 \begin_layout Standard
3452
3453
3454 \backslash
3455 /
3456 \end_layout
3457
3458 \end_inset
3459
3460 -L dir
3461 \end_layout
3462
3463 \end_inset
3464 </cell>
3465 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3466 \begin_inset Text
3467
3468 \begin_layout Standard
3469 -
3470 \begin_inset ERT
3471 status collapsed
3472
3473 \begin_layout Standard
3474
3475
3476 \backslash
3477 /
3478 \end_layout
3479
3480 \end_inset
3481
3482 -L dir
3483 \end_layout
3484
3485 \end_inset
3486 </cell>
3487 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3488 \begin_inset Text
3489
3490 \begin_layout Standard
3491 -
3492 \begin_inset ERT
3493 status collapsed
3494
3495 \begin_layout Standard
3496
3497
3498 \backslash
3499 /
3500 \end_layout
3501
3502 \end_inset
3503
3504 -L dir
3505 \end_layout
3506
3507 \end_inset
3508 </cell>
3509 </row>
3510 <row topline="true">
3511 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3512 \begin_inset Text
3513
3514 \begin_layout Standard
3515 $SDCC_LIB/
3516 \newline
3517
3518 \emph on
3519 <model>
3520 \end_layout
3521
3522 \end_inset
3523 </cell>
3524 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3525 \begin_inset Text
3526
3527 \begin_layout Standard
3528 $SDCC_LIB/
3529 \newline
3530
3531 \emph on
3532 <model>
3533 \end_layout
3534
3535 \end_inset
3536 </cell>
3537 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3538 \begin_inset Text
3539
3540 \begin_layout Standard
3541 $SDCC_LIB
3542 \backslash
3543
3544 \newline
3545
3546 \emph on
3547 <model>
3548 \end_layout
3549
3550 \end_inset
3551 </cell>
3552 </row>
3553 <row topline="true">
3554 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3555 \begin_inset Text
3556
3557 \begin_layout Standard
3558 $SDCC_HOME/
3559 \newline
3560
3561 \emph on
3562 $PREFIX2DATA_DIR/
3563 \newline
3564 $LIB_DIR_SUFFIX/<model>
3565 \end_layout
3566
3567 \end_inset
3568 </cell>
3569 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3570 \begin_inset Text
3571
3572 \begin_layout Standard
3573 $SDCC_HOME/
3574 \newline
3575 share/sdcc/
3576 \newline
3577 lib/
3578 \emph on
3579 <model>
3580 \end_layout
3581
3582 \end_inset
3583 </cell>
3584 <cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3585 \begin_inset Text
3586
3587 \begin_layout Standard
3588 $SDCC_HOME
3589 \backslash
3590 lib
3591 \backslash
3592
3593 \emph on
3594
3595 \newline
3596 <model>
3597 \end_layout
3598
3599 \end_inset
3600 </cell>
3601 </row>
3602 <row topline="true">
3603 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3604 \begin_inset Text
3605
3606 \begin_layout Standard
3607 path(argv[0])/
3608 \newline
3609
3610 \emph on
3611 $BIN2DATADIR/
3612 \emph default
3613
3614 \newline
3615
3616 \emph on
3617 $LIB_DIR_SUFFIX/<model>
3618 \end_layout
3619
3620 \end_inset
3621 </cell>
3622 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3623 \begin_inset Text
3624
3625 \begin_layout Standard
3626 path(argv[0])/
3627 \newline
3628 ../sdcc/lib/
3629 \emph on
3630 <model>
3631 \newline
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 \InsetSpace ~
3656 \InsetSpace ~
3657 \InsetSpace ~
3658 \InsetSpace ~
3659 \InsetSpace ~
3660 \InsetSpace ~
3661 \InsetSpace ~
3662 \InsetSpace ~
3663 \InsetSpace ~
3664 \InsetSpace ~
3665 \InsetSpace ~
3666 \InsetSpace ~
3667 \InsetSpace ~
3668 \InsetSpace ~
3669 \InsetSpace ~
3670 \InsetSpace ~
3671
3672 \end_layout
3673
3674 \end_inset
3675 </cell>
3676 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3677 \begin_inset Text
3678
3679 \begin_layout Standard
3680 path(argv[0])
3681 \backslash
3682
3683 \newline
3684 ..
3685 \backslash
3686 lib
3687 \backslash
3688
3689 \emph on
3690 <model>
3691 \newline
3692 \InsetSpace ~
3693 \InsetSpace ~
3694 \InsetSpace ~
3695 \InsetSpace ~
3696 \InsetSpace ~
3697 \InsetSpace ~
3698 \InsetSpace ~
3699 \InsetSpace ~
3700 \InsetSpace ~
3701 \InsetSpace ~
3702 \InsetSpace ~
3703 \InsetSpace ~
3704 \InsetSpace ~
3705 \InsetSpace ~
3706 \InsetSpace ~
3707 \InsetSpace ~
3708 \InsetSpace ~
3709 \InsetSpace ~
3710 \InsetSpace ~
3711 \InsetSpace ~
3712 \InsetSpace ~
3713 \InsetSpace ~
3714 \InsetSpace ~
3715 \InsetSpace ~
3716 \InsetSpace ~
3717 \InsetSpace ~
3718 \InsetSpace ~
3719 \InsetSpace ~
3720 \InsetSpace ~
3721 \InsetSpace ~
3722 \InsetSpace ~
3723 \InsetSpace ~
3724 \InsetSpace ~
3725 \InsetSpace ~
3726 \InsetSpace ~
3727
3728 \end_layout
3729
3730 \end_inset
3731 </cell>
3732 </row>
3733 <row topline="true" bottomline="true">
3734 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3735 \begin_inset Text
3736
3737 \begin_layout Standard
3738
3739 \emph on
3740 $DATADIR/
3741 \newline
3742 $LIB_DIR_SUFFIX/<model>
3743 \end_layout
3744
3745 \end_inset
3746 </cell>
3747 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3748 \begin_inset Text
3749
3750 \begin_layout Standard
3751 /usr/local/share/sdcc/
3752 \newline
3753 lib/
3754 \emph on
3755 <model>
3756 \end_layout
3757
3758 \end_inset
3759 </cell>
3760 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3761 \begin_inset Text
3762
3763 \begin_layout Standard
3764 (not on Win32)
3765 \end_layout
3766
3767 \end_inset
3768 </cell>
3769 </row>
3770 </lyxtabular>
3771
3772 \end_inset
3773
3774
3775 \newline
3776
3777 \end_layout
3778
3779 \begin_layout Standard
3780 \begin_inset Note Note
3781 status collapsed
3782
3783 \begin_layout Standard
3784 Don't delete any of the stray spaces in the table above without checking
3785  the HTML output (last line)!
3786 \end_layout
3787
3788 \end_inset
3789
3790
3791 \end_layout
3792
3793 \begin_layout Standard
3794 \InsetSpace ~
3795
3796 \newline
3797 The option -
3798 \begin_inset ERT
3799 status collapsed
3800
3801 \begin_layout Standard
3802
3803
3804 \backslash
3805 /
3806 \end_layout
3807
3808 \end_inset
3809
3810 -nostdlib disables the last two search paths.
3811 \end_layout
3812
3813 \begin_layout Section
3814 Building SDCC
3815 \begin_inset LatexCommand \index{Building SDCC}
3816
3817 \end_inset
3818
3819
3820 \end_layout
3821
3822 \begin_layout Subsection
3823 Building SDCC on Linux
3824 \begin_inset LatexCommand \label{sub:Building-SDCC-on-Linux}
3825
3826 \end_inset
3827
3828
3829 \end_layout
3830
3831 \begin_layout Enumerate
3832
3833 \series medium
3834 Download the source package
3835 \series default
3836  either from the SDCC Subversion repository or from snapshot builds
3837 \series medium
3838 , it will be named something like sdcc
3839 \series default
3840 -src
3841 \series medium
3842 -yyyymmdd-rrrr.t
3843 \series default
3844 ar.
3845 \series medium
3846 bz2
3847 \series default
3848
3849 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
3850
3851 \end_inset
3852
3853 .
3854 \end_layout
3855
3856 \begin_layout Enumerate
3857
3858 \series medium
3859 Bring up a command line terminal, such as xterm.
3860 \end_layout
3861
3862 \begin_layout Enumerate
3863
3864 \series medium
3865 Unpack the file using a command like:
3866 \family sans
3867 \series bold
3868 "tar -xvzf sdcc-src-yyyymmdd-rrrr.tar.bz2
3869 \begin_inset Quotes srd
3870 \end_inset
3871
3872
3873 \family default
3874 \series medium
3875 , this will create a sub-directory called sdcc with all of the sources.
3876 \end_layout
3877
3878 \begin_layout Enumerate
3879 Change directory into the main SDCC directory, for example type:
3880 \family sans
3881 \series bold
3882 "cd sdcc
3883 \series default
3884 ".
3885 \end_layout
3886
3887 \begin_layout Enumerate
3888
3889 \series medium
3890 Type
3891 \family sans
3892 \series bold
3893 "./configure
3894 \family default
3895 \series default
3896 ".
3897  This configures the package for compilation on your system.
3898 \end_layout
3899
3900 \begin_layout Enumerate
3901
3902 \series medium
3903 Type
3904 \family sans
3905 \series bold
3906 "make
3907 \family default
3908 \series default
3909 "
3910 \series medium
3911 .
3912
3913 \series default
3914  All of the source packages will compile, this can take a while.
3915 \end_layout
3916
3917 \begin_layout Enumerate
3918
3919 \series medium
3920 Type
3921 \family sans
3922 \series bold
3923 "make install"
3924 \family default
3925 \series default
3926  as root
3927 \series medium
3928 .
3929
3930 \series default
3931  This copies the binary executables, the include files, the libraries and
3932  the documentation to the install directories.
3933  Proceed with section
3934 \begin_inset LatexCommand \ref{sec:Testing-the-SDCC}
3935
3936 \end_inset
3937
3938 .
3939 \end_layout
3940
3941 \begin_layout Subsection
3942 Building SDCC on Mac OS X
3943 \end_layout
3944
3945 \begin_layout Standard
3946 Follow the instruction for Linux.
3947 \newline
3948
3949 \newline
3950 On Mac OS X 10.2.x it was reported, that the
3951  default gcc (version 3.1 20020420 (prerelease)) fails to compile SDCC.
3952  Fortunately there's also gcc 2.9.x installed, which works fine.
3953  This compiler can be selected by running 'configure' with:
3954 \end_layout
3955
3956 \begin_layout LyX-Code
3957 ./configure CC=gcc2 CXX=g++2
3958 \end_layout
3959
3960 \begin_layout Standard
3961 Universal (ppc and i386) binaries can be produced on Mac OS X 10.4.x with
3962  Xcode.
3963  Run 'configure' with:
3964 \end_layout
3965
3966 \begin_layout LyX-Code
3967 ./configure
3968 \backslash
3969
3970 \end_layout
3971
3972 \begin_layout LyX-Code
3973 LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
3974  ppc"
3975 \backslash
3976
3977 \end_layout
3978
3979 \begin_layout LyX-Code
3980 CXXFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
3981  ppc"
3982 \backslash
3983
3984 \end_layout
3985
3986 \begin_layout LyX-Code
3987 CFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
3988 \end_layout
3989
3990 \begin_layout Subsection
3991 Cross compiling SDCC on Linux for Windows
3992 \end_layout
3993
3994 \begin_layout Standard
3995 With the Mingw32 gcc cross compiler it's easy to compile SDCC for Win32.
3996  See section 'Configure Options'.
3997 \end_layout
3998
3999 \begin_layout Subsection
4000 Building SDCC using Cygwin and Mingw32
4001 \end_layout
4002
4003 \begin_layout Standard
4004 For building and installing a Cygwin executable follow the instructions
4005  for Linux.
4006 \newline
4007
4008 \newline
4009 On Cygwin a
4010 \begin_inset Quotes sld
4011 \end_inset
4012
4013 native
4014 \begin_inset Quotes srd
4015 \end_inset
4016
4017  Win32-binary can be built, which will not need the Cygwin-DLL.
4018  For the necessary 'configure' options see section 'configure options' or
4019  the script 'sdcc/support/scripts/sdcc_cygwin_mingw32'.
4020 \newline
4021
4022 \newline
4023 In order to install
4024  Cygwin on Windows download setup.exe from
4025 \begin_inset LatexCommand \url[www.cygwin.com]{http://www.cygwin.com/}
4026
4027 \end_inset
4028
4029 .
4030  Run it, set the
4031 \begin_inset Quotes sld
4032 \end_inset
4033
4034 default text file type
4035 \begin_inset Quotes srd
4036 \end_inset
4037
4038  to
4039 \begin_inset Quotes sld
4040 \end_inset
4041
4042 unix
4043 \begin_inset Quotes srd
4044 \end_inset
4045
4046  and download/install at least the following packages.
4047  Some packages are selected by default, others will be automatically selected
4048  because of dependencies with the manually selected packages.
4049  Never deselect these packages!
4050 \end_layout
4051
4052 \begin_layout Itemize
4053 flex
4054 \end_layout
4055
4056 \begin_layout Itemize
4057 bison
4058 \end_layout
4059
4060 \begin_layout Itemize
4061 gcc ; version 3.x is fine, no need to use the old 2.9x
4062 \end_layout
4063
4064 \begin_layout Itemize
4065 binutils ; selected with gcc
4066 \end_layout
4067
4068 \begin_layout Itemize
4069 make
4070 \end_layout
4071
4072 \begin_layout Itemize
4073 rxvt ; a nice console, which makes life much easier under windoze (see below)
4074 \end_layout
4075
4076 \begin_layout Itemize
4077 man ; not really needed for building SDCC, but you'll miss it sooner or
4078  later
4079 \end_layout
4080
4081 \begin_layout Itemize
4082 less ; not really needed for building SDCC, but you'll miss it sooner or
4083  later
4084 \end_layout
4085
4086 \begin_layout Itemize
4087 svn ; only if you use Subversion access
4088 \end_layout
4089
4090 \begin_layout Standard
4091 If you want to develop something you'll need:
4092 \end_layout
4093
4094 \begin_layout Itemize
4095 python ; for the regression tests
4096 \end_layout
4097
4098 \begin_layout Itemize
4099 gdb ; the gnu debugger, together with the nice GUI
4100 \begin_inset Quotes sld
4101 \end_inset
4102
4103 insight
4104 \begin_inset Quotes srd
4105 \end_inset
4106
4107
4108 \end_layout
4109
4110 \begin_layout Itemize
4111 openssh ; to access the CF or commit changes
4112 \end_layout
4113
4114 \begin_layout Itemize
4115 autoconf and autoconf-devel ; if you want to fight with 'configure', don't
4116  use autoconf-stable!
4117 \end_layout
4118
4119 \begin_layout Standard
4120 rxvt is a nice console with history.
4121  Replace in your cygwin.bat the line
4122 \end_layout
4123
4124 \begin_layout LyX-Code
4125 bash -
4126 \begin_inset ERT
4127 status collapsed
4128
4129 \begin_layout Standard
4130
4131
4132 \backslash
4133 /
4134 \end_layout
4135
4136 \end_inset
4137
4138 -login -i
4139 \end_layout
4140
4141 \begin_layout Standard
4142 with (one line):
4143 \end_layout
4144
4145 \begin_layout LyX-Code
4146 rxvt -sl 1000 -fn "Lucida Console-12" -sr -cr red
4147 \end_layout
4148
4149 \begin_layout LyX-Code
4150      -bg black -fg white -geometry 100x65 -e bash -
4151 \begin_inset ERT
4152 status collapsed
4153
4154 \begin_layout Standard
4155
4156
4157 \backslash
4158 /
4159 \end_layout
4160
4161 \end_inset
4162
4163 -login
4164 \end_layout
4165
4166 \begin_layout Standard
4167 Text selected with the mouse is automatically copied to the clipboard, pasting
4168  works with shift-insert.
4169 \newline
4170
4171 \newline
4172 The other good tip is to make sure you have no //c/-styl
4173 e paths anywhere, use /cygdrive/c/ instead.
4174  Using // invokes a network lookup which is very slow.
4175  If you think
4176 \begin_inset Quotes sld
4177 \end_inset
4178
4179 cygdrive
4180 \begin_inset Quotes srd
4181 \end_inset
4182
4183  is too long, you can change it with e.g.
4184 \end_layout
4185
4186 \begin_layout LyX-Code
4187 mount -s -u -c /mnt
4188 \end_layout
4189
4190 \begin_layout Standard
4191 SDCC sources use the unix line ending LF.
4192  Life is much easier, if you store the source tree on a drive which is mounted
4193  in binary mode.
4194  And use an editor which can handle LF-only line endings.
4195  Make sure not to commit files with windows line endings.
4196  The tabulator spacing
4197 \begin_inset LatexCommand \index{tabulator spacing (8 columns)}
4198
4199 \end_inset
4200
4201  used in the project is 8.
4202  Although a tabulator spacing of 8 is a sensible choice for programmers
4203  (it's a power of 2 and allows to display 8/16 bit signed variables without
4204  loosing columns) the plan is to move towards using only spaces in the source.
4205 \end_layout
4206
4207 \begin_layout Subsection
4208 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)
4209 \end_layout
4210
4211 \begin_layout Standard
4212
4213 \series medium
4214 Download the source package
4215 \series default
4216  either from the SDCC Subversion repository or from the
4217 \begin_inset LatexCommand \url[snapshot builds]{http://sdcc.sourceforge.net/snap.php}
4218
4219 \end_inset
4220
4221
4222 \series medium
4223 , it will be named something like sdcc
4224 \series default
4225 -src
4226 \series medium
4227 -yyyymmdd-rrrr.tar.bz2.
4228
4229 \series default
4230  SDCC is distributed with all the projects, workspaces, and files you need
4231  to build it using Visual C++ 6.0/NET (except for SDCDB and ucSim).
4232  The workspace name is 'sdcc.dsw'.
4233  Please note that as it is now, all the executables are created in a folder
4234  called sdcc
4235 \backslash
4236 bin_vc.
4237  Once built you need to copy the executables from sdcc
4238 \backslash
4239 bin_vc to sdcc
4240 \backslash
4241 bin before running SDCC.
4242 \newline
4243
4244 \newline
4245 WARNING: Visual studio is very picky with line terminatio
4246 ns; it expects the 0x0d, 0x0a DOS style line endings, not the 0x0a Unix
4247  style line endings.
4248  When using the Subversion repository it's easiest to configure the svn
4249  client to convert automatically for you.
4250  If however you are getting a message such as "This makefile was not generated
4251  by Developer Studio etc.
4252  etc.
4253 \begin_inset Quotes srd
4254 \end_inset
4255
4256  when opening the sdcc.dsw workspace or any of the *.dsp projects, then you
4257  need to convert the Unix style line endings to DOS style line endings.
4258  To do so you can use the
4259 \begin_inset Quotes sld
4260 \end_inset
4261
4262 unix2dos
4263 \begin_inset Quotes srd
4264 \end_inset
4265
4266  utility freely available on the internet.
4267  Doug Hawkins reported in the sdcc-user list that this works:
4268 \newline
4269
4270 \newline
4271 C:
4272 \backslash
4273 Programming
4274 \backslash
4275 SDCC> unix2dos sdcc.dsw
4276 \newline
4277 C:
4278 \backslash
4279 Programming
4280 \backslash
4281 SDCC> for /R %I in (*.dsp) do @unix2dos "%I"
4282 \newline
4283
4284 \newline
4285 In order to build SDCC with MSVC
4286  you need win32 executables of bison.exe, flex.exe, and gawk.exe.
4287  One good place to get them is
4288 \begin_inset LatexCommand \url[here]{http://unxutils.sourceforge.net}
4289
4290 \end_inset
4291
4292
4293 \newline
4294
4295 \newline
4296 Download the file UnxUtils
4297 \begin_inset LatexCommand \index{UnxUtils}
4298
4299 \end_inset
4300
4301 .zip.
4302  Now you have to install the utilities and setup MSVC so it can locate the
4303  required programs.
4304  Here there are two alternatives (choose one!):
4305 \end_layout
4306
4307 \begin_layout Enumerate
4308 The easy way:
4309 \newline
4310
4311 \newline
4312 a) Extract UnxUtils.zip to your C:
4313 \backslash
4314  hard disk PRESERVING the original paths, otherwise bison won't work.
4315  (If you are using WinZip make certain that 'Use folder names' is selected)
4316 \newline
4317
4318 \newline
4319 b)
4320  In the Visual C++ IDE click Tools, Options, select the Directory tab, in
4321  'Show directories for:' select 'Executable files', and in the directories
4322  window add a new path: 'C:
4323 \backslash
4324 user
4325 \backslash
4326 local
4327 \backslash
4328 wbin', click ok.
4329 \newline
4330
4331 \newline
4332 (As a side effect, you get a bunch of Unix utilities that
4333  could be useful, such as diff and patch.)
4334 \end_layout
4335
4336 \begin_layout Enumerate
4337 A more compact way:
4338 \newline
4339
4340 \newline
4341 This one avoids extracting a bunch of files you may not
4342  use, but requires some extra work:
4343 \newline
4344
4345 \newline
4346 a) Create a directory were to put the
4347  tools needed, or use a directory already present.
4348  Say for example 'C:
4349 \backslash
4350 util'.
4351 \newline
4352
4353 \newline
4354 b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and
4355  gawk.exe to such directory WITHOUT preserving the original paths.
4356  (If you are using WinZip make certain that 'Use folder names' is not selected)
4357 \newline
4358
4359 \newline
4360 c
4361 ) Rename bison.exe to '_bison.exe'.
4362 \newline
4363
4364 \newline
4365 d) Create a batch file 'bison.bat' in 'C:
4366 \backslash
4367 util
4368 \backslash
4369 ' and add these lines:
4370 \newline
4371 \InsetSpace ~
4372 \InsetSpace ~
4373 set BISON_SIMPLE=C:
4374 \backslash
4375 util
4376 \backslash
4377 bison.simple
4378 \newline
4379 \InsetSpace ~
4380 \InsetSpace ~
4381 set BISON_HAIRY=C:
4382 \backslash
4383 util
4384 \backslash
4385 bison.hairy
4386 \newline
4387 \InsetSpace ~
4388 \InsetSpace ~
4389 _bison %1 %2 %3 %4 %5 %6 %7 %8 %9
4390 \newline
4391
4392 \newline
4393 Steps 'c' and 'd' are needed
4394  because bison requires by default that the files 'bison.simple' and 'bison.hairy'
4395  reside in some weird Unix directory, '/usr/local/share/' I think.
4396  So it is necessary to tell bison where those files are located if they
4397  are not in such directory.
4398  That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.
4399 \newline
4400
4401 \newline
4402 e
4403 ) In the Visual C++ IDE click Tools, Options, select the Directory tab,
4404  in 'Show directories for:' select 'Executable files', and in the directories
4405  window add a new path: 'c:
4406 \backslash
4407 util', click ok.
4408  Note that you can use any other path instead of 'c:
4409 \backslash
4410 util', even the path where the Visual C++ tools are, probably: 'C:
4411 \backslash
4412 Program Files
4413 \backslash
4414 Microsoft Visual Studio
4415 \backslash
4416 Common
4417 \backslash
4418 Tools'.
4419  So you don't have to execute step 'e' :)
4420 \end_layout
4421
4422 \begin_layout Standard
4423 That is it.
4424  Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy
4425  the executables from sdcc
4426 \backslash
4427 bin_vc to sdcc
4428 \backslash
4429 bin, and you can compile using SDCC.
4430 \end_layout
4431
4432 \begin_layout Subsection
4433 Building SDCC Using Borland
4434 \end_layout
4435
4436 \begin_layout Enumerate
4437 From the sdcc directory, run the command "make -f Makefile.bcc".
4438  This should regenerate all the .exe files in the bin directory except for
4439  SDCDB and ucSim.
4440 \end_layout
4441
4442 \begin_layout Enumerate
4443 If you modify any source files and need to rebuild, be aware that the dependenci
4444 es may not be correctly calculated.
4445  The safest option is to delete all .obj files and run the build again.
4446  From a Cygwin BASH prompt, this can easily be done with the command (be
4447  sure you are in the sdcc directory):
4448 \newline
4449
4450 \newline
4451
4452 \family sans
4453 \series bold
4454 find .
4455 \backslash
4456 ( -name '*.obj' -o -name '*.lib' -o -name '*.rul'
4457 \backslash
4458 ) -print -exec rm {}
4459 \backslash
4460 ;
4461 \family default
4462 \series default
4463
4464 \newline
4465
4466 \newline
4467 or on Windows NT/2000/XP from the command prompt with the command:
4468 \newline
4469
4470 \family sans
4471 \series bold
4472
4473 \newline
4474 del /s *.obj *.lib *.rul
4475 \family default
4476 \series default
4477  from the sdcc directory.
4478 \end_layout
4479
4480 \begin_layout Subsection
4481 Windows Install Using a ZIP Package
4482 \end_layout
4483
4484 \begin_layout Enumerate
4485 Download the binary zip package from
4486 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4487
4488 \end_inset
4489
4490  and unpack it using your favorite unpacking tool (gunzip, WinZip, etc).
4491  This should unpack to a group of sub-directories.
4492  An example directory structure after unpacking the mingw32 package is:
4493  c:
4494 \backslash
4495 sdcc
4496 \backslash
4497 bin for the executables, c:
4498 \backslash
4499 sdcc
4500 \backslash
4501 include and c:
4502 \backslash
4503 sdcc
4504 \backslash
4505 lib for the include and libraries.
4506 \end_layout
4507
4508 \begin_layout Enumerate
4509 Adjust your environment variable PATH to include the location of the bin
4510  directory or start sdcc using the full path.
4511 \end_layout
4512
4513 \begin_layout Subsection
4514 Windows Install Using the Setup Program
4515 \begin_inset LatexCommand \label{sub:Windows-Install}
4516
4517 \end_inset
4518
4519
4520 \end_layout
4521
4522 \begin_layout Standard
4523 Download the setup program
4524 \emph on
4525 sdcc-x.y.z-setup.exe
4526 \emph default
4527  for an official release from
4528 \newline
4529
4530 \begin_inset LatexCommand \url{http://sf.net/project/showfiles.php?group_id=599}
4531
4532 \end_inset
4533
4534  or a setup program for one of the snapshots
4535 \emph on
4536 sdcc-yyyymmdd-xxxx-setup.exe
4537 \emph default
4538  from
4539 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4540
4541 \end_inset
4542
4543  and execute it.
4544  A windows typical installer will guide you through the installation process.
4545 \end_layout
4546
4547 \begin_layout Subsection
4548 VPATH
4549 \begin_inset LatexCommand \index{VPATH}
4550
4551 \end_inset
4552
4553  feature
4554 \end_layout
4555
4556 \begin_layout Standard
4557 SDCC supports the VPATH feature provided by configure and make.
4558  It allows to separate the source and build trees.
4559  Here's an example:
4560 \end_layout
4561
4562 \begin_layout Standard
4563
4564 \family typewriter
4565 cd ~\InsetSpace ~
4566 \InsetSpace ~
4567 \InsetSpace ~
4568 \InsetSpace ~
4569 \InsetSpace ~
4570 \InsetSpace ~
4571 \InsetSpace ~
4572 \InsetSpace ~
4573 \InsetSpace ~
4574 \InsetSpace ~
4575 \InsetSpace ~
4576 \InsetSpace ~
4577 \InsetSpace ~
4578 \InsetSpace ~
4579 \InsetSpace ~
4580 \InsetSpace ~
4581 \InsetSpace ~
4582 \InsetSpace ~
4583 \InsetSpace ~
4584 \InsetSpace ~
4585 \InsetSpace ~
4586 # cd $HOME
4587 \end_layout
4588
4589 \begin_layout Standard
4590
4591 \family typewriter
4592 tar -xzf sdcc.src.tar.gz\InsetSpace ~
4593 # extract source to directory sdcc
4594 \end_layout
4595
4596 \begin_layout Standard
4597
4598 \family typewriter
4599 mkdir sdcc.build\InsetSpace ~
4600 \InsetSpace ~
4601 \InsetSpace ~
4602 \InsetSpace ~
4603 \InsetSpace ~
4604 \InsetSpace ~
4605 \InsetSpace ~
4606 \InsetSpace ~
4607 \InsetSpace ~
4608 # put output in sdcc.build
4609 \end_layout
4610
4611 \begin_layout Standard
4612
4613 \family typewriter
4614 cd sdcc.build
4615 \end_layout
4616
4617 \begin_layout Standard
4618
4619 \family typewriter
4620 ../sdcc/configure\InsetSpace ~
4621 \InsetSpace ~
4622 \InsetSpace ~
4623 \InsetSpace ~
4624 \InsetSpace ~
4625 \InsetSpace ~
4626 \InsetSpace ~
4627 \InsetSpace ~
4628 # configure is doing all the magic!
4629 \end_layout
4630
4631 \begin_layout Standard
4632
4633 \family typewriter
4634 make
4635 \end_layout
4636
4637 \begin_layout Standard
4638 \noindent
4639 That's it!
4640 \series bold
4641 configure
4642 \series default
4643  will create the directory tree will all the necessary Makefiles in ~/sdcc.build.
4644  It automagically computes the variables srcdir, top_srcdir and top_buildir
4645  for each directory.
4646  After running
4647 \series bold
4648 make
4649 \series default
4650  the generated files will be in ~/sdcc.build, while the source files stay
4651  in ~/sdcc.
4652 \newline
4653 This is not only usefull for building different binaries, e.g.
4654  when cross compiling.
4655  It also gives you a much better overview in the source tree when all the
4656  generated files are not scattered between the source files.
4657  And the best thing is: if you want to change a file you can leave the original
4658  file untouched in the source directory.
4659  Simply copy it to the build directory, edit it, enter `make clean', `rm
4660  Makefile.dep' and `make'.
4661 \series bold
4662 make
4663 \series default
4664  will do the rest for you!
4665 \end_layout
4666
4667 \begin_layout Section
4668 Building the Documentation
4669 \end_layout
4670
4671 \begin_layout Standard
4672 Add -
4673 \begin_inset ERT
4674 status collapsed
4675
4676 \begin_layout Standard
4677
4678
4679 \backslash
4680 /
4681 \end_layout
4682
4683 \end_inset
4684
4685 -enable-doc to the configure arguments to build the documentation together
4686  with all the other stuff.
4687  You will need several tools (LyX, LaTeX, LaTeX2HTML, pdflatex, dvipdf,
4688  dvips and makeindex) to get the job done.
4689  Another possibility is to change to the doc directory and to type
4690 \family sans
4691 \series bold
4692
4693 \begin_inset Quotes srd
4694 \end_inset
4695
4696 make
4697 \begin_inset Quotes srd
4698 \end_inset
4699
4700
4701 \family default
4702 \series default
4703  there.
4704  You're invited to make changes and additions to this manual (sdcc/doc/sdccman.ly
4705 x).
4706  Using LyX
4707 \begin_inset LatexCommand \url{http://www.lyx.org}
4708
4709 \end_inset
4710
4711  as editor is straightforward.
4712  Prebuilt documentation in html and pdf format is available from
4713 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4714
4715 \end_inset
4716
4717 .
4718 \end_layout
4719
4720 \begin_layout Section
4721 Reading the Documentation
4722 \begin_inset LatexCommand \index{Documentation}
4723
4724 \end_inset
4725
4726
4727 \end_layout
4728
4729 \begin_layout Standard
4730 Currently reading the document in pdf format is recommended, as for unknown
4731  reason the hyperlinks are working there whereas in the html version they
4732  are not
4733 \begin_inset Foot
4734 status open
4735
4736 \begin_layout Standard
4737 If you should know why please drop us a note
4738 \end_layout
4739
4740 \end_inset
4741
4742 .
4743 \newline
4744 You'll find the pdf version
4745 \begin_inset LatexCommand \index{PDF version of this document}
4746
4747 \end_inset
4748
4749  at
4750 \begin_inset LatexCommand \url{http://sdcc.sf.net/doc/sdccman.pdf}
4751
4752 \end_inset
4753
4754 .
4755 \newline
4756 A html version
4757 \begin_inset LatexCommand \index{HTML version of this document}
4758
4759 \end_inset
4760
4761  should be online at
4762 \begin_inset LatexCommand \url{http://sdcc.sf.net/doc/sdccman.html/index.html}
4763
4764 \end_inset
4765
4766 .
4767 \newline
4768 This documentation is in some aspects different from a commercial documentation:
4769 \end_layout
4770
4771 \begin_layout Itemize
4772 It tries to document SDCC for several processor architectures in one document
4773  (commercially these probably would be separate documents/products).
4774  This document
4775 \begin_inset LatexCommand \index{Status of documentation}
4776
4777 \end_inset
4778
4779  currently matches SDCC for mcs51 and DS390 best and does give too few informati
4780 on about f.e.
4781  Z80, PIC14, PIC16 and HC08.
4782 \end_layout
4783
4784 \begin_layout Itemize
4785 There are many references pointing away from this documentation.
4786  Don't let this distract you.
4787  If there f.e.
4788  was a reference like
4789 \begin_inset LatexCommand \url{http://www.opencores.org}
4790
4791 \end_inset
4792
4793  together with a statement
4794 \begin_inset Quotes sld
4795 \end_inset
4796
4797 some processors which are targetted by SDCC can be implemented in a
4798 \emph on
4799 f
4800 \emph default
4801 ield
4802 \emph on
4803 p
4804 \emph default
4805 rogrammable
4806 \emph on
4807 g
4808 \emph default
4809 ate
4810 \emph on
4811 a
4812 \emph default
4813 rray
4814 \begin_inset LatexCommand \index{FPGA (field programmable gate array)}
4815
4816 \end_inset
4817
4818
4819 \begin_inset Quotes srd
4820 \end_inset
4821
4822  or
4823 \begin_inset LatexCommand \url{http://sf.net/projects/fpgac}
4824
4825 \end_inset
4826
4827
4828 \begin_inset LatexCommand \index{FpgaC ((subset of) C to FPGA compiler)}
4829
4830 \end_inset
4831
4832
4833 \begin_inset Quotes sld
4834 \end_inset
4835
4836 have you ever heard of an open source compiler that compiles a subset of
4837  C for an FPGA?
4838 \begin_inset Quotes srd
4839 \end_inset
4840
4841  we expect you to have a quick look there and come back.
4842  If you read this you are on the right track.
4843 \end_layout
4844
4845 \begin_layout Itemize
4846 Some sections attribute more space to problems, restrictions and warnings
4847  than to the solution.
4848 \end_layout
4849
4850 \begin_layout Itemize
4851 The installation section and the section about the debugger is intimidating.
4852 \end_layout
4853
4854 \begin_layout Itemize
4855 There are still lots of typos and there are more different writing styles
4856  than pictures.
4857 \end_layout
4858
4859 \begin_layout Section
4860 Testing the SDCC Compiler
4861 \begin_inset LatexCommand \label{sec:Testing-the-SDCC}
4862
4863 \end_inset
4864
4865
4866 \end_layout
4867
4868 \begin_layout Standard
4869 The first thing you should do after installing your SDCC compiler is to
4870  see if it runs.
4871  Type
4872 \family sans
4873 \series bold
4874 "sdcc -
4875 \begin_inset ERT
4876 status collapsed
4877
4878 \begin_layout Standard
4879
4880
4881 \backslash
4882 /
4883 \end_layout
4884
4885 \end_inset
4886
4887 -version"
4888 \begin_inset LatexCommand \index{version}
4889
4890 \end_inset
4891
4892
4893 \family default
4894 \series default
4895  at the prompt, and the program should run and output its version like:
4896 \newline
4897
4898 \family typewriter
4899 SDCC : mcs51/z80/avr/ds390/pic16/pic14/ds400/hc08 2.5.6 #4169 (May 8 2006)
4900  (UNIX)
4901 \end_layout
4902
4903 \begin_layout Standard
4904 If it doesn't run, or gives a message about not finding sdcc program, then
4905  you need to check over your installation.
4906  Make sure that the sdcc bin directory is in your executable search path
4907  defined by the PATH environment setting (
4908 \series medium
4909 see
4910 \series default
4911 section
4912 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
4913
4914 \end_inset
4915
4916 \InsetSpace ~
4917
4918 \series medium
4919 Install trouble-shooting for suggestions
4920 \series default
4921 ).
4922  Make sure that the sdcc program is in the bin folder, if not perhaps something
4923  did not install correctly.
4924 \newline
4925
4926 \newline
4927
4928 \series medium
4929 SDCC
4930 \series default
4931 is commonly installed as described in section
4932 \begin_inset Quotes sld
4933 \end_inset
4934
4935 Install and search paths
4936 \begin_inset Quotes srd
4937 \end_inset
4938
4939 .
4940 \newline
4941
4942 \newline
4943
4944 \series medium
4945 Make sure the compiler works on a very simple example.
4946  Type in the following test.c program using your favorite
4947 \series default
4948 ASCII
4949 \series medium
4950 editor:
4951 \end_layout
4952
4953 \begin_layout Verse
4954
4955 \family typewriter
4956 char test;
4957 \newline
4958
4959 \newline
4960 void main(void) {
4961 \newline
4962 \InsetSpace ~
4963 \InsetSpace ~
4964 \InsetSpace ~
4965 \InsetSpace ~
4966 test=0;
4967 \newline
4968 }
4969 \end_layout
4970
4971 \begin_layout Standard
4972
4973 \series medium
4974 Compile this using the following command:
4975 \family sans
4976 \series bold
4977 "sdcc -c test.c".
4978 \family default
4979 \series medium
4980 If all goes well, the compiler will generate a test.asm and test.rel file.
4981  Congratulations, you've just compiled your first program with SDCC.
4982  We used the -c option to tell SDCC not to link the generated code, just
4983  to keep things simple for this step.
4984 \series default
4985
4986 \newline
4987
4988 \newline
4989
4990 \series medium
4991 The next step is to try it with the linker.
4992  Type in
4993 \family sans
4994 \series bold
4995 "sdcc test.c
4996 \family default
4997 \series default
4998 "
4999 \series medium
5000 .
5001  If all goes well the compiler will link with the libraries and produce
5002  a test.ihx output file.
5003  If this step fails(no test.ihx, and the linker generates warnings), then
5004  the problem is most likely that
5005 \series default
5006 SDCC
5007 \series medium
5008  cannot find the
5009 \series default
5010 /
5011 \series medium
5012 usr/local/share/sdcc/lib directory(see
5013 \series default
5014 section
5015 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5016
5017 \end_inset
5018
5019 \InsetSpace ~
5020
5021 \series medium
5022 Install trouble-shooting for suggestions).
5023 \series default
5024
5025 \newline
5026
5027 \newline
5028
5029 \series medium
5030 The final test is to ensure
5031 \series default
5032 SDCC
5033 \series medium
5034  can use the
5035 \series default
5036 standard
5037 \series medium
5038  header files and libraries.
5039  Edit test.c and change it to the following:
5040 \end_layout
5041
5042 \begin_layout Verse
5043
5044 \family typewriter
5045 #include <string.h>
5046 \newline
5047
5048 \newline
5049 char str1[10];
5050 \newline
5051
5052 \newline
5053 void main(void) {
5054 \newline
5055 \InsetSpace ~
5056 \InsetSpace ~
5057 strcpy(str1, "testing");
5058 \newline
5059 }
5060 \end_layout
5061
5062 \begin_layout Standard
5063
5064 \series medium
5065 Compile this by typing
5066 \family sans
5067 \series bold
5068 "sdcc test.c"
5069 \family default
5070 \series medium
5071 .
5072  This should generate a test.ihx output file, and it should give no warnings
5073  such as not finding the string.h file.
5074  If it cannot find the string.h file, then the problem is that
5075 \series default
5076 SDCC
5077 \series medium
5078  cannot find the /usr/local/share/sdcc/include directory(see the
5079 \series default
5080 section
5081 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5082
5083 \end_inset
5084
5085 \InsetSpace ~
5086
5087 \series medium
5088 Install trouble-shooting section for suggestions).
5089
5090 \series default
5091  Use option
5092 \series bold
5093 -
5094 \begin_inset ERT
5095 status collapsed
5096
5097 \begin_layout Standard
5098
5099
5100 \backslash
5101 /
5102 \end_layout
5103
5104 \end_inset
5105
5106 -print-search-dirs
5107 \series default
5108
5109 \begin_inset LatexCommand \index{-\/-print-search-dirs}
5110
5111 \end_inset
5112
5113  to find exactly where SDCC is looking for the include and lib files.
5114 \end_layout
5115
5116 \begin_layout Section
5117 Install Trouble-shooting
5118 \begin_inset LatexCommand \label{sub:Install-Trouble-shooting}
5119
5120 \end_inset
5121
5122
5123 \begin_inset LatexCommand \index{Install trouble-shooting}
5124
5125 \end_inset
5126
5127
5128 \end_layout
5129
5130 \begin_layout Subsection
5131 If SDCC does not build correctly
5132 \end_layout
5133
5134 \begin_layout Standard
5135 A thing to try is starting from scratch by unpacking the .tgz source package
5136  again in an empty directory.
5137  Configure it like:
5138 \newline
5139
5140 \newline
5141
5142 \family sans
5143 \series bold
5144 ./configure 2>&1 | tee configure.log
5145 \family default
5146 \series default
5147
5148 \newline
5149
5150 \newline
5151 and build it like:
5152 \newline
5153
5154 \newline
5155
5156 \family sans
5157 \series bold
5158 make 2>&1 | tee make.log
5159 \family default
5160 \series default
5161
5162 \newline
5163
5164 \newline
5165 If anything goes wrong, you can review the log files to locate the problem.
5166  Or a relevant part of this can be attached to an email that could be helpful
5167  when requesting help from the mailing list.
5168 \end_layout
5169
5170 \begin_layout Subsection
5171 What the
5172 \begin_inset Quotes sld
5173 \end_inset
5174
5175 ./configure
5176 \begin_inset Quotes srd
5177 \end_inset
5178
5179  does
5180 \end_layout
5181
5182 \begin_layout Standard
5183 The
5184 \begin_inset Quotes sld
5185 \end_inset
5186
5187 ./configure
5188 \begin_inset Quotes srd
5189 \end_inset
5190
5191  command is a script that analyzes your system and performs some configuration
5192  to ensure the source package compiles on your system.
5193  It will take a few minutes to run, and will compile a few tests to determine
5194  what compiler features are installed.
5195 \end_layout
5196
5197 \begin_layout Subsection
5198 What the
5199 \begin_inset Quotes sld
5200 \end_inset
5201
5202 make
5203 \begin_inset Quotes srd
5204 \end_inset
5205
5206  does
5207 \end_layout
5208
5209 \begin_layout Standard
5210 This runs the GNU make tool, which automatically compiles all the source
5211  packages into the final installed binary executables.
5212 \end_layout
5213
5214 \begin_layout Subsection
5215 What the
5216 \begin_inset Quotes sld
5217 \end_inset
5218
5219 make install
5220 \begin_inset Quotes erd
5221 \end_inset
5222
5223  command does.
5224 \end_layout
5225
5226 \begin_layout Standard
5227 This will install the compiler, other executables libraries and include
5228  files into the appropriate directories.
5229  See sections
5230 \begin_inset LatexCommand \ref{sub:Install-paths}
5231
5232 \end_inset
5233
5234 ,\InsetSpace ~
5235
5236 \begin_inset LatexCommand \ref{sub:Search-Paths}
5237
5238 \end_inset
5239
5240 \InsetSpace ~
5241 about install and search paths.
5242 \newline
5243 On most systems you will need super-user privilege
5244 s to do this.
5245 \end_layout
5246
5247 \begin_layout Section
5248 Components of SDCC
5249 \end_layout
5250
5251 \begin_layout Standard
5252 SDCC is not just a compiler, but a collection of tools by various developers.
5253  These include linkers, assemblers, simulators and other components.
5254  Here is a summary of some of the components.
5255  Note that the included simulator and assembler have separate documentation
5256  which you can find in the source package in their respective directories.
5257  As SDCC grows to include support for other processors, other packages from
5258  various developers are included and may have their own sets of documentation.
5259 \newline
5260
5261 \newline
5262 You
5263  might want to look at the files which are installed in <installdir>.
5264  At the time of this writing, we find the following programs for gcc-builds:
5265 \newline
5266
5267 \newline
5268 In
5269  <installdir>/bin:
5270 \end_layout
5271
5272 \begin_layout Itemize
5273 sdcc - The compiler.
5274 \end_layout
5275
5276 \begin_layout Itemize
5277 sdcpp - The C preprocessor.
5278 \end_layout
5279
5280 \begin_layout Itemize
5281 asx8051 - The assembler for 8051 type processors.
5282 \end_layout
5283
5284 \begin_layout Itemize
5285 as-z80
5286 \series bold
5287 ,
5288 \series default
5289 as-gbz80 - The Z80 and GameBoy Z80 assemblers.
5290 \end_layout
5291
5292 \begin_layout Itemize
5293 aslink -The linker for 8051 type processors.
5294 \end_layout
5295
5296 \begin_layout Itemize
5297 link-z80
5298 \series bold
5299 ,
5300 \series default
5301 link-gbz80 - The Z80 and GameBoy Z80 linkers.
5302 \end_layout
5303
5304 \begin_layout Itemize
5305 s51 - The ucSim 8051 simulator.
5306 \end_layout
5307
5308 \begin_layout Itemize
5309 sdcdb - The source debugger.
5310 \end_layout
5311
5312 \begin_layout Itemize
5313 packihx - A tool to pack (compress) Intel hex files.
5314 \end_layout
5315
5316 \begin_layout Standard
5317 In <installdir>/share/sdcc/include
5318 \end_layout
5319
5320 \begin_layout Itemize
5321 the include files
5322 \end_layout
5323
5324 \begin_layout Standard
5325 In <installdir>/share/sdcc/lib
5326 \end_layout
5327
5328 \begin_layout Itemize
5329 the subdirs src and small, large, z80, gbz80 and ds390 with the precompiled
5330  relocatables.
5331 \end_layout
5332
5333 \begin_layout Standard
5334 In <installdir>/share/sdcc/doc
5335 \end_layout
5336
5337 \begin_layout Itemize
5338 the documentation
5339 \end_layout
5340
5341 \begin_layout Standard
5342 As development for other processors proceeds, this list will expand to include
5343  executables to support processors like AVR, PIC, etc.
5344 \end_layout
5345
5346 \begin_layout Subsection
5347 sdcc - The Compiler
5348 \end_layout
5349
5350 \begin_layout Standard
5351 This is the actual compiler, it in turn uses the c-preprocessor and invokes
5352  the assembler and linkage editor.
5353 \end_layout
5354
5355 \begin_layout Subsection
5356 sdcpp - The C-Preprocessor
5357 \end_layout
5358
5359 \begin_layout Standard
5360 The preprocessor
5361 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
5362
5363 \end_inset
5364
5365  is a modified version of the GNU cpp
5366 \begin_inset LatexCommand \index{cpp|see{sdcpp}}
5367
5368 \end_inset
5369
5370  preprocessor
5371 \begin_inset LatexCommand \url{http://gcc.gnu.org/}
5372
5373 \end_inset
5374
5375 .
5376  The C preprocessor is used to pull in #include sources, process #ifdef
5377  statements, #defines and so on.
5378 \end_layout
5379
5380 \begin_layout Subsection
5381 as
5382 \emph on
5383 xxxx
5384 \emph default
5385 , aslink, link-
5386 \emph on
5387 xxx
5388 \emph default
5389  - The Assemblers and Linkage Editors
5390 \end_layout
5391
5392 \begin_layout Standard
5393 This is retargettable assembler & linkage editor, it was developed by Alan
5394  Baldwin.
5395  John Hartman created the version for 8051, and I (Sandeep) have made some
5396  enhancements and bug fixes for it to work properly with SDCC.
5397 \end_layout
5398
5399 \begin_layout Subsection
5400 s51 - The Simulator
5401 \end_layout
5402
5403 \begin_layout Standard
5404 S51
5405 \begin_inset LatexCommand \index{s51}
5406
5407 \end_inset
5408
5409  is a free open source simulator developed by Daniel Drotos.
5410  The simulator is built as part of the build process.
5411  For more information visit Daniel's web site at:
5412 \begin_inset LatexCommand \url{http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51}
5413
5414 \end_inset
5415
5416 .
5417  It currently supports the core mcs51, the Dallas DS80C390 and the Phillips
5418  XA51 family.
5419 \end_layout
5420
5421 \begin_layout Subsection
5422 sdcdb - Source Level Debugger
5423 \end_layout
5424
5425 \begin_layout Standard
5426 SDCDB
5427 \begin_inset LatexCommand \index{SDCDB (debugger)}
5428
5429 \end_inset
5430
5431  is the companion source level debugger.
5432  More about SDCDB in section
5433 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
5434
5435 \end_inset
5436
5437 .
5438  The current version of the debugger uses Daniel's Simulator S51
5439 \begin_inset LatexCommand \index{s51}
5440
5441 \end_inset
5442
5443 , but can be easily changed to use other simulators.
5444 \end_layout
5445
5446 \begin_layout Chapter
5447 Using SDCC
5448 \end_layout
5449
5450 \begin_layout Section
5451 Compiling
5452 \end_layout
5453
5454 \begin_layout Subsection
5455 Single Source File Projects
5456 \end_layout
5457
5458 \begin_layout Standard
5459 For single source file 8051 projects the process is very simple.
5460  Compile your programs with the following command
5461 \family sans
5462 \series bold
5463 "sdcc sourcefile.c".
5464
5465 \family default
5466 \series default
5467  This will compile, assemble and link your source file.
5468  Output files are as follows:
5469 \end_layout
5470
5471 \begin_layout Itemize
5472 sourcefile.asm
5473 \begin_inset LatexCommand \index{<file>.asm}
5474
5475 \end_inset
5476
5477  - Assembler source
5478 \begin_inset LatexCommand \index{Assembler source}
5479
5480 \end_inset
5481
5482  file created by the compiler
5483 \end_layout
5484
5485 \begin_layout Itemize
5486 sourcefile.lst
5487 \begin_inset LatexCommand \index{<file>.lst}
5488
5489 \end_inset
5490
5491  - Assembler listing
5492 \begin_inset LatexCommand \index{Assembler listing}
5493
5494 \end_inset
5495
5496  file created by the Assembler
5497 \end_layout
5498
5499 \begin_layout Itemize
5500 sourcefile.rst
5501 \begin_inset LatexCommand \index{<file>.rst}
5502
5503 \end_inset
5504
5505  - Assembler listing
5506 \begin_inset LatexCommand \index{Assembler listing}
5507
5508 \end_inset
5509
5510  file updated with linkedit information, created by linkage editor
5511 \end_layout
5512
5513 \begin_layout Itemize
5514 sourcefile.sym
5515 \begin_inset LatexCommand \index{<file>.sym}
5516
5517 \end_inset
5518
5519  - symbol listing
5520 \begin_inset LatexCommand \index{Symbol listing}
5521
5522 \end_inset
5523
5524  for the sourcefile, created by the assembler
5525 \end_layout
5526
5527 \begin_layout Itemize
5528 sourcefile.rel
5529 \begin_inset LatexCommand \index{<file>.rel}
5530
5531 \end_inset
5532
5533  or sourcefile.o
5534 \begin_inset LatexCommand \index{<file>.o}
5535
5536 \end_inset
5537
5538  - Object file
5539 \begin_inset LatexCommand \index{Object file}
5540
5541 \end_inset
5542
5543  created by the assembler, input to Linkage editor
5544 \end_layout
5545
5546 \begin_layout Itemize
5547 sourcefile.map
5548 \begin_inset LatexCommand \index{<file>.map}
5549
5550 \end_inset
5551
5552  - The memory map
5553 \begin_inset LatexCommand \index{Memory map}
5554
5555 \end_inset
5556
5557  for the load module, created by the Linker
5558 \end_layout
5559
5560 \begin_layout Itemize
5561 sourcefile.mem
5562 \begin_inset LatexCommand \index{<file>.mem}
5563
5564 \end_inset
5565
5566  - A file with a summary of the memory usage
5567 \end_layout
5568
5569 \begin_layout Itemize
5570 sourcefile.ihx
5571 \begin_inset LatexCommand \index{<file>.ihx}
5572
5573 \end_inset
5574
5575  - The load module in Intel hex format
5576 \begin_inset LatexCommand \index{Intel hex format}
5577
5578 \end_inset
5579
5580  (you can select the Motorola S19 format
5581 \begin_inset LatexCommand \index{Motorola S19 format}
5582
5583 \end_inset
5584
5585  with -
5586 \begin_inset ERT
5587 status collapsed
5588
5589 \begin_layout Standard
5590
5591
5592 \backslash
5593 /
5594 \end_layout
5595
5596 \end_inset
5597
5598 -out-fmt-s19
5599 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
5600
5601 \end_inset
5602
5603 .
5604  If you need another format you might want to use
5605 \family sans
5606 \shape italic
5607 objdump
5608 \family default
5609 \shape default
5610
5611 \begin_inset LatexCommand \index{objdump (tool)}
5612
5613 \end_inset
5614
5615  or
5616 \family sans
5617 \shape italic
5618  srecord
5619 \family default
5620 \shape default
5621
5622 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5623
5624 \end_inset
5625
5626
5627 \begin_inset Note Note
5628 status collapsed
5629
5630 \begin_layout Standard
5631 hyperlinks needed
5632 \end_layout
5633
5634 \end_inset
5635
5636  - see also section
5637 \begin_inset LatexCommand \vref{sub:Postprocessing-the-Intel}
5638
5639 \end_inset
5640
5641 ).
5642  Both formats are documented in the documentation of srecord
5643 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5644
5645 \end_inset
5646
5647
5648 \end_layout
5649
5650 \begin_layout Itemize
5651 sourcefile.adb
5652 \begin_inset LatexCommand \index{<file>.adb}
5653
5654 \end_inset
5655
5656  - An intermediate file containing debug information needed to create the
5657  .cdb file (with -
5658 \begin_inset ERT
5659 status collapsed
5660
5661 \begin_layout Standard
5662
5663
5664 \backslash
5665 /
5666 \end_layout
5667
5668 \end_inset
5669
5670 -debug
5671 \begin_inset LatexCommand \index{-\/-debug}
5672
5673 \end_inset
5674
5675 )
5676 \end_layout
5677
5678 \begin_layout Itemize
5679 sourcefile.cdb
5680 \begin_inset LatexCommand \index{<file>.cdb}
5681
5682 \end_inset
5683
5684  - An optional file (with -
5685 \begin_inset ERT
5686 status collapsed
5687
5688 \begin_layout Standard
5689
5690
5691 \backslash
5692 /
5693 \end_layout
5694
5695 \end_inset
5696
5697 -debug) containing debug information.
5698  The format is documented in cdbfileformat.pdf
5699 \end_layout
5700
5701 \begin_layout Itemize
5702 sourcefile.
5703  - (no extension)
5704 \begin_inset LatexCommand \index{<file> (no extension)}
5705
5706 \end_inset
5707
5708  An optional AOMF or AOMF51
5709 \begin_inset LatexCommand \index{AOMF, AOMF51}
5710
5711 \end_inset
5712
5713
5714 \begin_inset LatexCommand \label{OMF file}
5715
5716 \end_inset
5717
5718 file containing debug information (generated with option -
5719 \begin_inset ERT
5720 status collapsed
5721
5722 \begin_layout Standard
5723
5724
5725 \backslash
5726 /
5727 \end_layout
5728
5729 \end_inset
5730
5731 -debug).
5732  The (Intel)
5733 \emph on
5734  a
5735 \emph default
5736 bsolute
5737 \emph on
5738 o
5739 \emph default
5740 bject
5741 \emph on
5742 m
5743 \emph default
5744 odule
5745 \emph on
5746 f
5747 \emph default
5748 ormat is a subformat of the OMF51 format and is commonly used by third party
5749  tools (debuggers
5750 \begin_inset LatexCommand \index{Debugger}
5751
5752 \end_inset
5753
5754 , simulators, emulators).
5755 \end_layout
5756
5757 \begin_layout Itemize
5758 sourcefile.dump*
5759 \begin_inset LatexCommand \index{<file>.dump*}
5760
5761 \end_inset
5762
5763  - Dump file to debug the compiler it self (generated with option -
5764 \begin_inset ERT
5765 status collapsed
5766
5767 \begin_layout Standard
5768
5769
5770 \backslash
5771 /
5772 \end_layout
5773
5774 \end_inset
5775
5776 -dumpall) (see section
5777 \begin_inset LatexCommand \ref{sub:Intermediate-Dump-Options}
5778
5779 \end_inset
5780
5781 \InsetSpace ~
5782  and section
5783 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
5784
5785 \end_inset
5786
5787 \InsetSpace ~
5788
5789 \begin_inset Quotes sld
5790 \end_inset
5791
5792 Anatomy of the compiler
5793 \begin_inset Quotes srd
5794 \end_inset
5795
5796 ).
5797 \end_layout
5798
5799 \begin_layout Subsection
5800 Postprocessing the Intel Hex
5801 \begin_inset LatexCommand \index{Intel hex format}
5802
5803 \end_inset
5804
5805  file
5806 \begin_inset LatexCommand \label{sub:Postprocessing-the-Intel}
5807
5808 \end_inset
5809
5810
5811 \end_layout
5812
5813 \begin_layout Standard
5814 In most cases this won't be needed but the Intel Hex file
5815 \begin_inset LatexCommand \index{<file>.ihx}
5816
5817 \end_inset
5818
5819  which is generated by SDCC might include lines of varying length and the
5820  addresses within the file are not guaranteed to be strictly ascending.
5821  If your toolchain or a bootloader does not like this you can use the tool
5822 \family typewriter
5823 packihx
5824 \family default
5825
5826 \begin_inset LatexCommand \index{packihx (tool)}
5827
5828 \end_inset
5829
5830  which is part of the SDCC distribution:
5831 \newline
5832
5833 \newline
5834
5835 \family sans
5836 \series bold
5837  packihx sourcefile.ihx >sourcefile.hex
5838 \family default
5839 \series default
5840
5841 \newline
5842
5843 \newline
5844 The separately available
5845 \emph on
5846  srecord
5847 \emph default
5848
5849 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5850
5851 \end_inset
5852
5853  package additionally allows to set undefined locations to a predefined
5854  value, to insert checksums
5855 \begin_inset LatexCommand \index{checksum}
5856
5857 \end_inset
5858
5859  of various flavours (crc, add, xor) and to perform other manipulations
5860  (convert, split, crop, offset, ...).
5861 \newline
5862
5863 \newline
5864
5865 \family sans
5866 \series bold
5867 srec_cat\InsetSpace ~
5868 \InsetSpace ~
5869 sourcefile.ihx -intel\InsetSpace ~
5870 \InsetSpace ~
5871 -o sourcefile.hex -intel
5872 \newline
5873
5874 \newline
5875
5876 \family default
5877 \series default
5878 An example for a more complex command line
5879 \begin_inset Foot
5880 status open
5881
5882 \begin_layout Standard
5883 the command backfills
5884 \begin_inset LatexCommand \index{backfill unused memory}
5885
5886 \end_inset
5887
5888  unused memory with 0x12 and the overall 16 bit sum of the complete 64 kByte
5889  block is zero.
5890  If the program counter on an mcs51 runs wild the backfill pattern 0x12
5891  will be interpreted as an
5892 \family typewriter
5893 lcall
5894 \family default
5895  to address
5896 \family typewriter
5897 0x1212
5898 \family default
5899  (where an emergency routine could sit).
5900 \end_layout
5901
5902 \end_inset
5903
5904  could look like:
5905 \newline
5906
5907 \newline
5908
5909 \family sans
5910 \series bold
5911 \size footnotesize
5912 srec_cat\InsetSpace ~
5913 sourcefile.ihx -intel\InsetSpace ~
5914 \InsetSpace ~
5915 -fill 0x12 0x0000 0xfffe\InsetSpace ~
5916 -little-endian-checksum-nega
5917 tive 0xfffe 0x02 0x02\InsetSpace ~
5918 \InsetSpace ~
5919 -o sourcefile.hex -intel
5920 \size default
5921
5922 \newline
5923
5924 \newline
5925
5926 \family default
5927 \series default
5928 The srecord package is available at
5929 \begin_inset LatexCommand \url{http://sf.net/projects/srecord}
5930
5931 \end_inset
5932
5933  .
5934 \end_layout
5935
5936 \begin_layout Subsection
5937 Projects with Multiple Source Files
5938 \end_layout
5939
5940 \begin_layout Standard
5941 SDCC can compile only ONE file at a time.
5942  Let us for example assume that you have a project containing the following
5943  files:
5944 \newline
5945
5946 \newline
5947 foo1.c (contains some functions)
5948 \newline
5949 foo2.c (contains some more functions)
5950 \newline
5951 foomai
5952 n.c (contains more functions and the function main)
5953 \newline
5954
5955 \size footnotesize
5956
5957 \newline
5958
5959 \size default
5960 The first two files will need to be compiled separately with the commands:
5961 \newline
5962
5963 \newline
5964
5965 \family sans
5966 \series bold
5967 sdcc\InsetSpace ~
5968 -c\InsetSpace ~
5969 foo1.c
5970 \family default
5971 \series default
5972 \size footnotesize
5973
5974 \newline
5975
5976 \family sans
5977 \series bold
5978 \size default
5979 sdcc\InsetSpace ~
5980 -c\InsetSpace ~
5981 foo2.c
5982 \family default
5983 \series default
5984
5985 \newline
5986
5987 \newline
5988 Then compile the source file containing the
5989 \emph on
5990 main()
5991 \emph default
5992  function and link
5993 \begin_inset LatexCommand \index{Linker}
5994
5995 \end_inset
5996
5997  the files together with the following command:
5998 \newline
5999
6000 \newline
6001
6002 \family sans
6003 \series bold
6004 sdcc\InsetSpace ~
6005 foomain.c\InsetSpace ~
6006 foo1.rel\InsetSpace ~
6007 foo2.rel
6008 \family default
6009 \series default
6010
6011 \begin_inset LatexCommand \index{<file>.rel}
6012
6013 \end_inset
6014
6015
6016 \newline
6017
6018 \newline
6019 Alternatively,
6020 \emph on
6021 foomain.c
6022 \emph default
6023 can be separately compiled as well:
6024 \family sans
6025 \series bold
6026
6027 \newline
6028
6029 \newline
6030 sdcc\InsetSpace ~
6031 -c\InsetSpace ~
6032 foomain.c
6033 \newline
6034 sdcc foomain.rel foo1.rel foo2.rel
6035 \newline
6036
6037 \newline
6038
6039 \family default
6040 \series default
6041 The file containing the
6042 \emph on
6043 main()
6044 \emph default
6045  function
6046 \noun on
6047 must
6048 \noun default
6049  be the
6050 \noun on
6051 first
6052 \noun default
6053  file specified in the command line, since the linkage editor processes
6054  file in the order they are presented to it.
6055  The linker is invoked from SDCC using a script file with extension .lnk
6056 \begin_inset LatexCommand \index{<file>.lnk}
6057
6058 \end_inset
6059
6060 .
6061  You can view this file to troubleshoot linking problems such as those arising
6062  from missing libraries.
6063 \end_layout
6064
6065 \begin_layout Subsection
6066 Projects with Additional Libraries
6067 \begin_inset LatexCommand \index{Libraries}
6068
6069 \end_inset
6070
6071
6072 \end_layout
6073
6074 \begin_layout Standard
6075 Some reusable routines may be compiled into a library, see the documentation
6076  for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc)
6077  for how to create a
6078 \emph on
6079 .lib
6080 \begin_inset LatexCommand \index{<file>.lib}
6081
6082 \end_inset
6083
6084
6085 \emph default
6086  library file.
6087  Libraries created in this manner can be included in the command line.
6088  Make sure you include the -L <library-path> option to tell the linker where
6089  to look for these files if they are not in the current directory.
6090  Here is an example, assuming you have the source file
6091 \emph on
6092 foomain.c
6093 \emph default
6094  and a library
6095 \emph on
6096  foolib.lib
6097 \emph default
6098  in the directory
6099 \emph on
6100 mylib
6101 \emph default
6102  (if that is not the same as your current project):
6103 \newline
6104
6105 \newline
6106
6107 \family sans
6108 \series bold
6109 sdcc foomain.c foolib.lib -L mylib
6110 \newline
6111
6112 \newline
6113
6114 \family default
6115 \series default
6116 Note here that
6117 \emph on
6118  mylib
6119 \emph default
6120  must be an absolute path name.
6121 \newline
6122
6123 \newline
6124 The most efficient way to use libraries is
6125  to keep separate modules in separate source files.
6126  The lib file now should name all the modules.rel
6127 \begin_inset LatexCommand \index{<file>.rel}
6128
6129 \end_inset
6130
6131  files.
6132  For an example see the standard library file
6133 \emph on
6134 libsdcc.lib
6135 \emph default
6136  in the directory <installdir>/share/lib/small.
6137 \end_layout
6138
6139 \begin_layout Subsection
6140 Using sdcclib to Create and Manage Libraries
6141 \begin_inset LatexCommand \index{sdcclib}
6142
6143 \end_inset
6144
6145
6146 \end_layout
6147
6148 \begin_layout Standard
6149 Alternatively, instead of having a .rel file for each entry on the library
6150  file as described in the preceding section, sdcclib can be used to embed
6151  all the modules belonging to such library in the library file itself.
6152  This results in a larger library file, but it greatly reduces the number
6153  of disk files accessed by the linker.
6154   Additionally, the packed library file contains an index of all include
6155  modules and symbols that significantly speeds up the linking process.
6156  To display a list of options supported by sdcclib type:
6157 \newline
6158
6159 \end_layout
6160
6161 \begin_layout Standard
6162
6163 \family sans
6164 \series bold
6165 sdcclib -?
6166 \begin_inset LatexCommand \index{sdcclib}
6167
6168 \end_inset
6169
6170
6171 \newline
6172
6173 \newline
6174
6175 \family default
6176 \series default
6177 To create a new library file, start by compiling all the required modules.
6178  For example:
6179 \newline
6180
6181 \end_layout
6182
6183 \begin_layout Standard
6184
6185 \family sans
6186 \series bold
6187 sdcc -c _divsint.c
6188 \end_layout
6189
6190 \begin_layout Standard
6191
6192 \family sans
6193 \series bold
6194 sdcc -c _divuint.c
6195 \end_layout
6196
6197 \begin_layout Standard
6198
6199 \family sans
6200 \series bold
6201 sdcc -c _modsint.c
6202 \end_layout
6203
6204 \begin_layout Standard
6205
6206 \family sans
6207 \series bold
6208 sdcc -c _moduint.c
6209 \end_layout
6210
6211 \begin_layout Standard
6212
6213 \family sans
6214 \series bold
6215 sdcc -c _mulint.c
6216 \newline
6217
6218 \end_layout
6219
6220 \begin_layout Standard
6221 This will create files _divsint.rel, _divuint.rel, _modsint.rel, _moduint.rel,
6222  and _mulint.rel.
6223  The next step is to add the .rel files to the library file:
6224 \newline
6225
6226 \end_layout
6227
6228 \begin_layout Standard
6229
6230 \family sans
6231 \series bold
6232 sdcclib libint.lib _divsint.rel
6233 \family default
6234
6235 \begin_inset LatexCommand \index{sdcclib}
6236
6237 \end_inset
6238
6239
6240 \end_layout
6241
6242 \begin_layout Standard
6243
6244 \family sans
6245 \series bold
6246 sdcclib libint.lib _divuint.rel
6247 \end_layout
6248
6249 \begin_layout Standard
6250
6251 \family sans
6252 \series bold
6253 sdcclib libint.lib _modsint.rel
6254 \end_layout
6255
6256 \begin_layout Standard
6257
6258 \family sans
6259 \series bold
6260 sdcclib libint.lib _moduint.rel
6261 \end_layout
6262
6263 \begin_layout Standard
6264
6265 \family sans
6266 \series bold
6267 sdcclib libint.lib _mulint.rel
6268 \family default
6269 \series default
6270
6271 \newline
6272
6273 \end_layout
6274
6275 \begin_layout Standard
6276 Or, if you preffer:
6277 \family sans
6278 \series bold
6279
6280 \newline
6281
6282 \end_layout
6283
6284 \begin_layout Standard
6285
6286 \family sans
6287 \series bold
6288 sdcclib libint.lib _divsint.rel _divuint.rel _modsint.rel _moduint.rel _mulint.rel
6289 \family default
6290 \series default
6291
6292 \newline
6293
6294 \end_layout
6295
6296 \begin_layout Standard
6297 If the file already exists in the library, it will be replaced.
6298  If a list of .rel files is available, you can tell sdcclib to add those
6299  files to a library.
6300  For example, if the file 'myliblist.txt' contains
6301 \family sans
6302 \series bold
6303
6304 \newline
6305
6306 \end_layout
6307
6308 \begin_layout Standard
6309
6310 \family sans
6311 \series bold
6312 _divsint.rel
6313 \end_layout
6314
6315 \begin_layout Standard
6316
6317 \family sans
6318 \series bold
6319 _divuint.rel
6320 \end_layout
6321
6322 \begin_layout Standard
6323
6324 \family sans
6325 \series bold
6326 _modsint.rel
6327 \end_layout
6328
6329 \begin_layout Standard
6330
6331 \family sans
6332 \series bold
6333 _moduint.rel
6334 \end_layout
6335
6336 \begin_layout Standard
6337
6338 \family sans
6339 \series bold
6340 _mulint.rel
6341 \family default
6342 \series default
6343
6344 \newline
6345
6346 \end_layout
6347
6348 \begin_layout Standard
6349 Use
6350 \family sans
6351 \series bold
6352
6353 \newline
6354
6355 \end_layout
6356
6357 \begin_layout Standard
6358
6359 \family sans
6360 \series bold
6361 sdcclib -l libint.lib myliblist.txt
6362 \family default
6363 \series default
6364
6365 \newline
6366
6367 \end_layout
6368
6369 \begin_layout Standard
6370 Additionally, you can instruct sdcclib to compiles the files before adding
6371  them to the library.
6372  This is achieved using the environment variables SDCCLIB_CC and/or SDCCLIB_AS.
6373  For example:
6374 \family sans
6375 \series bold
6376
6377 \newline
6378
6379 \end_layout
6380
6381 \begin_layout Standard
6382
6383 \family sans
6384 \series bold
6385 set SDCCLIB_CC=sdcc -c
6386 \end_layout
6387
6388 \begin_layout Standard
6389
6390 \family sans
6391 \series bold
6392 sdcclib -l libint.lib myliblist.txt
6393 \family default
6394 \series default
6395
6396 \newline
6397
6398 \end_layout
6399
6400 \begin_layout Standard
6401 To see what modules and symbols are included in the library, options -s
6402  and -m are available.
6403  For example:
6404 \newline
6405
6406 \newline
6407
6408 \family sans
6409 \series bold
6410 sdcclib -s libint.lib
6411 \family default
6412
6413 \begin_inset LatexCommand \index{sdcclib}
6414
6415 \end_inset
6416
6417
6418 \newline
6419
6420 \family typewriter
6421 \series default
6422 _divsint.rel:
6423 \end_layout
6424
6425 \begin_layout Standard
6426
6427 \family typewriter
6428 __divsint_a_1_1
6429 \end_layout
6430
6431 \begin_layout Standard
6432
6433 \family typewriter
6434 __divsint_PARM_2
6435 \end_layout
6436
6437 \begin_layout Standard
6438
6439 \family typewriter
6440 __divsint
6441 \newline
6442 _divuint.rel:
6443 \end_layout
6444
6445 \begin_layout Standard
6446
6447 \family typewriter
6448 __divuint_a_1_1
6449 \end_layout
6450
6451 \begin_layout Standard
6452
6453 \family typewriter
6454 __divuint_PARM_2
6455 \end_layout
6456
6457 \begin_layout Standard
6458
6459 \family typewriter
6460 __divuint_reste_1_1
6461 \end_layout
6462
6463 \begin_layout Standard
6464
6465 \family typewriter
6466 __divuint_count_1_1
6467 \end_layout
6468
6469 \begin_layout Standard
6470
6471 \family typewriter
6472 __divuint
6473 \newline
6474 _modsint.rel:
6475 \end_layout
6476
6477 \begin_layout Standard
6478
6479 \family typewriter
6480 __modsint_a_1_1
6481 \end_layout
6482
6483 \begin_layout Standard
6484
6485 \family typewriter
6486 __modsint_PARM_2
6487 \end_layout
6488
6489 \begin_layout Standard
6490
6491 \family typewriter
6492 __modsint
6493 \newline
6494 _moduint.rel:
6495 \end_layout
6496
6497 \begin_layout Standard
6498
6499 \family typewriter
6500 __moduint_a_1_1
6501 \end_layout
6502
6503 \begin_layout Standard
6504
6505 \family typewriter
6506 __moduint_PARM_2
6507 \end_layout
6508
6509 \begin_layout Standard
6510
6511 \family typewriter
6512 __moduint_count_1_1
6513 \end_layout
6514
6515 \begin_layout Standard
6516
6517 \family typewriter
6518 __moduint
6519 \newline
6520 _mulint.rel:
6521 \end_layout
6522
6523 \begin_layout Standard
6524
6525 \family typewriter
6526 __mulint_PARM_2
6527 \end_layout
6528
6529 \begin_layout Standard
6530
6531 \family typewriter
6532 __mulint
6533 \family default
6534 \series bold
6535
6536 \newline
6537
6538 \end_layout
6539
6540 \begin_layout Standard
6541 If the source files are compiled using -
6542 \begin_inset ERT
6543 status collapsed
6544
6545 \begin_layout Standard
6546
6547
6548 \backslash
6549 /
6550 \end_layout
6551
6552 \end_inset
6553
6554 -debug
6555 \begin_inset LatexCommand \index{-\/-debug}
6556
6557 \end_inset
6558
6559 , the corresponding debug information file .adb will be include in the library
6560  file as well.
6561  The library files created with sdcclib are plain text files, so they can
6562  be viewed with a text editor.
6563  It is not recomended to modify a library file created with sdcclib using
6564  a text editor, as there are file indexes numbers located accross the file
6565  used by the linker to quickly locate the required module to link.
6566  Once a .rel file (as well as a .adb file) is added to a library using sdcclib,
6567  it can be safely deleted, since all the information required for linking
6568  is embedded in the library file itself.
6569  Library files created using sdcclib are used as described in the preceding
6570  sections.
6571 \begin_inset VSpace bigskip
6572 \end_inset
6573
6574
6575 \end_layout
6576
6577 \begin_layout Section
6578 Command Line Options
6579 \begin_inset LatexCommand \index{Command Line Options}
6580
6581 \end_inset
6582
6583
6584 \begin_inset LatexCommand \label{sec:Command-Line-Options}
6585
6586 \end_inset
6587
6588
6589 \end_layout
6590
6591 \begin_layout Subsection
6592 Processor Selection Options
6593 \begin_inset LatexCommand \index{Options processor selection}
6594
6595 \end_inset
6596
6597
6598 \begin_inset LatexCommand \index{Processor selection options}
6599
6600 \end_inset
6601
6602
6603 \end_layout
6604
6605 \begin_layout List
6606 \labelwidthstring 00.00.0000
6607
6608 \series bold
6609 -mmcs51
6610 \begin_inset LatexCommand \index{-mmcs51}
6611
6612 \end_inset
6613
6614
6615 \series default
6616  Generate code for the Intel MCS51
6617 \begin_inset LatexCommand \index{MCS51}
6618
6619 \end_inset
6620
6621  family of processors.
6622  This is the default processor target.
6623 \end_layout
6624
6625 \begin_layout List
6626 \labelwidthstring 00.00.0000
6627
6628 \series bold
6629 -mds390
6630 \begin_inset LatexCommand \index{-mds390}
6631
6632 \end_inset
6633
6634
6635 \series default
6636  Generate code for the Dallas DS80C390
6637 \begin_inset LatexCommand \index{DS80C390}
6638
6639 \end_inset
6640
6641  processor.
6642 \end_layout
6643
6644 \begin_layout List
6645 \labelwidthstring 00.00.0000
6646
6647 \series bold
6648 -mds400
6649 \begin_inset LatexCommand \index{-mds400}
6650
6651 \end_inset
6652
6653
6654 \series default
6655  Generate code for the Dallas DS80C400
6656 \begin_inset LatexCommand \index{DS80C400}
6657
6658 \end_inset
6659
6660  processor.
6661 \end_layout
6662
6663 \begin_layout List
6664 \labelwidthstring 00.00.0000
6665
6666 \series bold
6667 -mhc08
6668 \begin_inset LatexCommand \index{-mhc08}
6669
6670 \end_inset
6671
6672
6673 \series default
6674  Generate code for the Freescale/Motorola HC08
6675 \begin_inset LatexCommand \index{HC08}
6676
6677 \end_inset
6678
6679  family of processors.
6680 \end_layout
6681
6682 \begin_layout List
6683 \labelwidthstring 00.00.0000
6684
6685 \series bold
6686 -mz80
6687 \begin_inset LatexCommand \index{-mz80}
6688
6689 \end_inset
6690
6691
6692 \series default
6693  Generate code for the Zilog Z80
6694 \begin_inset LatexCommand \index{Z80}
6695
6696 \end_inset
6697
6698  family of processors.
6699 \end_layout
6700
6701 \begin_layout List
6702 \labelwidthstring 00.00.0000
6703
6704 \series bold
6705 -mgbz80
6706 \begin_inset LatexCommand \index{-mgbz80}
6707
6708 \end_inset
6709
6710
6711 \series default
6712  Generate code for the GameBoy Z80
6713 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
6714
6715 \end_inset
6716
6717  processor (Not actively maintained).
6718 \end_layout
6719
6720 \begin_layout List
6721 \labelwidthstring 00.00.0000
6722
6723 \series bold
6724 -mavr
6725 \begin_inset LatexCommand \index{-mavr}
6726
6727 \end_inset
6728
6729
6730 \series default
6731  Generate code for the Atmel AVR
6732 \begin_inset LatexCommand \index{AVR}
6733
6734 \end_inset
6735
6736  processor (Not maintained, not complete).
6737  AVR users should probably have a look at winavr
6738 \begin_inset LatexCommand \url{http://sourceforge.net/projects/winavr}
6739
6740 \end_inset
6741
6742  or
6743 \begin_inset LatexCommand \url{http://www.avrfreaks.net/index.php?name=PNphpBB2&file=index}
6744
6745 \end_inset
6746
6747 , which is based on AVR-port of the gcc compiler.
6748 \end_layout
6749
6750 \begin_layout Standard
6751 \begin_inset Note Note
6752 status collapsed
6753
6754 \begin_layout Standard
6755 I think it is fair to direct users there for now.
6756  Open source is also about avoiding unnecessary work .
6757  But I didn't find the 'official' link.
6758 \end_layout
6759
6760 \end_inset
6761
6762
6763 \end_layout
6764
6765 \begin_layout List
6766 \labelwidthstring 00.00.0000
6767
6768 \series bold
6769 -mpic14
6770 \begin_inset LatexCommand \index{-mpic14}
6771
6772 \end_inset
6773
6774
6775 \series default
6776  Generate code for the Microchip PIC 14
6777 \begin_inset LatexCommand \index{PIC14}
6778
6779 \end_inset
6780
6781 -bit processors (p16f84 and variants.
6782  In development, not complete).
6783 \end_layout
6784
6785 \begin_layout Standard
6786 \begin_inset Note Note
6787 status collapsed
6788
6789 \begin_layout Standard
6790 p16f627 p16f628 p16f84 p16f873 p16f877?
6791 \end_layout
6792
6793 \end_inset
6794
6795
6796 \end_layout
6797
6798 \begin_layout List
6799 \labelwidthstring 00.00.0000
6800
6801 \series bold
6802 -mpic16
6803 \begin_inset LatexCommand \index{-mpic16}
6804
6805 \end_inset
6806
6807
6808 \series default
6809  Generate code for the Microchip PIC 16
6810 \begin_inset LatexCommand \index{PIC16}
6811
6812 \end_inset
6813
6814 -bit processors (p18f452 and variants.
6815  In development, not complete).
6816 \end_layout
6817
6818 \begin_layout List
6819 \labelwidthstring 00.00.0000
6820
6821 \series bold
6822 -mtlcs900h
6823 \series default
6824  Generate code for the Toshiba TLCS-900H
6825 \begin_inset LatexCommand \index{TLCS-900H}
6826
6827 \end_inset
6828
6829  processor (Not maintained, not complete).
6830 \end_layout
6831
6832 \begin_layout List
6833 \labelwidthstring 00.00.0000
6834
6835 \series bold
6836 -mxa51
6837 \begin_inset LatexCommand \index{-mxa51}
6838
6839 \end_inset
6840
6841
6842 \series default
6843  Generate code for the Phillips XA51
6844 \begin_inset LatexCommand \index{XA51}
6845
6846 \end_inset
6847
6848  processor (Not maintained, not complete).
6849 \end_layout
6850
6851 \begin_layout Standard
6852 \begin_inset VSpace bigskip
6853 \end_inset
6854
6855
6856 \end_layout
6857
6858 \begin_layout Subsection
6859 Preprocessor Options
6860 \begin_inset LatexCommand \index{Options preprocessor}
6861
6862 \end_inset
6863
6864
6865 \begin_inset LatexCommand \index{Preprocessor options}
6866
6867 \end_inset
6868
6869
6870 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
6871
6872 \end_inset
6873
6874
6875 \end_layout
6876
6877 \begin_layout List
6878 \labelwidthstring 00.00.0000
6879
6880 \series bold
6881 -I<path>
6882 \begin_inset LatexCommand \index{-I<path>}
6883
6884 \end_inset
6885
6886
6887 \series default
6888  The additional location where the preprocessor will look for <..h> or
6889 \begin_inset Quotes eld
6890 \end_inset
6891
6892 ..h
6893 \begin_inset Quotes erd
6894 \end_inset
6895
6896  files.
6897 \end_layout
6898
6899 \begin_layout List
6900 \labelwidthstring 00.00.0000
6901
6902 \series bold
6903 -D<macro[=value]>
6904 \begin_inset LatexCommand \index{-D<macro[=value]>}
6905
6906 \end_inset
6907
6908
6909 \series default
6910  Command line definition of macros.
6911  Passed to the preprocessor.
6912 \end_layout
6913
6914 \begin_layout List
6915 \labelwidthstring 00.00.0000
6916
6917 \series bold
6918 -M
6919 \begin_inset LatexCommand \index{-M}
6920
6921 \end_inset
6922
6923
6924 \series default
6925  Tell the preprocessor to output a rule suitable for make describing the
6926  dependencies of each object file.
6927  For each source file, the preprocessor outputs one make-rule whose target
6928  is the object file name for that source file and whose dependencies are
6929  all the files `#include'd in it.
6930  This rule may be a single line or may be continued with `
6931 \backslash
6932 '-newline if it is long.
6933  The list of rules is printed on standard output instead of the preprocessed
6934  C program.
6935  `-M' implies `-E
6936 \begin_inset LatexCommand \index{-E}
6937
6938 \end_inset
6939
6940 '.
6941 \end_layout
6942
6943 \begin_layout List
6944 \labelwidthstring 00.00.0000
6945
6946 \series bold
6947 -C
6948 \begin_inset LatexCommand \index{-C}
6949
6950 \end_inset
6951
6952
6953 \series default
6954  Tell the preprocessor not to discard comments.
6955  Used with the `-E' option.
6956 \end_layout
6957
6958 \begin_layout List
6959 \labelwidthstring 00.00.0000
6960
6961 \series bold
6962 -MM
6963 \begin_inset LatexCommand \index{-MM}
6964
6965 \end_inset
6966
6967
6968 \series default
6969 Like `-M' but the output mentions only the user header files included with
6970  `#include
6971 \begin_inset Quotes eld
6972 \end_inset
6973
6974 file"'.
6975  System header files included with `#include <file>' are omitted.
6976 \end_layout
6977
6978 \begin_layout List
6979 \labelwidthstring 00.00.0000
6980
6981 \series bold
6982 -Aquestion(answer)
6983 \begin_inset LatexCommand \index{-Aquestion(answer)}
6984
6985 \end_inset
6986
6987
6988 \series default
6989  Assert the answer answer for question, in case it is tested with a preprocessor
6990  conditional such as `#if #question(answer)'.
6991  `-A-' disables the standard assertions that normally describe the target
6992  machine.
6993 \end_layout
6994
6995 \begin_layout List
6996 \labelwidthstring 00.00.0000
6997
6998 \series bold
6999 -Umacro
7000 \begin_inset LatexCommand \index{-Umacro}
7001
7002 \end_inset
7003
7004
7005 \series default
7006  Undefine macro macro.
7007  `-U' options are evaluated after all `-D' options, but before any `-include'
7008  and `-imacros' options.
7009 \end_layout
7010
7011 \begin_layout List
7012 \labelwidthstring 00.00.0000
7013
7014 \series bold
7015 -dM
7016 \begin_inset LatexCommand \index{-dM}
7017
7018 \end_inset
7019
7020
7021 \series default
7022  Tell the preprocessor to output only a list of the macro definitions that
7023  are in effect at the end of preprocessing.
7024  Used with the `-E' option.
7025 \end_layout
7026
7027 \begin_layout List
7028 \labelwidthstring 00.00.0000
7029
7030 \series bold
7031 -dD
7032 \begin_inset LatexCommand \index{-dD}
7033
7034 \end_inset
7035
7036
7037 \series default
7038  Tell the preprocessor to pass all macro definitions into the output, in
7039  their proper sequence in the rest of the output.
7040 \end_layout
7041
7042 \begin_layout List
7043 \labelwidthstring 00.00.0000
7044
7045 \series bold
7046 -dN
7047 \begin_inset LatexCommand \index{-dN}
7048
7049 \end_inset
7050
7051
7052 \series default
7053 Like `-dD' except that the macro arguments and contents are omitted.
7054  Only `#define name' is included in the output.
7055 \end_layout
7056
7057 \begin_layout List
7058 \labelwidthstring 00.00.0000
7059
7060 \series bold
7061 -pedantic-parse-number
7062 \begin_inset LatexCommand \index{pedantic}
7063
7064 \end_inset
7065
7066
7067 \begin_inset LatexCommand \index{-pedantic-parse-number}
7068
7069 \end_inset
7070
7071
7072 \size large
7073 \bar under
7074
7075 \begin_inset LatexCommand \label{lyx:-pedantic-parse-number}
7076
7077 \end_inset
7078
7079
7080 \series default
7081 \size default
7082 \bar default
7083 Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed properly
7084  and the macro LO_B(3) gets expanded.
7085  See also #pragma pedantic_parse_number
7086 \begin_inset LatexCommand \vpageref{ite:pedantic_parse_number}
7087
7088 \end_inset
7089
7090  in section
7091 \begin_inset LatexCommand \ref{sec:Pragmas}
7092
7093 \end_inset
7094
7095
7096 \emph on
7097 Note: this functionality is not in conformance with C99 standard!
7098 \end_layout
7099
7100 \begin_layout List
7101 \labelwidthstring 00.00.0000
7102
7103 \series bold
7104 -Wp\InsetSpace ~
7105 preprocessorOption[,preprocessorOption]
7106 \series default
7107
7108 \begin_inset LatexCommand \index{-Wp preprocessorOption[,preprocessorOption]}
7109
7110 \end_inset
7111
7112 ...
7113  Pass the preprocessorOption to the preprocessor
7114 \family typewriter
7115 sdcpp
7116 \family default
7117
7118 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
7119
7120 \end_inset
7121
7122 .
7123  SDCC uses an adapted version of the preprocessor
7124 \emph on
7125 cpp
7126 \emph default
7127  of the GNU Compiler Collection
7128 \begin_inset LatexCommand \index{gcc (GNU Compiler Collection)}
7129
7130 \end_inset
7131
7132  (
7133 \emph on
7134 gcc
7135 \emph default
7136
7137 \begin_inset LatexCommand \url{http://gcc.gnu.org/}
7138
7139 \end_inset
7140
7141 ), if you need more dedicated options please refer to the GCC\InsetSpace ~
7142 4.1.1\InsetSpace ~
7143 CPP\InsetSpace ~
7144 Manual
7145  at
7146 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/software/gcc/onlinedocs/}
7147
7148 \end_inset
7149
7150 .
7151 \end_layout
7152
7153 \begin_layout Standard
7154 \begin_inset VSpace bigskip
7155 \end_inset
7156
7157
7158 \end_layout
7159
7160 \begin_layout Subsection
7161 Linker Options
7162 \begin_inset LatexCommand \index{Options linker}
7163
7164 \end_inset
7165
7166
7167 \begin_inset LatexCommand \index{Linker options}
7168
7169 \end_inset
7170
7171
7172 \end_layout
7173
7174 \begin_layout List
7175 \labelwidthstring 00.00.0000
7176
7177 \series bold
7178 -L\InsetSpace ~
7179 -
7180 \series default
7181
7182 \begin_inset ERT
7183 status collapsed
7184
7185 \begin_layout Standard
7186
7187
7188 \backslash
7189 /
7190 \end_layout
7191
7192 \end_inset
7193
7194
7195 \series bold
7196 -lib-path
7197 \begin_inset LatexCommand \index{-\/-lib-path <path>}
7198
7199 \end_inset
7200
7201
7202 \begin_inset LatexCommand \index{-L -\/-lib-path}
7203
7204 \end_inset
7205
7206
7207 \series default
7208 \InsetSpace ~
7209 <absolute path to additional libraries> This option is passed to the linkage
7210  editor's additional libraries
7211 \begin_inset LatexCommand \index{Libraries}
7212
7213 \end_inset
7214
7215  search path.
7216  The path name must be absolute.
7217  Additional library files may be specified in the command line.
7218  See section Compiling programs for more details.
7219 \end_layout
7220
7221 \begin_layout List
7222 \labelwidthstring 00.00.0000
7223
7224 \series bold
7225 -
7226 \begin_inset ERT
7227 status collapsed
7228
7229 \begin_layout Standard
7230
7231
7232 \backslash
7233 /
7234 \end_layout
7235
7236 \end_inset
7237
7238 -xram-loc
7239 \series default
7240
7241 \begin_inset LatexCommand \index{-\/-xram-loc <Value>}
7242
7243 \end_inset
7244
7245 \InsetSpace ~
7246 <Value> The start location of the external ram
7247 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
7248
7249 \end_inset
7250
7251 , default value is 0.
7252  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7253 \begin_inset ERT
7254 status collapsed
7255
7256 \begin_layout Standard
7257
7258
7259 \backslash
7260 /
7261 \end_layout
7262
7263 \end_inset
7264
7265 -xram-loc 0x8000 or -
7266 \begin_inset ERT
7267 status collapsed
7268
7269 \begin_layout Standard
7270
7271
7272 \backslash
7273 /
7274 \end_layout
7275
7276 \end_inset
7277
7278 -xram-loc 32768.
7279 \end_layout
7280
7281 \begin_layout List
7282 \labelwidthstring 00.00.0000
7283
7284 \series bold
7285 -
7286 \begin_inset ERT
7287 status collapsed
7288
7289 \begin_layout Standard
7290
7291
7292 \backslash
7293 /
7294 \end_layout
7295
7296 \end_inset
7297
7298 -code-loc
7299 \series default
7300
7301 \begin_inset LatexCommand \index{-\/-code-loc <Value>}
7302
7303 \end_inset
7304
7305 \InsetSpace ~
7306 <Value> The start location of the code
7307 \begin_inset LatexCommand \index{code}
7308
7309 \end_inset
7310
7311  segment, default value 0.
7312  Note when this option is used the interrupt vector table
7313 \begin_inset LatexCommand \index{interrupt vector table}
7314
7315 \end_inset
7316
7317  is also relocated to the given address.
7318  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7319 \begin_inset ERT
7320 status collapsed
7321
7322 \begin_layout Standard
7323
7324
7325 \backslash
7326 /
7327 \end_layout
7328
7329 \end_inset
7330
7331 -code-loc 0x8000 or -
7332 \begin_inset ERT
7333 status collapsed
7334
7335 \begin_layout Standard
7336
7337
7338 \backslash
7339 /
7340 \end_layout
7341
7342 \end_inset
7343
7344 -code-loc 32768.
7345 \end_layout
7346
7347 \begin_layout List
7348 \labelwidthstring 00.00.0000
7349
7350 \series bold
7351 -
7352 \begin_inset ERT
7353 status collapsed
7354
7355 \begin_layout Standard
7356
7357
7358 \backslash
7359 /
7360 \end_layout
7361
7362 \end_inset
7363
7364 -stack-loc
7365 \series default
7366
7367 \begin_inset LatexCommand \index{-\/-stack-loc <Value>}
7368
7369 \end_inset
7370
7371 \InsetSpace ~
7372 <Value> By default the stack
7373 \begin_inset LatexCommand \index{stack}
7374
7375 \end_inset
7376
7377  is placed after the data segment.
7378  Using this option the stack can be placed anywhere in the internal memory
7379  space of the 8051.
7380  The value entered can be in Hexadecimal or Decimal format, e.g.
7381  -
7382 \begin_inset ERT
7383 status collapsed
7384
7385 \begin_layout Standard
7386
7387
7388 \backslash
7389 /
7390 \end_layout
7391
7392 \end_inset
7393
7394 -stack-loc 0x20 or -
7395 \begin_inset ERT
7396 status collapsed
7397
7398 \begin_layout Standard
7399
7400
7401 \backslash
7402 /
7403 \end_layout
7404
7405 \end_inset
7406
7407 -stack-loc 32.
7408  Since the sp register is incremented before a push or call, the initial
7409  sp will be set to one byte prior the provided value.
7410  The provided value should not overlap any other memory areas such as used
7411  register banks or the data segment and with enough space for the current
7412  application.
7413  The
7414 \series bold
7415 -
7416 \begin_inset ERT
7417 status collapsed
7418
7419 \begin_layout Standard
7420
7421
7422 \backslash
7423 /
7424 \end_layout
7425
7426 \end_inset
7427
7428 -pack-iram
7429 \series default
7430 \InsetSpace ~
7431
7432 \begin_inset LatexCommand \index{-\/-pack-iram}
7433
7434 \end_inset
7435
7436  option (which is now a default setting) will override this setting, so
7437  you should also specify the
7438 \series bold
7439 -
7440 \begin_inset ERT
7441 status collapsed
7442
7443 \begin_layout Standard
7444
7445
7446 \backslash
7447 /
7448 \end_layout
7449
7450 \end_inset
7451
7452 -no-pack-iram
7453 \series default
7454 \InsetSpace ~
7455
7456 \begin_inset LatexCommand \index{-\/-no-pack-iram}
7457
7458 \end_inset
7459
7460  option if you need to manually place the stack.
7461 \end_layout
7462
7463 \begin_layout List
7464 \labelwidthstring 00.00.0000
7465
7466 \series bold
7467 -
7468 \begin_inset ERT
7469 status collapsed
7470
7471 \begin_layout Standard
7472
7473
7474 \backslash
7475 /
7476 \end_layout
7477
7478 \end_inset
7479
7480 -xstack-loc
7481 \series default
7482
7483 \begin_inset LatexCommand \index{-\/-xstack-loc <Value>}
7484
7485 \end_inset
7486
7487 \InsetSpace ~
7488 <Value> By default the external stack
7489 \begin_inset LatexCommand \index{xstack}
7490
7491 \end_inset
7492
7493  is placed after the pdata
7494 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
7495
7496 \end_inset
7497
7498  segment.
7499  Using this option the xstack can be placed anywhere in the external memory
7500  space of the 8051.
7501  The value entered can be in Hexadecimal or Decimal format, e.g.
7502  -
7503 \begin_inset ERT
7504 status collapsed
7505
7506 \begin_layout Standard
7507
7508
7509 \backslash
7510 /
7511 \end_layout
7512
7513 \end_inset
7514
7515 -xstack-loc 0x8000 or -
7516 \begin_inset ERT
7517 status collapsed
7518
7519 \begin_layout Standard
7520
7521
7522 \backslash
7523 /
7524 \end_layout
7525
7526 \end_inset
7527
7528 -stack-loc 32768.
7529  The provided value should not overlap any other memory areas such as the
7530  pdata or xdata segment and with enough space for the current application.
7531 \end_layout
7532
7533 \begin_layout List
7534 \labelwidthstring 00.00.0000
7535
7536 \series bold
7537 -
7538 \begin_inset ERT
7539 status collapsed
7540
7541 \begin_layout Standard
7542
7543
7544 \backslash
7545 /
7546 \end_layout
7547
7548 \end_inset
7549
7550 -data-loc
7551 \series default
7552
7553 \begin_inset LatexCommand \index{-\/-data-loc <Value>}
7554
7555 \end_inset
7556
7557 \InsetSpace ~
7558 <Value> The start location of the internal ram data
7559 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
7560
7561 \end_inset
7562
7563  segment.
7564  The value entered can be in Hexadecimal or Decimal format, eg.
7565  -
7566 \begin_inset ERT
7567 status collapsed
7568
7569 \begin_layout Standard
7570
7571
7572 \backslash
7573 /
7574 \end_layout
7575
7576 \end_inset
7577
7578 -data-loc 0x20 or -
7579 \begin_inset ERT
7580 status collapsed
7581
7582 \begin_layout Standard
7583
7584
7585 \backslash
7586 /
7587 \end_layout
7588
7589 \end_inset
7590
7591 -data-loc 32.
7592  (By default, the start location of the internal ram data segment  is set
7593  as low as possible in memory, taking into account the used register banks
7594  and the bit segment at address 0x20.
7595  For example if register banks 0 and 1 are used without bit variables, the
7596  data segment will be set, if -
7597 \begin_inset ERT
7598 status collapsed
7599
7600 \begin_layout Standard
7601
7602
7603 \backslash
7604 /
7605 \end_layout
7606
7607 \end_inset
7608
7609 -data-loc is not used, to location 0x10.)
7610 \end_layout
7611
7612 \begin_layout List
7613 \labelwidthstring 00.00.0000
7614
7615 \series bold
7616 -
7617 \begin_inset ERT
7618 status collapsed
7619
7620 \begin_layout Standard
7621
7622
7623 \backslash
7624 /
7625 \end_layout
7626
7627 \end_inset
7628
7629 -idata-loc
7630 \series default
7631
7632 \begin_inset LatexCommand \index{-\/-idata-loc <Value>}
7633
7634 \end_inset
7635
7636 \InsetSpace ~
7637 <Value> The start location of the indirectly addressable internal ram
7638 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
7639
7640 \end_inset
7641
7642  of the 8051, default value is 0x80.
7643  The value entered can be in Hexadecimal or Decimal format, eg.
7644  -
7645 \begin_inset ERT
7646 status collapsed
7647
7648 \begin_layout Standard
7649
7650
7651 \backslash
7652 /
7653 \end_layout
7654
7655 \end_inset
7656
7657 -idata-loc 0x88 or -
7658 \begin_inset ERT
7659 status collapsed
7660
7661 \begin_layout Standard
7662
7663
7664 \backslash
7665 /
7666 \end_layout
7667
7668 \end_inset
7669
7670 -idata-loc 136.
7671 \end_layout
7672
7673 \begin_layout List
7674 \labelwidthstring 00.00.0000
7675
7676 \series bold
7677 -
7678 \begin_inset ERT
7679 status collapsed
7680
7681 \begin_layout Standard
7682
7683
7684 \backslash
7685 /
7686 \end_layout
7687
7688 \end_inset
7689
7690 -bit-loc
7691 \series default
7692 \InsetSpace ~
7693 <Value> The start location of the bit
7694 \begin_inset LatexCommand \index{bit}
7695
7696 \end_inset
7697
7698  addressable internal ram of the 8051.
7699  This is
7700 \emph on
7701 not
7702 \emph default
7703  implemented yet.
7704  Instead an option can be passed directly to the linker: -Wl\InsetSpace ~
7705 -bBSEG=<Value>.
7706 \end_layout
7707
7708 \begin_layout List
7709 \labelwidthstring 00.00.0000
7710
7711 \series bold
7712 -
7713 \begin_inset ERT
7714 status collapsed
7715
7716 \begin_layout Standard
7717
7718
7719 \backslash
7720 /
7721 \end_layout
7722
7723 \end_inset
7724
7725 -out-fmt-ihx
7726 \begin_inset LatexCommand \index{-\/-out-fmt-ihx}
7727
7728 \end_inset
7729
7730
7731 \series default
7732 The linker output (final object code) is in Intel Hex format.
7733 \begin_inset LatexCommand \index{Intel hex format}
7734
7735 \end_inset
7736
7737  This is the default option.
7738  The format itself is documented in the documentation of srecord
7739 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
7740
7741 \end_inset
7742
7743 .
7744 \end_layout
7745
7746 \begin_layout List
7747 \labelwidthstring 00.00.0000
7748
7749 \series bold
7750 -
7751 \begin_inset ERT
7752 status collapsed
7753
7754 \begin_layout Standard
7755
7756
7757 \backslash
7758 /
7759 \end_layout
7760
7761 \end_inset
7762
7763 -out-fmt-s19
7764 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
7765
7766 \end_inset
7767
7768
7769 \series default
7770 The linker output (final object code) is in Motorola S19 format
7771 \begin_inset LatexCommand \index{Motorola S19 format}
7772
7773 \end_inset
7774
7775 .
7776  The format itself is documented in the documentation of srecord.
7777 \end_layout
7778
7779 \begin_layout List
7780 \labelwidthstring 00.00.0000
7781
7782 \series bold
7783 -
7784 \begin_inset ERT
7785 status collapsed
7786
7787 \begin_layout Standard
7788
7789
7790 \backslash
7791 /
7792 \end_layout
7793
7794 \end_inset
7795
7796 -out-fmt-elf
7797 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
7798
7799 \end_inset
7800
7801
7802 \begin_inset LatexCommand \index{HC08!Options!-\/-out-fmt-elf}
7803
7804 \end_inset
7805
7806
7807 \series default
7808 The linker output (final object code) is in ELF format
7809 \begin_inset LatexCommand \index{ELF format}
7810
7811 \end_inset
7812
7813 .
7814  (Currently only supported for the HC08
7815 \begin_inset LatexCommand \index{HC08}
7816
7817 \end_inset
7818
7819  processors)
7820 \end_layout
7821
7822 \begin_layout List
7823 \labelwidthstring 00.00.0000
7824
7825 \series bold
7826 -Wl\InsetSpace ~
7827 linkOption[,linkOption]
7828 \series default
7829
7830 \begin_inset LatexCommand \index{-Wl linkOption[,linkOption]}
7831
7832 \end_inset
7833
7834 ...
7835  Pass the linkOption to the linker.
7836  If a bootloader is used an option like
7837 \begin_inset Quotes sld
7838 \end_inset
7839
7840 -Wl\InsetSpace ~
7841 -bCSEG=0x1000
7842 \begin_inset Quotes srd
7843 \end_inset
7844
7845  would be typical to set the start of the code segment.
7846  See also #pragma constseg and #pragma codeseg in section
7847 \begin_inset LatexCommand \ref{sec:Pragmas}
7848
7849 \end_inset
7850
7851  .
7852  File sdcc/as/doc/asxhtm.html has more on linker options.
7853 \end_layout
7854
7855 \begin_layout Standard
7856 \begin_inset VSpace bigskip
7857 \end_inset
7858
7859
7860 \end_layout
7861
7862 \begin_layout Subsection
7863 MCS51 Options
7864 \begin_inset LatexCommand \index{Options MCS51}
7865
7866 \end_inset
7867
7868
7869 \begin_inset LatexCommand \index{MCS51 options}
7870
7871 \end_inset
7872
7873
7874 \end_layout
7875
7876 \begin_layout List
7877 \labelwidthstring 00.00.0000
7878
7879 \series bold
7880 -
7881 \begin_inset ERT
7882 status collapsed
7883
7884 \begin_layout Standard
7885
7886
7887 \backslash
7888 /
7889 \end_layout
7890
7891 \end_inset
7892
7893 -model-small
7894 \begin_inset LatexCommand \index{-\/-model-small}
7895
7896 \end_inset
7897
7898
7899 \series default
7900 Generate code for Small Model programs, see section Memory Models for more
7901  details.
7902  This is the default model.
7903 \end_layout
7904
7905 \begin_layout List
7906 \labelwidthstring 00.00.0000
7907
7908 \series bold
7909 -
7910 \begin_inset ERT
7911 status collapsed
7912
7913 \begin_layout Standard
7914
7915
7916 \backslash
7917 /
7918 \end_layout
7919
7920 \end_inset
7921
7922 -model-medium
7923 \begin_inset LatexCommand \index{-\/-model-medium}
7924
7925 \end_inset
7926
7927
7928 \series default
7929  Generate code for Medium model programs, see section Memory Models for
7930  more details.
7931  If this option is used all source files in the project have to be compiled
7932  with this option.
7933  It must also be used when invoking the linker.
7934 \end_layout
7935
7936 \begin_layout List
7937 \labelwidthstring 00.00.0000
7938
7939 \series bold
7940 -
7941 \begin_inset ERT
7942 status collapsed
7943
7944 \begin_layout Standard
7945
7946
7947 \backslash
7948 /
7949 \end_layout
7950
7951 \end_inset
7952
7953 -model-large
7954 \begin_inset LatexCommand \index{-\/-model-large}
7955
7956 \end_inset
7957
7958
7959 \series default
7960  Generate code for Large model programs, see section Memory Models for more
7961  details.
7962  If this option is used all source files in the project have to be compiled
7963  with this option.
7964  It must also be used when invoking the linker.
7965 \end_layout
7966
7967 \begin_layout List
7968 \labelwidthstring 00.00.0000
7969
7970 \series bold
7971 -
7972 \begin_inset ERT
7973 status collapsed
7974
7975 \begin_layout Standard
7976
7977
7978 \backslash
7979 /
7980 \end_layout
7981
7982 \end_inset
7983
7984 -xstack
7985 \begin_inset LatexCommand \index{-\/-xstack}
7986
7987 \end_inset
7988
7989
7990 \series default
7991  Uses a pseudo stack in the pdata
7992 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
7993
7994 \end_inset
7995
7996  area (usually the first 256 bytes in the external ram) for allocating variables
7997  and passing parameters.
7998  See section
7999 \begin_inset LatexCommand \ref{sub:External-Stack}
8000
8001 \end_inset
8002
8003 \InsetSpace ~
8004  External Stack for more details.
8005 \end_layout
8006
8007 \begin_layout List
8008 \labelwidthstring 00.00.0000
8009
8010 \series bold
8011 -
8012 \begin_inset ERT
8013 status collapsed
8014
8015 \begin_layout Standard
8016
8017
8018 \backslash
8019 /
8020 \end_layout
8021
8022 \end_inset
8023
8024 -iram-size
8025 \series default
8026 \InsetSpace ~
8027 <Value>
8028 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
8029
8030 \end_inset
8031
8032  Causes the linker to check if the internal ram usage is within limits of
8033  the given value.
8034 \end_layout
8035
8036 \begin_layout List
8037 \labelwidthstring 00.00.0000
8038
8039 \series bold
8040 -
8041 \begin_inset ERT
8042 status collapsed
8043
8044 \begin_layout Standard
8045
8046
8047 \backslash
8048 /
8049 \end_layout
8050
8051 \end_inset
8052
8053 -xram-size
8054 \series default
8055 \InsetSpace ~
8056 <Value>
8057 \begin_inset LatexCommand \index{-\/-xram-size <Value>}
8058
8059 \end_inset
8060
8061  Causes the linker to check if the external ram usage is within limits of
8062  the given value.
8063 \end_layout
8064
8065 \begin_layout List
8066 \labelwidthstring 00.00.0000
8067
8068 \series bold
8069 -
8070 \begin_inset ERT
8071 status collapsed
8072
8073 \begin_layout Standard
8074
8075
8076 \backslash
8077 /
8078 \end_layout
8079
8080 \end_inset
8081
8082 -code-size
8083 \series default
8084 \InsetSpace ~
8085 <Value>
8086 \begin_inset LatexCommand \index{-\/-code-size <Value>}
8087
8088 \end_inset
8089
8090  Causes the linker to check if the code memory usage is within limits of
8091  the given value.
8092 \end_layout
8093
8094 \begin_layout List
8095 \labelwidthstring 00.00.0000
8096
8097 \series bold
8098 -
8099 \begin_inset ERT
8100 status collapsed
8101
8102 \begin_layout Standard
8103
8104
8105 \backslash
8106 /
8107 \end_layout
8108
8109 \end_inset
8110
8111 -stack-size
8112 \series default
8113 \InsetSpace ~
8114 <Value>
8115 \begin_inset LatexCommand \index{-\/-stack-size <Value>}
8116
8117 \end_inset
8118
8119  Causes the linker to check if there is at minimum <Value> bytes for stack.
8120 \end_layout
8121
8122 \begin_layout List
8123 \labelwidthstring 00.00.0000
8124
8125 \series bold
8126 -
8127 \begin_inset ERT
8128 status collapsed
8129
8130 \begin_layout Standard
8131
8132
8133 \backslash
8134 /
8135 \end_layout
8136
8137 \end_inset
8138
8139 -pack-iram
8140 \series default
8141 \InsetSpace ~
8142
8143 \begin_inset LatexCommand \index{-\/-pack-iram}
8144
8145 \end_inset
8146
8147  Causes the linker to use unused register banks for data variables and pack
8148  data, idata and stack together.
8149  This is the default now.
8150 \end_layout
8151
8152 \begin_layout List
8153 \labelwidthstring 00.00.0000
8154
8155 \series bold
8156 -
8157 \begin_inset ERT
8158 status collapsed
8159
8160 \begin_layout Standard
8161
8162
8163 \backslash
8164 /
8165 \end_layout
8166
8167 \end_inset
8168
8169 -no-pack-iram
8170 \series default
8171 \InsetSpace ~
8172
8173 \begin_inset LatexCommand \index{-\/-no-pack-iram}
8174
8175 \end_inset
8176
8177  Causes the linker to use old style for allocating memory areas.
8178 \end_layout
8179
8180 \begin_layout List
8181 \labelwidthstring 00.00.0000
8182
8183 \series bold
8184 -
8185 \begin_inset ERT
8186 status collapsed
8187
8188 \begin_layout Standard
8189
8190
8191 \backslash
8192 /
8193 \end_layout
8194
8195 \end_inset
8196
8197 -acall-ajmp
8198 \series default
8199 \InsetSpace ~
8200
8201 \begin_inset LatexCommand \index{-\/-acall-ajmp}
8202
8203 \end_inset
8204
8205  Replaces the three byte instructions lcall/ljmp with the two byte instructions
8206  acall/ajmp.
8207  Only use this option if your code is in the same 2k block of memory.
8208  You may need to use this option for some 8051 derivatives which lack the
8209  lcall/ljmp instructions..
8210 \end_layout
8211
8212 \begin_layout Standard
8213 \begin_inset VSpace bigskip
8214 \end_inset
8215
8216
8217 \end_layout
8218
8219 \begin_layout Subsection
8220 DS390 / DS400 Options
8221 \begin_inset LatexCommand \index{Options DS390}
8222
8223 \end_inset
8224
8225
8226 \begin_inset LatexCommand \index{DS390}
8227
8228 \end_inset
8229
8230
8231 \end_layout
8232
8233 \begin_layout List
8234 \labelwidthstring 00.00.0000
8235
8236 \series bold
8237 -
8238 \begin_inset ERT
8239 status collapsed
8240
8241 \begin_layout Standard
8242
8243
8244 \backslash
8245 /
8246 \end_layout
8247
8248 \end_inset
8249
8250 -model-flat24
8251 \series default
8252
8253 \begin_inset LatexCommand \index{DS390!Options!-\/-model-flat24}
8254
8255 \end_inset
8256
8257 Generate 24-bit flat mode code.
8258  This is the one and only that the ds390 code generator supports right now
8259  and is default when using
8260 \emph on
8261 -mds390
8262 \emph default
8263 .
8264  See section Memory Models for more details.
8265 \end_layout
8266
8267 \begin_layout List
8268 \labelwidthstring 00.00.0000
8269
8270 \series bold
8271 -
8272 \begin_inset ERT
8273 status collapsed
8274
8275 \begin_layout Standard
8276
8277
8278 \backslash
8279 /
8280 \end_layout
8281
8282 \end_inset
8283
8284 -protect-sp-update
8285 \begin_inset LatexCommand \index{DS390!Options!-\/-protect-sp-update}
8286
8287 \end_inset
8288
8289
8290 \series default
8291  disable interrupts during ESP:SP updates.
8292 \end_layout
8293
8294 \begin_layout List
8295 \labelwidthstring 00.00.0000
8296
8297 \series bold
8298 -
8299 \begin_inset ERT
8300 status collapsed
8301
8302 \begin_layout Standard
8303
8304
8305 \backslash
8306 /
8307 \end_layout
8308
8309 \end_inset
8310
8311 -stack-10bit
8312 \series default
8313
8314 \begin_inset LatexCommand \index{DS390!Options!-\/-stack-10bit}
8315
8316 \end_inset
8317
8318  Generate code for the 10 bit stack mode of the Dallas DS80C390 part.
8319  This is the one and only that the ds390 code generator supports right now
8320  and is default when using
8321 \emph on
8322 -mds390
8323 \emph default
8324 .
8325  In this mode, the stack is located in the lower 1K of the internal RAM,
8326  which is mapped to 0x400000.
8327  Note that the support is incomplete, since it still uses a single byte
8328  as the stack pointer.
8329  This means that only the lower 256 bytes of the potential 1K stack space
8330  will actually be used.
8331  However, this does allow you to reclaim the precious 256 bytes of low RAM
8332  for use for the DATA and IDATA segments.
8333  The compiler will not generate any code to put the processor into 10 bit
8334  stack mode.
8335  It is important to ensure that the processor is in this mode before calling
8336  any re-entrant functions compiled with this option.
8337  In principle, this should work with the
8338 \emph on
8339 -
8340 \begin_inset ERT
8341 status collapsed
8342
8343 \begin_layout Standard
8344
8345
8346 \backslash
8347 /
8348 \end_layout
8349
8350 \end_inset
8351
8352 -stack-auto
8353 \begin_inset LatexCommand \index{-\/-stack-auto}
8354
8355 \end_inset
8356
8357
8358 \emph default
8359  option, but that has not been tested.
8360  It is incompatible with the
8361 \emph on
8362 -
8363 \begin_inset ERT
8364 status collapsed
8365
8366 \begin_layout Standard
8367
8368
8369 \backslash
8370 /
8371 \end_layout
8372
8373 \end_inset
8374
8375 -xstack
8376 \begin_inset LatexCommand \index{-\/-xstack}
8377
8378 \end_inset
8379
8380
8381 \emph default
8382  option.
8383  It also only makes sense if the processor is in 24 bit contiguous addressing
8384  mode (see the
8385 \emph on
8386 -
8387 \begin_inset ERT
8388 status collapsed
8389
8390 \begin_layout Standard
8391
8392
8393 \backslash
8394 /
8395 \end_layout
8396
8397 \end_inset
8398
8399 -model-flat24 option
8400 \emph default
8401 ).
8402 \series bold
8403
8404 \begin_inset Note Note
8405 status collapsed
8406
8407 \begin_layout List
8408 \labelwidthstring 00.00.0000
8409
8410 \series bold
8411 -
8412 \begin_inset ERT
8413 status open
8414
8415 \begin_layout Standard
8416
8417
8418 \backslash
8419 /
8420 \end_layout
8421
8422 \end_inset
8423
8424 -stack-8-bit - switches off the 10-bit mode
8425 \end_layout
8426
8427 \end_inset
8428
8429
8430 \end_layout
8431
8432 \begin_layout List
8433 \labelwidthstring 00.00.0000
8434
8435 \series bold
8436 -
8437 \begin_inset ERT
8438 status collapsed
8439
8440 \begin_layout Standard
8441
8442
8443 \backslash
8444 /
8445 \end_layout
8446
8447 \end_inset
8448
8449 -stack-probe
8450 \begin_inset LatexCommand \index{DS390!Options!-\/-stack-probe}
8451
8452 \end_inset
8453
8454
8455 \series default
8456  insert call to function __stack_probe at each function prologue.
8457 \end_layout
8458
8459 \begin_layout List
8460 \labelwidthstring 00.00.0000
8461
8462 \series bold
8463 -
8464 \begin_inset ERT
8465 status open
8466
8467 \begin_layout Standard
8468
8469
8470 \backslash
8471 /
8472 \end_layout
8473
8474 \end_inset
8475
8476 -tini-libid
8477 \begin_inset LatexCommand \index{DS390!Options!-\/-tini-libid}
8478
8479 \end_inset
8480
8481
8482 \series default
8483  <nnnn> LibraryID used in -mTININative.
8484 \end_layout
8485
8486 \begin_layout List
8487 \labelwidthstring 00.00.0000
8488
8489 \series bold
8490 -
8491 \begin_inset ERT
8492 status collapsed
8493
8494 \begin_layout Standard
8495
8496
8497 \backslash
8498 /
8499 \end_layout
8500
8501 \end_inset
8502
8503 -use-accelerator
8504 \begin_inset LatexCommand \index{DS390!Options!-\/-use-accelerator}
8505
8506 \end_inset
8507
8508
8509 \series default
8510  generate code for DS390 Arithmetic Accelerator.
8511 \end_layout
8512
8513 \begin_layout Standard
8514 \begin_inset VSpace bigskip
8515 \end_inset
8516
8517
8518 \end_layout
8519
8520 \begin_layout Subsection
8521 Z80 Options
8522 \begin_inset LatexCommand \index{Options Z80}
8523
8524 \end_inset
8525
8526
8527 \begin_inset LatexCommand \index{Z80}
8528
8529 \end_inset
8530
8531
8532 \end_layout
8533
8534 \begin_layout List
8535 \labelwidthstring 00.00.0000
8536
8537 \series bold
8538 -
8539 \begin_inset ERT
8540 status collapsed
8541
8542 \begin_layout Standard
8543
8544
8545 \backslash
8546 /
8547 \end_layout
8548
8549 \end_inset
8550
8551 -callee-saves-bc
8552 \series default
8553
8554 \begin_inset LatexCommand \index{Z80!Options!-\/-callee-saves-bc}
8555
8556 \end_inset
8557
8558 Force a called function to always save BC.
8559 \end_layout
8560
8561 \begin_layout List
8562 \labelwidthstring 00.00.0000
8563
8564 \series bold
8565 -
8566 \begin_inset ERT
8567 status collapsed
8568
8569 \begin_layout Standard
8570
8571
8572 \backslash
8573 /
8574 \end_layout
8575
8576 \end_inset
8577
8578 -no-std-crt0
8579 \series default
8580
8581 \begin_inset LatexCommand \index{Z80!Options!-\/-no-std-crt0}
8582
8583 \end_inset
8584
8585  When linking, skip the standard crt0.o object file.
8586  You must provide your own crt0.o for your system when linking.
8587 \end_layout
8588
8589 \begin_layout List
8590 \labelwidthstring 00.00.0000
8591
8592 \series bold
8593 -
8594 \begin_inset ERT
8595 status collapsed
8596
8597 \begin_layout Standard
8598
8599
8600 \backslash
8601 /
8602 \end_layout
8603
8604 \end_inset
8605
8606 -portmode=
8607 \series default
8608 <Value>
8609 \begin_inset LatexCommand \index{Z80!Options!-\/-portmode=<Value>}
8610
8611 \end_inset
8612
8613  Determinate PORT I/O mode (<Value> is z80 or z180).
8614 \end_layout
8615
8616 \begin_layout List
8617 \labelwidthstring 00.00.0000
8618
8619 \series bold
8620 -
8621 \begin_inset ERT
8622 status collapsed
8623
8624 \begin_layout Standard
8625
8626
8627 \backslash
8628 /
8629 \end_layout
8630
8631 \end_inset
8632
8633 -asm=
8634 \series default
8635 <Value>
8636 \begin_inset LatexCommand \index{Z80!Options!-\/-asm=<Value>}
8637
8638 \end_inset
8639
8640  Define assembler name (<Value> is rgbds, asxxxx, isas or z80asm).
8641 \end_layout
8642
8643 \begin_layout List
8644 \labelwidthstring 00.00.0000
8645
8646 \series bold
8647 -
8648 \begin_inset ERT
8649 status collapsed
8650
8651 \begin_layout Standard
8652
8653
8654 \backslash
8655 /
8656 \end_layout
8657
8658 \end_inset
8659
8660 -codeseg
8661 \series default
8662 \InsetSpace ~
8663 <Value>
8664 \begin_inset LatexCommand \index{Z80!Options!-\/-codeseg <Value>}
8665
8666 \end_inset
8667
8668  Use <Value> for the code segment name.
8669 \end_layout
8670
8671 \begin_layout List
8672 \labelwidthstring 00.00.0000
8673
8674 \series bold
8675 -
8676 \begin_inset ERT
8677 status collapsed
8678
8679 \begin_layout Standard
8680
8681
8682 \backslash
8683 /
8684 \end_layout
8685
8686 \end_inset
8687
8688 -constseg
8689 \series default
8690 \InsetSpace ~
8691 <Value>
8692 \begin_inset LatexCommand \index{Z80!Options!-\/-constseg <Value>}
8693
8694 \end_inset
8695
8696  Use <Value> for the const segment name.
8697 \end_layout
8698
8699 \begin_layout List
8700 \labelwidthstring 00.00.0000
8701 \begin_inset VSpace bigskip
8702 \end_inset
8703
8704
8705 \end_layout
8706
8707 \begin_layout Subsection
8708 GBZ80 Options
8709 \begin_inset LatexCommand \index{Options GBZ80}
8710
8711 \end_inset
8712
8713
8714 \begin_inset LatexCommand \index{GBZ80}
8715
8716 \end_inset
8717
8718
8719 \end_layout
8720
8721 \begin_layout List
8722 \labelwidthstring 00.00.0000
8723
8724 \series bold
8725 -
8726 \begin_inset ERT
8727 status collapsed
8728
8729 \begin_layout Standard
8730
8731
8732 \backslash
8733 /
8734 \end_layout
8735
8736 \end_inset
8737
8738 -callee-saves-bc
8739 \series default
8740
8741 \begin_inset LatexCommand \index{GBZ80!Options!-\/-callee-saves-bc}
8742
8743 \end_inset
8744
8745 Force a called function to always save BC.
8746 \end_layout
8747
8748 \begin_layout List
8749 \labelwidthstring 00.00.0000
8750
8751 \series bold
8752 -bo
8753 \series default
8754 \InsetSpace ~
8755 <Num>
8756 \begin_inset LatexCommand \index{GBZ80!Options!-bo <Num>}
8757
8758 \end_inset
8759
8760  Use code bank <Num>.
8761 \end_layout
8762
8763 \begin_layout List
8764 \labelwidthstring 00.00.0000
8765
8766 \series bold
8767 -ba
8768 \series default
8769 \InsetSpace ~
8770 <Num>
8771 \begin_inset LatexCommand \index{GBZ80!Options!-ba <Num>}
8772
8773 \end_inset
8774
8775  Use data bank <Num>.
8776 \end_layout
8777
8778 \begin_layout List
8779 \labelwidthstring 00.00.0000
8780
8781 \series bold
8782 -
8783 \begin_inset ERT
8784 status collapsed
8785
8786 \begin_layout Standard
8787
8788
8789 \backslash
8790 /
8791 \end_layout
8792
8793 \end_inset
8794
8795 -codeseg
8796 \series default
8797 \InsetSpace ~
8798 <Value>
8799 \begin_inset LatexCommand \index{GBZ80!Options!-\/-codeseg <Value>}
8800
8801 \end_inset
8802
8803  Use <Value> for the code segment name.
8804 \end_layout
8805
8806 \begin_layout List
8807 \labelwidthstring 00.00.0000
8808
8809 \series bold
8810 -
8811 \begin_inset ERT
8812 status collapsed
8813
8814 \begin_layout Standard
8815
8816
8817 \backslash
8818 /
8819 \end_layout
8820
8821 \end_inset
8822
8823 -constseg
8824 \series default
8825 \InsetSpace ~
8826 <Value>
8827 \begin_inset LatexCommand \index{GBZ80!Options!-\/-constseg <Value>}
8828
8829 \end_inset
8830
8831  Use <Value> for the const segment name.
8832 \end_layout
8833
8834 \begin_layout Standard
8835 \begin_inset VSpace bigskip
8836 \end_inset
8837
8838
8839 \end_layout
8840
8841 \begin_layout Subsection
8842 Optimization Options
8843 \begin_inset LatexCommand \index{Options optimization}
8844
8845 \end_inset
8846
8847
8848 \begin_inset LatexCommand \index{Optimization options}
8849
8850 \end_inset
8851
8852
8853 \end_layout
8854
8855 \begin_layout List
8856 \labelwidthstring 00.00.0000
8857
8858 \series bold
8859 -
8860 \begin_inset ERT
8861 status collapsed
8862
8863 \begin_layout Standard
8864
8865
8866 \backslash
8867 /
8868 \end_layout
8869
8870 \end_inset
8871
8872 -nogcse
8873 \begin_inset LatexCommand \index{-\/-nogcse}
8874
8875 \end_inset
8876
8877
8878 \series default
8879  Will not do global subexpression elimination, this option may be used when
8880  the compiler creates undesirably large stack/data spaces to store compiler
8881  temporaries (
8882 \emph on
8883 s
8884 \emph default
8885 pill
8886 \emph on
8887 loc
8888 \emph default
8889 ations, sloc
8890 \begin_inset LatexCommand \index{sloc (spill location)}
8891
8892 \end_inset
8893
8894 ).
8895  A warning message will be generated when this happens and the compiler
8896  will indicate the number of extra bytes it allocated.
8897  It is recommended that this option NOT be used, #pragma\InsetSpace ~
8898 nogcse
8899 \begin_inset LatexCommand \index{\#pragma nogcse}
8900
8901 \end_inset
8902
8903  can be used to turn off global subexpression elimination
8904 \begin_inset LatexCommand \index{Subexpression elimination}
8905
8906 \end_inset
8907
8908  for a given function only.
8909 \end_layout
8910
8911 \begin_layout List
8912 \labelwidthstring 00.00.0000
8913
8914 \series bold
8915 -
8916 \begin_inset ERT
8917 status collapsed
8918
8919 \begin_layout Standard
8920
8921
8922 \backslash
8923 /
8924 \end_layout
8925
8926 \end_inset
8927
8928 -noinvariant
8929 \begin_inset LatexCommand \index{-\/-noinvariant}
8930
8931 \end_inset
8932
8933
8934 \series default
8935  Will not do loop invariant optimizations, this may be turned off for reasons
8936  explained for the previous option.
8937  For more details of loop optimizations performed see Loop Invariants in
8938  section
8939 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
8940
8941 \end_inset
8942
8943 .
8944  It is recommended that this option NOT be used, #pragma\InsetSpace ~
8945 noinvariant
8946 \begin_inset LatexCommand \index{\#pragma noinvariant}
8947
8948 \end_inset
8949
8950  can be used to turn off invariant optimizations for a given function only.
8951 \end_layout
8952
8953 \begin_layout List
8954 \labelwidthstring 00.00.0000
8955
8956 \series bold
8957 -
8958 \begin_inset ERT
8959 status collapsed
8960
8961 \begin_layout Standard
8962
8963
8964 \backslash
8965 /
8966 \end_layout
8967
8968 \end_inset
8969
8970 -noinduction
8971 \begin_inset LatexCommand \index{-\/-noinduction}
8972
8973 \end_inset
8974
8975
8976 \series default
8977  Will not do loop induction optimizations, see section strength reduction
8978  for more details.
8979  It is recommended that this option is NOT used, #pragma\InsetSpace ~
8980 noinduction
8981 \begin_inset LatexCommand \index{\#pragma noinduction}
8982
8983 \end_inset
8984
8985  can be used to turn off induction optimizations for a given function only.
8986 \end_layout
8987
8988 \begin_layout List
8989 \labelwidthstring 00.00.0000
8990
8991 \series bold
8992 -
8993 \begin_inset ERT
8994 status collapsed
8995
8996 \begin_layout Standard
8997
8998
8999 \backslash
9000 /
9001 \end_layout
9002
9003 \end_inset
9004
9005 -nojtbound
9006 \begin_inset LatexCommand \index{-\/-nojtbound}
9007
9008 \end_inset
9009
9010
9011 \series default
9012  Will not generate boundary condition check when switch statements
9013 \begin_inset LatexCommand \index{switch statement}
9014
9015 \end_inset
9016
9017  are implemented using jump-tables.
9018  See section
9019 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
9020
9021 \end_inset
9022
9023 \InsetSpace ~
9024 Switch Statements for more details.
9025  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9026 nojtbound
9027 \begin_inset LatexCommand \index{\#pragma nojtbound}
9028
9029 \end_inset
9030
9031  can be used to turn off boundary checking for jump tables for a given function
9032  only.
9033 \end_layout
9034
9035 \begin_layout List
9036 \labelwidthstring 00.00.0000
9037
9038 \series bold
9039 -
9040 \begin_inset ERT
9041 status collapsed
9042
9043 \begin_layout Standard
9044
9045
9046 \backslash
9047 /
9048 \end_layout
9049
9050 \end_inset
9051
9052 -noloopreverse
9053 \begin_inset LatexCommand \index{-\/-noloopreverse}
9054
9055 \end_inset
9056
9057
9058 \series default
9059 Will not do loop reversal
9060 \begin_inset LatexCommand \index{Loop reversing}
9061
9062 \end_inset
9063
9064 optimization.
9065 \end_layout
9066
9067 \begin_layout List
9068 \labelwidthstring 00.00.0000
9069 -
9070 \begin_inset ERT
9071 status collapsed
9072
9073 \begin_layout Standard
9074
9075
9076 \backslash
9077 /
9078 \end_layout
9079
9080 \end_inset
9081
9082 -
9083 \series bold
9084 nolabelopt
9085 \series default
9086
9087 \begin_inset LatexCommand \index{-\/-nolabelopt }
9088
9089 \end_inset
9090
9091 Will not optimize labels (makes the dumpfiles more readable).
9092 \end_layout
9093
9094 \begin_layout List
9095 \labelwidthstring 00.00.0000
9096
9097 \series bold
9098 -
9099 \begin_inset ERT
9100 status collapsed
9101
9102 \begin_layout Standard
9103
9104
9105 \backslash
9106 /
9107 \end_layout
9108
9109 \end_inset
9110
9111 -no-xinit-opt
9112 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
9113
9114 \end_inset
9115
9116
9117 \series default
9118  Will not memcpy initialized data from code space into xdata space.
9119  This saves a few bytes in code space if you don't have initialized data
9120 \begin_inset LatexCommand \index{Variable initialization}
9121
9122 \end_inset
9123
9124 .
9125 \end_layout
9126
9127 \begin_layout List
9128 \labelwidthstring 00.00.0000
9129
9130 \series bold
9131 -
9132 \begin_inset ERT
9133 status collapsed
9134
9135 \begin_layout Standard
9136
9137
9138 \backslash
9139 /
9140 \end_layout
9141
9142 \end_inset
9143
9144 -nooverlay
9145 \begin_inset LatexCommand \index{-\/-nooverlay}
9146
9147 \end_inset
9148
9149
9150 \series default
9151   The compiler will not overlay parameters and local variables of any function,
9152  see section Parameters and local variables for more details.
9153 \end_layout
9154
9155 \begin_layout List
9156 \labelwidthstring 00.00.0000
9157
9158 \series bold
9159 -
9160 \begin_inset ERT
9161 status collapsed
9162
9163 \begin_layout Standard
9164
9165
9166 \backslash
9167 /
9168 \end_layout
9169
9170 \end_inset
9171
9172 -no-peep
9173 \begin_inset LatexCommand \index{-\/-no-peep}
9174
9175 \end_inset
9176
9177
9178 \series default
9179  Disable peep-hole optimization with built-in rules.
9180 \end_layout
9181
9182 \begin_layout List
9183 \labelwidthstring 00.00.0000
9184
9185 \series bold
9186 -
9187 \begin_inset ERT
9188 status collapsed
9189
9190 \begin_layout Standard
9191
9192
9193 \backslash
9194 /
9195 \end_layout
9196
9197 \end_inset
9198
9199 -peep-file
9200 \series default
9201
9202 \begin_inset LatexCommand \index{-\/-peep-file}
9203
9204 \end_inset
9205
9206 \InsetSpace ~
9207 <filename> This option can be used to use additional rules to be used by
9208  the peep hole optimizer.
9209  See section
9210 \begin_inset LatexCommand \ref{sub:Peephole-Optimizer}
9211
9212 \end_inset
9213
9214 \InsetSpace ~
9215 Peep Hole optimizations for details on how to write these rules.
9216 \end_layout
9217
9218 \begin_layout List
9219 \labelwidthstring 00.00.0000
9220
9221 \series bold
9222 -
9223 \begin_inset ERT
9224 status collapsed
9225
9226 \begin_layout Standard
9227
9228
9229 \backslash
9230 /
9231 \end_layout
9232
9233 \end_inset
9234
9235 -peep-asm
9236 \begin_inset LatexCommand \index{-\/-peep-asm}
9237
9238 \end_inset
9239
9240
9241 \series default
9242  Pass the inline assembler code through the peep hole optimizer.
9243  This can cause unexpected changes to inline assembler code, please go through
9244  the peephole optimizer
9245 \begin_inset LatexCommand \index{Peephole optimizer}
9246
9247 \end_inset
9248
9249  rules defined in the source file tree '<target>/peeph.def' before using
9250  this option.
9251 \end_layout
9252
9253 \begin_layout List
9254 \labelwidthstring 00.00.0000
9255
9256 \series bold
9257 -
9258 \begin_inset ERT
9259 status collapsed
9260
9261 \begin_layout Standard
9262
9263
9264 \backslash
9265 /
9266 \end_layout
9267
9268 \end_inset
9269
9270 -opt-code-speed
9271 \begin_inset LatexCommand \index{-\/-opt-code-speed}
9272
9273 \end_inset
9274
9275
9276 \series default
9277  The compiler will optimize code generation towards fast code, possibly
9278  at the expense of code size.
9279 \end_layout
9280
9281 \begin_layout List
9282 \labelwidthstring 00.00.0000
9283
9284 \series bold
9285 -
9286 \begin_inset ERT
9287 status collapsed
9288
9289 \begin_layout Standard
9290
9291
9292 \backslash
9293 /
9294 \end_layout
9295
9296 \end_inset
9297
9298 -opt-code-size
9299 \begin_inset LatexCommand \index{-\/-opt-code-size}
9300
9301 \end_inset
9302
9303
9304 \series default
9305  The compiler will optimize code generation towards compact code, possibly
9306  at the expense of code speed.
9307 \end_layout
9308
9309 \begin_layout Standard
9310 \begin_inset VSpace bigskip
9311 \end_inset
9312
9313
9314 \end_layout
9315
9316 \begin_layout Subsection
9317 Other Options
9318 \begin_inset LatexCommand \index{Options other}
9319
9320 \end_inset
9321
9322
9323 \end_layout
9324
9325 \begin_layout List
9326 \labelwidthstring 00.00.0000
9327
9328 \series bold
9329 -c\InsetSpace ~
9330 -
9331 \begin_inset ERT
9332 status collapsed
9333
9334 \begin_layout Standard
9335
9336
9337 \backslash
9338 /
9339 \end_layout
9340
9341 \end_inset
9342
9343 -compile-only
9344 \begin_inset LatexCommand \index{-\/-compile-only}
9345
9346 \end_inset
9347
9348
9349 \begin_inset LatexCommand \index{-c -\/-compile-only}
9350
9351 \end_inset
9352
9353
9354 \series default
9355  will compile and assemble the source, but will not call the linkage editor.
9356 \end_layout
9357
9358 \begin_layout List
9359 \labelwidthstring 00.00.0000
9360
9361 \series bold
9362 -
9363 \series default
9364
9365 \begin_inset ERT
9366 status collapsed
9367
9368 \begin_layout Standard
9369
9370
9371 \backslash
9372 /
9373 \end_layout
9374
9375 \end_inset
9376
9377
9378 \series bold
9379 -c1mode
9380 \begin_inset LatexCommand \index{-\/-c1mode}
9381
9382 \end_inset
9383
9384
9385 \series default
9386  reads the preprocessed source from standard input and compiles it.
9387  The file name for the assembler output must be specified using the -o option.
9388 \end_layout
9389
9390 \begin_layout List
9391 \labelwidthstring 00.00.0000
9392
9393 \series bold
9394 -E
9395 \begin_inset LatexCommand \index{-E}
9396
9397 \end_inset
9398
9399
9400 \series default
9401  Run only the C preprocessor.
9402  Preprocess all the C source files specified and output the results to standard
9403  output.
9404 \end_layout
9405
9406 \begin_layout List
9407 \labelwidthstring 00.00.0000
9408
9409 \series bold
9410 -o\InsetSpace ~
9411 <path/file>
9412 \begin_inset LatexCommand \index{-o <path/file>}
9413
9414 \end_inset
9415
9416
9417 \series default
9418 The output path where everything will be placed or the file name used for
9419  all generated output files.
9420  If the parameter is a path, it must have a trailing slash (or backslash
9421  for the Windows binaries) to be recognized as a path.Note for Windows users:
9422  if the path contains spaces, it should be surrounded by quotes.
9423  The trailing backslash should be doubled in order to prevent escaping the
9424  final quote, for example:
9425 \emph on
9426 -o
9427 \begin_inset Quotes sld
9428 \end_inset
9429
9430 F:
9431 \backslash
9432 Projects
9433 \backslash
9434 test3
9435 \backslash
9436 output 1
9437 \backslash
9438
9439 \backslash
9440
9441 \begin_inset Quotes srd
9442 \end_inset
9443
9444
9445 \emph default
9446  or put after the final quote, for example:
9447 \emph on
9448 -o
9449 \begin_inset Quotes sld
9450 \end_inset
9451
9452 F:
9453 \backslash
9454 Projects
9455 \backslash
9456 test3
9457 \backslash
9458 output 1
9459 \begin_inset Quotes srd
9460 \end_inset
9461
9462
9463 \backslash
9464
9465 \emph default
9466 .
9467  The path using slashes for directory delimiters can be used too, for example:
9468 \emph on
9469 -o
9470 \begin_inset Quotes sld
9471 \end_inset
9472
9473 F:/Projects/test3/output 1/
9474 \begin_inset Quotes srd
9475 \end_inset
9476
9477
9478 \emph default
9479 .
9480 \end_layout
9481
9482 \begin_layout List
9483 \labelwidthstring 00.00.0000
9484
9485 \series bold
9486 -
9487 \begin_inset ERT
9488 status collapsed
9489
9490 \begin_layout Standard
9491
9492
9493 \backslash
9494 /
9495 \end_layout
9496
9497 \end_inset
9498
9499 -stack-auto
9500 \begin_inset LatexCommand \index{-\/-stack-auto}
9501
9502 \end_inset
9503
9504
9505 \series default
9506 All functions in the source file will be compiled as
9507 \emph on
9508 reentrant
9509 \emph default
9510
9511 \begin_inset LatexCommand \index{reentrant}
9512
9513 \end_inset
9514
9515 , i.e.
9516  the parameters and local variables will be allocated on the stack
9517 \begin_inset LatexCommand \index{stack}
9518
9519 \end_inset
9520
9521 .
9522  See section
9523 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
9524
9525 \end_inset
9526
9527  Parameters and Local Variables for more details.
9528  If this option is used all source files in the project should be compiled
9529  with this option.
9530  It automatically implies -
9531 \series bold
9532
9533 \begin_inset ERT
9534 status open
9535
9536 \begin_layout Standard
9537
9538
9539 \backslash
9540 /
9541 \end_layout
9542
9543 \end_inset
9544
9545
9546 \series default
9547 -int-long-reent and -
9548 \series bold
9549
9550 \begin_inset ERT
9551 status open
9552
9553 \begin_layout Standard
9554
9555
9556 \backslash
9557 /
9558 \end_layout
9559
9560 \end_inset
9561
9562
9563 \series default
9564 -float-reent.
9565 \end_layout
9566
9567 \begin_layout List
9568 \labelwidthstring 00.00.0000
9569
9570 \series bold
9571 -
9572 \begin_inset ERT
9573 status collapsed
9574
9575 \begin_layout Standard
9576
9577
9578 \backslash
9579 /
9580 \end_layout
9581
9582 \end_inset
9583
9584 -callee-saves
9585 \begin_inset LatexCommand \index{-\/-callee-saves}
9586
9587 \end_inset
9588
9589
9590 \begin_inset LatexCommand \label{lyx:--callee-saves-function1[,function2][,function3]...}
9591
9592 \end_inset
9593
9594 function1[,function2][,function3]....
9595
9596 \series default
9597  The compiler by default uses a caller saves convention for register saving
9598  across function calls, however this can cause unnecessary register pushing
9599  and popping when calling small functions from larger functions.
9600  This option can be used to switch the register saving convention for the
9601  function names specified.
9602  The compiler will not save registers when calling these functions, no extra
9603  code will be generated at the entry and exit (function prologue
9604 \series bold
9605
9606 \begin_inset LatexCommand \index{function prologue}
9607
9608 \end_inset
9609
9610
9611 \series default
9612  and epilogue
9613 \series bold
9614
9615 \begin_inset LatexCommand \index{function epilogue}
9616
9617 \end_inset
9618
9619
9620 \series default
9621 ) for these functions to save and restore the registers used by these functions,
9622  this can SUBSTANTIALLY reduce code and improve run time performance of
9623  the generated code.
9624  In the future the compiler (with inter procedural analysis) will be able
9625  to determine the appropriate scheme to use for each function call.
9626  DO NOT use this option for built-in functions such as _mulint..., if this
9627  option is used for a library function the appropriate library function
9628  needs to be recompiled with the same option.
9629  If the project consists of multiple source files then all the source file
9630  should be compiled with the same -
9631 \begin_inset ERT
9632 status collapsed
9633
9634 \begin_layout Standard
9635
9636
9637 \backslash
9638 /
9639 \end_layout
9640
9641 \end_inset
9642
9643 -callee-saves option string.
9644  Also see #pragma\InsetSpace ~
9645 callee_saves
9646 \begin_inset LatexCommand \index{\#pragma callee\_saves}
9647
9648 \end_inset
9649
9650
9651 \begin_inset LatexCommand \vpageref{ite:callee_saves-function1[,function2[,function3...]]--}
9652
9653 \end_inset
9654
9655 .
9656 \end_layout
9657
9658 \begin_layout List
9659 \labelwidthstring 00.00.0000
9660
9661 \series bold
9662 -
9663 \begin_inset ERT
9664 status collapsed
9665
9666 \begin_layout Standard
9667
9668
9669 \backslash
9670 /
9671 \end_layout
9672
9673 \end_inset
9674
9675 -all-callee-saves
9676 \begin_inset LatexCommand \index{-\/-all-callee-saves}
9677
9678 \end_inset
9679
9680
9681 \series default
9682 Function of-
9683 \begin_inset ERT
9684 status collapsed
9685
9686 \begin_layout Standard
9687
9688
9689 \backslash
9690 /
9691 \end_layout
9692
9693 \end_inset
9694
9695 -callee-saves will be applied to all functions by default.
9696 \end_layout
9697
9698 \begin_layout List
9699 \labelwidthstring 00.00.0000
9700
9701 \series bold
9702 -
9703 \begin_inset ERT
9704 status collapsed
9705
9706 \begin_layout Standard
9707
9708
9709 \backslash
9710 /
9711 \end_layout
9712
9713 \end_inset
9714
9715 -debug
9716 \begin_inset LatexCommand \index{-\/-debug}
9717
9718 \end_inset
9719
9720
9721 \series default
9722 When this option is used the compiler will generate debug information.
9723  The debug information collected in a file with .cdb extension can be used
9724  with the SDCDB.
9725  For more information see documentation for SDCDB.
9726  Another file with no extension contains debug information in AOMF or AOMF51
9727 \begin_inset LatexCommand \index{AOMF, AOMF51}
9728
9729 \end_inset
9730
9731  format which is commonly used by third party tools.
9732 \end_layout
9733
9734 \begin_layout List
9735 \labelwidthstring 00.00.0000
9736
9737 \series bold
9738 -S
9739 \begin_inset LatexCommand \index{-S}
9740
9741 \end_inset
9742
9743
9744 \series default
9745 Stop after the stage of compilation proper; do not assemble.
9746  The output is an assembler code file for the input file specified.
9747 \end_layout
9748
9749 \begin_layout List
9750 \labelwidthstring 00.00.0000
9751
9752 \series bold
9753 -
9754 \begin_inset ERT
9755 status collapsed
9756
9757 \begin_layout Standard
9758
9759
9760 \backslash
9761 /
9762 \end_layout
9763
9764 \end_inset
9765
9766 -int-long-reent
9767 \begin_inset LatexCommand \index{-\/-int-long-reent}
9768
9769 \end_inset
9770
9771
9772 \series default
9773  Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
9774  Note by default these libraries are compiled as non-reentrant.
9775  See section Installation for more details.
9776 \end_layout
9777
9778 \begin_layout List
9779 \labelwidthstring 00.00.0000
9780
9781 \series bold
9782 -
9783 \begin_inset ERT
9784 status collapsed
9785
9786 \begin_layout Standard
9787
9788
9789 \backslash
9790 /
9791 \end_layout
9792
9793 \end_inset
9794
9795 -cyclomatic
9796 \begin_inset LatexCommand \index{-\/-cyclomatic}
9797
9798 \end_inset
9799
9800
9801 \series default
9802 This option will cause the compiler to generate an information message for
9803  each function in the source file.
9804  The message contains some
9805 \emph on
9806 important
9807 \emph default
9808  information about the function.
9809  The number of edges and nodes the compiler detected in the control flow
9810  graph of the function, and most importantly the
9811 \emph on
9812 cyclomatic complexity
9813 \begin_inset LatexCommand \index{Cyclomatic complexity}
9814
9815 \end_inset
9816
9817
9818 \emph default
9819  see section on Cyclomatic Complexity for more details.
9820 \end_layout
9821
9822 \begin_layout List
9823 \labelwidthstring 00.00.0000
9824
9825 \series bold
9826 -
9827 \begin_inset ERT
9828 status collapsed
9829
9830 \begin_layout Standard
9831
9832
9833 \backslash
9834 /
9835 \end_layout
9836
9837 \end_inset
9838
9839 -float-reent
9840 \begin_inset LatexCommand \index{-\/-float-reent}
9841
9842 \end_inset
9843
9844
9845 \series default
9846  Floating point library is compiled as reentrant
9847 \begin_inset LatexCommand \index{reentrant}
9848
9849 \end_inset
9850
9851 .
9852  See section Installation for more details.
9853 \end_layout
9854
9855 \begin_layout List
9856 \labelwidthstring 00.00.0000
9857
9858 \series bold
9859 -
9860 \begin_inset ERT
9861 status collapsed
9862
9863 \begin_layout Standard
9864
9865
9866 \backslash
9867 /
9868 \end_layout
9869
9870 \end_inset
9871
9872 -funsigned-char
9873 \begin_inset LatexCommand \index{-\/-funsigned-char}
9874
9875 \end_inset
9876
9877
9878 \series default
9879  The default signedness for every type is
9880 \family typewriter
9881  signed
9882 \family default
9883 .
9884  In some embedded environments the default signedness of
9885 \family typewriter
9886  char
9887 \family default
9888  is
9889 \family typewriter
9890  unsigned
9891 \family default
9892 .
9893  To set the signess for characters to unsigned, use the option -
9894 \series bold
9895
9896 \begin_inset ERT
9897 status open
9898
9899 \begin_layout Standard
9900
9901
9902 \backslash
9903 /
9904 \end_layout
9905
9906 \end_inset
9907
9908
9909 \series default
9910 -funsigned-char.
9911  If this option is set and no signedness keyword (unsigned/signed) is given,
9912  a char will be signed.
9913  All other types are unaffected.
9914 \end_layout
9915
9916 \begin_layout List
9917 \labelwidthstring 00.00.0000
9918
9919 \series bold
9920 -
9921 \begin_inset ERT
9922 status collapsed
9923
9924 \begin_layout Standard
9925
9926
9927 \backslash
9928 /
9929 \end_layout
9930
9931 \end_inset
9932
9933 -main-return
9934 \begin_inset LatexCommand \index{-\/-main-return}
9935
9936 \end_inset
9937
9938
9939 \series default
9940  This option can be used if the code generated is called by a monitor program
9941  or if the main routine includes an endless loop.
9942  This option results in slightly smaller code and saves two bytes of stack
9943  space.
9944  The return from the 'main'
9945 \begin_inset LatexCommand \index{main return}
9946
9947 \end_inset
9948
9949  function will return to the function calling main.
9950  The default setting is to lock up i.e.
9951  generate a '
9952 \family typewriter
9953 sjmp .
9954 \family default
9955 '.
9956 \end_layout
9957
9958 \begin_layout List
9959 \labelwidthstring 00.00.0000
9960
9961 \series bold
9962 -
9963 \begin_inset ERT
9964 status collapsed
9965
9966 \begin_layout Standard
9967
9968
9969 \backslash
9970 /
9971 \end_layout
9972
9973 \end_inset
9974
9975 -nostdinc
9976 \begin_inset LatexCommand \index{-\/-nostdinc}
9977
9978 \end_inset
9979
9980
9981 \series default
9982  This will prevent the compiler from passing on the default include path
9983  to the preprocessor.
9984 \end_layout
9985
9986 \begin_layout List
9987 \labelwidthstring 00.00.0000
9988
9989 \series bold
9990 -
9991 \begin_inset ERT
9992 status collapsed
9993
9994 \begin_layout Standard
9995
9996
9997 \backslash
9998 /
9999 \end_layout
10000
10001 \end_inset
10002
10003 -nostdlib
10004 \begin_inset LatexCommand \index{-\/-nostdlib}
10005
10006 \end_inset
10007
10008
10009 \series default
10010  This will prevent the compiler from passing on the default library
10011 \begin_inset LatexCommand \index{Libraries}
10012
10013 \end_inset
10014
10015  path to the linker.
10016 \end_layout
10017
10018 \begin_layout List
10019 \labelwidthstring 00.00.0000
10020
10021 \series bold
10022 -
10023 \begin_inset ERT
10024 status collapsed
10025
10026 \begin_layout Standard
10027
10028
10029 \backslash
10030 /
10031 \end_layout
10032
10033 \end_inset
10034
10035 -verbose
10036 \begin_inset LatexCommand \index{-\/-verbose}
10037
10038 \end_inset
10039
10040
10041 \series default
10042  Shows the various actions the compiler is performing.
10043 \end_layout
10044
10045 \begin_layout List
10046 \labelwidthstring 00.00.0000
10047
10048 \series bold
10049 -V
10050 \begin_inset LatexCommand \index{-V}
10051
10052 \end_inset
10053
10054
10055 \series default
10056  Shows the actual commands the compiler is executing.
10057 \end_layout
10058
10059 \begin_layout List
10060 \labelwidthstring 00.00.0000
10061
10062 \series bold
10063 -
10064 \begin_inset ERT
10065 status collapsed
10066
10067 \begin_layout Standard
10068
10069
10070 \backslash
10071 /
10072 \end_layout
10073
10074 \end_inset
10075
10076 -no-c-code-in-asm
10077 \begin_inset LatexCommand \index{-\/-no-c-code-in-asm}
10078
10079 \end_inset
10080
10081
10082 \series default
10083  Hides your ugly and inefficient c-code from the asm file, so you can always
10084  blame the compiler :)
10085 \end_layout
10086
10087 \begin_layout List
10088 \labelwidthstring 00.00.0000
10089
10090 \series bold
10091 -
10092 \begin_inset ERT
10093 status collapsed
10094
10095 \begin_layout Standard
10096
10097
10098 \backslash
10099 /
10100 \end_layout
10101
10102 \end_inset
10103
10104 -fverbose-asm
10105 \begin_inset LatexCommand \index{-\/-no-gen-comments}
10106
10107 \end_inset
10108
10109
10110 \series default
10111  Include code generator and peep-hole comments in the generated asm files.
10112 \end_layout
10113
10114 \begin_layout List
10115 \labelwidthstring 00.00.0000
10116
10117 \series bold
10118 -
10119 \begin_inset ERT
10120 status collapsed
10121
10122 \begin_layout Standard
10123
10124
10125 \backslash
10126 /
10127 \end_layout
10128
10129 \end_inset
10130
10131 -no-peep-comments
10132 \begin_inset LatexCommand \index{-\/-no-peep-comments}
10133
10134 \end_inset
10135
10136
10137 \series default
10138  Don't include peep-hole comments in the generated asm files even if -
10139 \series bold
10140
10141 \begin_inset ERT
10142 status open
10143
10144 \begin_layout Standard
10145
10146
10147 \backslash
10148 /
10149 \end_layout
10150
10151 \end_inset
10152
10153
10154 \series default
10155 -fverbose-asm option is specified.
10156 \end_layout
10157
10158 \begin_layout List
10159 \labelwidthstring 00.00.0000
10160
10161 \series bold
10162 -
10163 \begin_inset ERT
10164 status collapsed
10165
10166 \begin_layout Standard
10167
10168
10169 \backslash
10170 /
10171 \end_layout
10172
10173 \end_inset
10174
10175 -i-code-in-asm
10176 \begin_inset LatexCommand \index{-\/-i-code-in-asm}
10177
10178 \end_inset
10179
10180
10181 \series default
10182  Include i-codes in the asm file.
10183  Sounds like noise but is most helpful for debugging the compiler itself.
10184 \end_layout
10185
10186 \begin_layout List
10187 \labelwidthstring 00.00.0000
10188
10189 \series bold
10190 -
10191 \begin_inset ERT
10192 status collapsed
10193
10194 \begin_layout Standard
10195
10196
10197 \backslash
10198 /
10199 \end_layout
10200
10201 \end_inset
10202
10203 -less-pedantic
10204 \begin_inset LatexCommand \index{pedantic}
10205
10206 \end_inset
10207
10208
10209 \begin_inset LatexCommand \index{-\/-less-pedantic}
10210
10211 \end_inset
10212
10213
10214 \series default
10215
10216 \begin_inset LatexCommand \label{lyx:--less-pedantic}
10217
10218 \end_inset
10219
10220  Disable some of the more pedantic warnings
10221 \begin_inset LatexCommand \index{Warnings}
10222
10223 \end_inset
10224
10225 .
10226  For more details, see the less_pedantic pragma
10227 \begin_inset LatexCommand \vpageref{ite:less_pedantic}
10228
10229 \end_inset
10230
10231 .
10232 \end_layout
10233
10234 \begin_layout List
10235 \labelwidthstring 00.00.0000
10236
10237 \series bold
10238 -
10239 \begin_inset ERT
10240 status collapsed
10241
10242 \begin_layout Standard
10243
10244
10245 \backslash
10246 /
10247 \end_layout
10248
10249 \end_inset
10250
10251 -disable-warning\InsetSpace ~
10252 <nnnn>
10253 \begin_inset LatexCommand \index{-\/-disable-warning}
10254
10255 \end_inset
10256
10257
10258 \series default
10259  Disable specific warning with number <nnnn>.
10260 \end_layout
10261
10262 \begin_layout List
10263 \labelwidthstring 00.00.0000
10264
10265 \series bold
10266 -
10267 \begin_inset ERT
10268 status collapsed
10269
10270 \begin_layout Standard
10271
10272
10273 \backslash
10274 /
10275 \end_layout
10276
10277 \end_inset
10278
10279 -Werror
10280 \begin_inset LatexCommand \index{-\/-Werror}
10281
10282 \end_inset
10283
10284
10285 \series default
10286  Treat all warnings as errors.
10287 \end_layout
10288
10289 \begin_layout List
10290 \labelwidthstring 00.00.0000
10291
10292 \series bold
10293 -
10294 \begin_inset ERT
10295 status collapsed
10296
10297 \begin_layout Standard
10298
10299
10300 \backslash
10301 /
10302 \end_layout
10303
10304 \end_inset
10305
10306 -print-search-dirs
10307 \begin_inset LatexCommand \index{-\/-print-search-dirs}
10308
10309 \end_inset
10310
10311
10312 \series default
10313  Display the directories in the compiler's search path
10314 \end_layout
10315
10316 \begin_layout List
10317 \labelwidthstring 00.00.0000
10318
10319 \series bold
10320 -
10321 \begin_inset ERT
10322 status collapsed
10323
10324 \begin_layout Standard
10325
10326
10327 \backslash
10328 /
10329 \end_layout
10330
10331 \end_inset
10332
10333 -vc
10334 \begin_inset LatexCommand \index{-\/-vc}
10335
10336 \end_inset
10337
10338
10339 \series default
10340  Display errors and warnings using MSVC style, so you can use SDCC with
10341  the visual studio IDE
10342 \begin_inset LatexCommand \index{IDE}
10343
10344 \end_inset
10345
10346 .
10347  With SDCC both offering a GCC-like (the default) and a MSVC-like
10348 \begin_inset LatexCommand \index{MSVC output style}
10349
10350 \end_inset
10351
10352  output style, integration into most programming editors should be straightforwa
10353 rd.
10354 \end_layout
10355
10356 \begin_layout List
10357 \labelwidthstring 00.00.0000
10358
10359 \series bold
10360 -
10361 \begin_inset ERT
10362 status collapsed
10363
10364 \begin_layout Standard
10365
10366
10367 \backslash
10368 /
10369 \end_layout
10370
10371 \end_inset
10372
10373 -use-stdout
10374 \begin_inset LatexCommand \index{-\/-use-stdout}
10375
10376 \end_inset
10377
10378
10379 \series default
10380  Send errors and warnings to stdout instead of stderr.
10381 \end_layout
10382
10383 \begin_layout List
10384 \labelwidthstring 00.00.0000
10385
10386 \series bold
10387 -Wa\InsetSpace ~
10388 asmOption[,asmOption]
10389 \series default
10390
10391 \begin_inset LatexCommand \index{-Wa asmOption[,asmOption]}
10392
10393 \end_inset
10394
10395 ...
10396  Pass the asmOption to the assembler
10397 \begin_inset LatexCommand \index{Options assembler}
10398
10399 \end_inset
10400
10401
10402 \begin_inset LatexCommand \index{Assembler options}
10403
10404 \end_inset
10405
10406 .
10407  See file sdcc/as/doc/asxhtm.html for assembler options.cd
10408 \end_layout
10409
10410 \begin_layout List
10411 \labelwidthstring 00.00.0000
10412
10413 \series bold
10414 -
10415 \begin_inset ERT
10416 status collapsed
10417
10418 \begin_layout Standard
10419
10420
10421 \backslash
10422 /
10423 \end_layout
10424
10425 \end_inset
10426
10427 -std-sdcc89
10428 \begin_inset LatexCommand \index{-\/-std-sdcc89}
10429
10430 \end_inset
10431
10432
10433 \series default
10434  Generally follow the C89 standard, but allow SDCC features that conflict
10435  with the standard (default).
10436 \end_layout
10437
10438 \begin_layout List
10439 \labelwidthstring 00.00.0000
10440
10441 \series bold
10442 -
10443 \begin_inset ERT
10444 status collapsed
10445
10446 \begin_layout Standard
10447
10448
10449 \backslash
10450 /
10451 \end_layout
10452
10453 \end_inset
10454
10455 -std-c89
10456 \begin_inset LatexCommand \index{-\/-std-c89}
10457
10458 \end_inset
10459
10460
10461 \series default
10462  Follow the C89 standard and disable SDCC features that conflict with the
10463  standard.
10464 \end_layout
10465
10466 \begin_layout List
10467 \labelwidthstring 00.00.0000
10468
10469 \series bold
10470 -
10471 \begin_inset ERT
10472 status collapsed
10473
10474 \begin_layout Standard
10475
10476
10477 \backslash
10478 /
10479 \end_layout
10480
10481 \end_inset
10482
10483 -std-sdcc99
10484 \begin_inset LatexCommand \index{-\/-std-sdcc99}
10485
10486 \end_inset
10487
10488
10489 \series default
10490  Generally follow the C99 standard, but allow SDCC features that conflict
10491  with the standard (incomplete support).
10492 \end_layout
10493
10494 \begin_layout List
10495 \labelwidthstring 00.00.0000
10496
10497 \series bold
10498 -
10499 \begin_inset ERT
10500 status collapsed
10501
10502 \begin_layout Standard
10503
10504
10505 \backslash
10506 /
10507 \end_layout
10508
10509 \end_inset
10510
10511 -std-c99
10512 \begin_inset LatexCommand \index{-\/-std-sdcc99}
10513
10514 \end_inset
10515
10516
10517 \series default
10518  Follow the C99 standard and disable SDCC features that conflict with the
10519  standard (incomplete support).
10520 \end_layout
10521
10522 \begin_layout List
10523 \labelwidthstring 00.00.0000
10524
10525 \series bold
10526 -
10527 \begin_inset ERT
10528 status collapsed
10529
10530 \begin_layout Standard
10531
10532
10533 \backslash
10534 /
10535 \end_layout
10536
10537 \end_inset
10538
10539 -codeseg
10540 \series default
10541
10542 \begin_inset LatexCommand \index{-\/-codeseg <Value>}
10543
10544 \end_inset
10545
10546 \InsetSpace ~
10547 <Name> The name to be used for the code
10548 \begin_inset LatexCommand \index{code}
10549
10550 \end_inset
10551
10552  segment, default CSEG.
10553  This is useful if you need to tell the compiler to put the code in a special
10554  segment so you can later on tell the linker to put this segment in a special
10555  place in memory.
10556  Can be used for instance when using bank switching to put the code in a
10557  bank.
10558 \end_layout
10559
10560 \begin_layout List
10561 \labelwidthstring 00.00.0000
10562
10563 \series bold
10564 -
10565 \begin_inset ERT
10566 status collapsed
10567
10568 \begin_layout Standard
10569
10570
10571 \backslash
10572 /
10573 \end_layout
10574
10575 \end_inset
10576
10577 -constseg
10578 \series default
10579
10580 \begin_inset LatexCommand \index{-\/-constseg <Value>}
10581
10582 \end_inset
10583
10584 \InsetSpace ~
10585 <Name> The name to be used for the const
10586 \begin_inset LatexCommand \index{const}
10587
10588 \end_inset
10589
10590  segment, default CONST.
10591  This is useful if you need to tell the compiler to put the const data in
10592  a special segment so you can later on tell the linker to put this segment
10593  in a special place in memory.
10594  Can be used for instance when using bank switching to put the const data
10595  in a bank.
10596 \end_layout
10597
10598 \begin_layout List
10599 \labelwidthstring 00.00.0000
10600
10601 \series bold
10602 -
10603 \begin_inset ERT
10604 status collapsed
10605
10606 \begin_layout Standard
10607
10608
10609 \backslash
10610 /
10611 \end_layout
10612
10613 \end_inset
10614
10615 -fdollars-in-identifiers
10616 \begin_inset LatexCommand \index{-\/-fdollars-in-identifiers}
10617
10618 \end_inset
10619
10620
10621 \series default
10622  Permit '$' as an identifier character.
10623 \end_layout
10624
10625 \begin_layout List
10626 \labelwidthstring 00.00.0000
10627
10628 \series bold
10629 -
10630 \begin_inset ERT
10631 status collapsed
10632
10633 \begin_layout Standard
10634
10635
10636 \backslash
10637 /
10638 \end_layout
10639
10640 \end_inset
10641
10642 -more-pedantic
10643 \series default
10644
10645 \begin_inset LatexCommand \index{-\/-more-pedantic}
10646
10647 \end_inset
10648
10649
10650 \begin_inset LatexCommand \index{pedantic}
10651
10652 \end_inset
10653
10654  Actually this is
10655 \series bold
10656 \emph on
10657 not
10658 \series default
10659 \emph default
10660  a SDCC compiler option but if you want
10661 \emph on
10662 more
10663 \emph default
10664  warnings you can use a separate tool dedicated to syntax checking like
10665  splint
10666 \begin_inset LatexCommand \label{lyx:more-pedantic-SPLINT}
10667
10668 \end_inset
10669
10670
10671 \begin_inset LatexCommand \index{lint (syntax checking tool)}
10672
10673 \end_inset
10674
10675
10676 \begin_inset LatexCommand \url{http://www.splint.org}
10677
10678 \end_inset
10679
10680 .
10681  To make your source files parseable by splint you will have to include
10682 \family sans
10683 lint.h
10684 \family default
10685
10686 \begin_inset LatexCommand \index{splint (syntax checking tool)}
10687
10688 \end_inset
10689
10690  in your source file and add brackets around extended keywords (like
10691 \family sans
10692
10693 \begin_inset Quotes sld
10694 \end_inset
10695
10696 __at\InsetSpace ~
10697
10698 \series bold
10699 (
10700 \series default
10701 0xab
10702 \series bold
10703 )
10704 \series default
10705
10706 \begin_inset Quotes srd
10707 \end_inset
10708
10709
10710 \family default
10711  and
10712 \family sans
10713
10714 \begin_inset Quotes sld
10715 \end_inset
10716
10717 __interrupt\InsetSpace ~
10718 (2)
10719 \begin_inset Quotes srd
10720 \end_inset
10721
10722
10723 \family default
10724 ).
10725 \newline
10726 Splint has an excellent on line manual at
10727 \begin_inset LatexCommand \url{http://www.splint.org/manual/}
10728
10729 \end_inset
10730
10731  and it's capabilities go beyond pure syntax checking.
10732  You'll need to tell splint the location of SDCC's include files so a typical
10733  command line could look like this:
10734 \newline
10735
10736 \family sans
10737 splint\InsetSpace ~
10738 -I\InsetSpace ~
10739 /usr/local/share/sdcc/include/mcs51/\InsetSpace ~
10740 \InsetSpace ~
10741 myprogram.c
10742 \end_layout
10743
10744 \begin_layout List
10745 \labelwidthstring 00.00.0000
10746
10747 \series bold
10748 -
10749 \begin_inset ERT
10750 status collapsed
10751
10752 \begin_layout Standard
10753
10754
10755 \backslash
10756 /
10757 \end_layout
10758
10759 \end_inset
10760
10761 -short-is-8bits
10762 \series default
10763
10764 \begin_inset LatexCommand \index{-\/-short-is-8bits}
10765
10766 \end_inset
10767
10768
10769 \begin_inset LatexCommand \label{lyx:--short-is-8bits}
10770
10771 \end_inset
10772
10773  Treat short as 8-bit (for backward compatibility with older versions of
10774  compiler - see section
10775 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
10776
10777 \end_inset
10778
10779 )
10780 \end_layout
10781
10782 \begin_layout Standard
10783 \begin_inset VSpace bigskip
10784 \end_inset
10785
10786
10787 \end_layout
10788
10789 \begin_layout Subsection
10790 Intermediate Dump Options
10791 \begin_inset LatexCommand \label{sub:Intermediate-Dump-Options}
10792
10793 \end_inset
10794
10795
10796 \begin_inset LatexCommand \index{Options intermediate dump}
10797
10798 \end_inset
10799
10800
10801 \begin_inset LatexCommand \index{Intermediate dump options}
10802
10803 \end_inset
10804
10805
10806 \end_layout
10807
10808 \begin_layout Standard
10809 The following options are provided for the purpose of retargetting and debugging
10810  the compiler.
10811  They provide a means to dump the intermediate code (iCode
10812 \begin_inset LatexCommand \index{iCode}
10813
10814 \end_inset
10815
10816 ) generated by the compiler in human readable form at various stages of
10817  the compilation process.
10818  More on iCodes see chapter
10819 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
10820
10821 \end_inset
10822
10823
10824 \begin_inset Quotes srd
10825 \end_inset
10826
10827 The anatomy of the compiler
10828 \begin_inset Quotes srd
10829 \end_inset
10830
10831 .
10832 \end_layout
10833
10834 \begin_layout List
10835 \labelwidthstring 00.00.0000
10836
10837 \series bold
10838 -
10839 \begin_inset ERT
10840 status collapsed
10841
10842 \begin_layout Standard
10843
10844
10845 \backslash
10846 /
10847 \end_layout
10848
10849 \end_inset
10850
10851 -dumpraw
10852 \begin_inset LatexCommand \index{-\/-dumpraw}
10853
10854 \end_inset
10855
10856
10857 \series default
10858  This option will cause the compiler to dump the intermediate code into
10859  a file of named
10860 \emph on
10861 <source filename>.dumpraw
10862 \emph default
10863  just after the intermediate code has been generated for a function, i.e.
10864  before any optimizations are done.
10865  The basic blocks
10866 \begin_inset LatexCommand \index{Basic blocks}
10867
10868 \end_inset
10869
10870  at this stage ordered in the depth first number, so they may not be in
10871  sequence of execution.
10872 \end_layout
10873
10874 \begin_layout List
10875 \labelwidthstring 00.00.0000
10876
10877 \series bold
10878 -
10879 \begin_inset ERT
10880 status collapsed
10881
10882 \begin_layout Standard
10883
10884
10885 \backslash
10886 /
10887 \end_layout
10888
10889 \end_inset
10890
10891 -dumpgcse
10892 \begin_inset LatexCommand \index{-\/-dumpgcse}
10893
10894 \end_inset
10895
10896
10897 \series default
10898  Will create a dump of iCodes, after global subexpression elimination
10899 \begin_inset LatexCommand \index{Global subexpression elimination}
10900
10901 \end_inset
10902
10903 , into a file named
10904 \emph on
10905 <source filename>.dumpgcse.
10906 \end_layout
10907
10908 \begin_layout List
10909 \labelwidthstring 00.00.0000
10910
10911 \series bold
10912 -
10913 \begin_inset ERT
10914 status collapsed
10915
10916 \begin_layout Standard
10917
10918
10919 \backslash
10920 /
10921 \end_layout
10922
10923 \end_inset
10924
10925 -dumpdeadcode
10926 \begin_inset LatexCommand \index{-\/-dumpdeadcode}
10927
10928 \end_inset
10929
10930
10931 \series default
10932  Will create a dump of iCodes, after deadcode elimination
10933 \begin_inset LatexCommand \index{Dead-code elimination}
10934
10935 \end_inset
10936
10937 , into a file named
10938 \emph on
10939 <source filename>.dumpdeadcode.
10940 \end_layout
10941
10942 \begin_layout List
10943 \labelwidthstring 00.00.0000
10944
10945 \series bold
10946 -
10947 \begin_inset ERT
10948 status collapsed
10949
10950 \begin_layout Standard
10951
10952
10953 \backslash
10954 /
10955 \end_layout
10956
10957 \end_inset
10958
10959 -dumploop
10960 \begin_inset LatexCommand \index{-\/-dumploop}
10961
10962 \end_inset
10963
10964
10965 \series default
10966 Will create a dump of iCodes, after loop optimizations
10967 \begin_inset LatexCommand \index{Loop optimization}
10968
10969 \end_inset
10970
10971 , into a file named
10972 \emph on
10973 <source filename>.dumploop.
10974 \end_layout
10975
10976 \begin_layout List
10977 \labelwidthstring 00.00.0000
10978
10979 \series bold
10980 -
10981 \begin_inset ERT
10982 status collapsed
10983
10984 \begin_layout Standard
10985
10986
10987 \backslash
10988 /
10989 \end_layout
10990
10991 \end_inset
10992
10993 -dumprange
10994 \begin_inset LatexCommand \index{-\/-dumprange}
10995
10996 \end_inset
10997
10998
10999 \series default
11000 Will create a dump of iCodes, after live range analysis
11001 \begin_inset LatexCommand \index{Live range analysis}
11002
11003 \end_inset
11004
11005 , into a file named
11006 \emph on
11007 <source filename>.dumprange.
11008 \end_layout
11009
11010 \begin_layout List
11011 \labelwidthstring 00.00.0000
11012
11013 \series bold
11014 -
11015 \begin_inset ERT
11016 status collapsed
11017
11018 \begin_layout Standard
11019
11020
11021 \backslash
11022 /
11023 \end_layout
11024
11025 \end_inset
11026
11027 -dumlrange
11028 \begin_inset LatexCommand \index{-\/-dumlrange}
11029
11030 \end_inset
11031
11032
11033 \series default
11034  Will dump the life ranges
11035 \begin_inset LatexCommand \index{Live range analysis}
11036
11037 \end_inset
11038
11039  for all symbols.
11040 \end_layout
11041
11042 \begin_layout List
11043 \labelwidthstring 00.00.0000
11044
11045 \series bold
11046 -
11047 \begin_inset ERT
11048 status collapsed
11049
11050 \begin_layout Standard
11051
11052
11053 \backslash
11054 /
11055 \end_layout
11056
11057 \end_inset
11058
11059 -dumpregassign
11060 \begin_inset LatexCommand \index{-\/-dumpregassign}
11061
11062 \end_inset
11063
11064
11065 \series default
11066 Will create a dump of iCodes, after register assignment
11067 \begin_inset LatexCommand \index{Register assignment}
11068
11069 \end_inset
11070
11071 , into a file named
11072 \emph on
11073 <source filename>.dumprassgn.
11074 \end_layout
11075
11076 \begin_layout List
11077 \labelwidthstring 00.00.0000
11078
11079 \series bold
11080 -
11081 \begin_inset ERT
11082 status collapsed
11083
11084 \begin_layout Standard
11085
11086
11087 \backslash
11088 /
11089 \end_layout
11090
11091 \end_inset
11092
11093 -dumplrange
11094 \begin_inset LatexCommand \index{-\/-dumplrange}
11095
11096 \end_inset
11097
11098
11099 \series default
11100  Will create a dump of the live ranges of iTemp's
11101 \end_layout
11102
11103 \begin_layout List
11104 \labelwidthstring 00.00.0000
11105
11106 \series bold
11107 -
11108 \begin_inset ERT
11109 status collapsed
11110
11111 \begin_layout Standard
11112
11113
11114 \backslash
11115 /
11116 \end_layout
11117
11118 \end_inset
11119
11120 -dumpall
11121 \begin_inset LatexCommand \index{-\/-dumpall}
11122
11123 \end_inset
11124
11125
11126 \series default
11127 Will cause all the above mentioned dumps to be created.
11128 \end_layout
11129
11130 \begin_layout Standard
11131 \begin_inset VSpace bigskip
11132 \end_inset
11133
11134
11135 \end_layout
11136
11137 \begin_layout Subsection
11138 Redirecting output on Windows Shells
11139 \end_layout
11140
11141 \begin_layout Standard
11142 By default SDCC writes its error messages to
11143 \begin_inset Quotes sld
11144 \end_inset
11145
11146 standard error
11147 \begin_inset Quotes srd
11148 \end_inset
11149
11150 .
11151  To force all messages to
11152 \begin_inset Quotes sld
11153 \end_inset
11154
11155 standard output
11156 \begin_inset Quotes srd
11157 \end_inset
11158
11159  use
11160 \series bold
11161 -
11162 \series default
11163 \emph on
11164
11165 \begin_inset ERT
11166 status collapsed
11167
11168 \begin_layout Standard
11169
11170
11171 \backslash
11172 /
11173 \end_layout
11174
11175 \end_inset
11176
11177
11178 \series bold
11179 \emph default
11180 -
11181 \series default
11182 use-stdout
11183 \begin_inset LatexCommand \index{-\/-use-stdout}
11184
11185 \end_inset
11186
11187 .
11188  Additionally, if you happen to have visual studio installed in your windows
11189  machine, you can use it to compile your sources using a custom build and
11190  the SDCC -
11191 \emph on
11192
11193 \begin_inset ERT
11194 status collapsed
11195
11196 \begin_layout Standard
11197
11198
11199 \backslash
11200 /
11201 \end_layout
11202
11203 \end_inset
11204
11205
11206 \emph default
11207 -vc
11208 \begin_inset LatexCommand \index{-\/-vc}
11209
11210 \end_inset
11211
11212  option.
11213  Something like this should work:
11214 \newline
11215
11216 \newline
11217
11218 \series bold
11219 c:
11220 \backslash
11221 sdcc
11222 \backslash
11223 bin
11224 \backslash
11225 sdcc.exe -
11226 \series default
11227 \emph on
11228
11229 \begin_inset ERT
11230 status collapsed
11231
11232 \begin_layout Standard
11233
11234
11235 \backslash
11236 /
11237 \end_layout
11238
11239 \end_inset
11240
11241
11242 \series bold
11243 \emph default
11244 -vc -
11245 \series default
11246 \emph on
11247
11248 \begin_inset ERT
11249 status collapsed
11250
11251 \begin_layout Standard
11252
11253
11254 \backslash
11255 /
11256 \end_layout
11257
11258 \end_inset
11259
11260
11261 \series bold
11262 \emph default
11263 -model-large -c $(InputPath)
11264 \series default
11265
11266 \begin_inset VSpace bigskip
11267 \end_inset
11268
11269
11270 \end_layout
11271
11272 \begin_layout Section
11273 Environment variables
11274 \begin_inset LatexCommand \index{Environment variables}
11275
11276 \end_inset
11277
11278
11279 \end_layout
11280
11281 \begin_layout Standard
11282 SDCC recognizes the following environment variables:
11283 \end_layout
11284
11285 \begin_layout List
11286 \labelwidthstring 00.00.0000
11287
11288 \series bold
11289 SDCC_LEAVE_SIGNALS
11290 \begin_inset LatexCommand \index{SDCC\_LEAVE\_SIGNALS}
11291
11292 \end_inset
11293
11294
11295 \series default
11296  SDCC installs a signal handler
11297 \begin_inset LatexCommand \index{signal handler}
11298
11299 \end_inset
11300
11301  to be able to delete temporary files after an user break (^C) or an exception.
11302  If this environment variable is set, SDCC won't install the signal handler
11303  in order to be able to debug SDCC.
11304 \end_layout
11305
11306 \begin_layout List
11307 \labelwidthstring 00.00.0000
11308
11309 \series bold
11310 TMP,\InsetSpace ~
11311 TEMP,\InsetSpace ~
11312 TMPDIR
11313 \begin_inset LatexCommand \index{TMP, TEMP, TMPDIR}
11314
11315 \end_inset
11316
11317
11318 \series default
11319  Path, where temporary files will be created.
11320  The order of the variables is the search order.
11321  In a standard *nix environment these variables are not set, and there's
11322  no need to set them.
11323  On Windows it's recommended to set one of them.
11324 \end_layout
11325
11326 \begin_layout List
11327 \labelwidthstring 00.00.0000
11328
11329 \series bold
11330 SDCC_HOME
11331 \begin_inset LatexCommand \index{SDCC\_HOME}
11332
11333 \end_inset
11334
11335
11336 \series default
11337  Path, see section
11338 \begin_inset LatexCommand \ref{sub:Install-paths}
11339
11340 \end_inset
11341
11342 \InsetSpace ~
11343
11344 \begin_inset Quotes sld
11345 \end_inset
11346
11347  Install Paths
11348 \begin_inset Quotes srd
11349 \end_inset
11350
11351 .
11352 \end_layout
11353
11354 \begin_layout List
11355 \labelwidthstring 00.00.0000
11356
11357 \series bold
11358 SDCC_INCLUDE
11359 \begin_inset LatexCommand \index{SDCC\_INCLUDE}
11360
11361 \end_inset
11362
11363
11364 \series default
11365  Path, see section
11366 \begin_inset LatexCommand \ref{sub:Search-Paths}
11367
11368 \end_inset
11369
11370 \InsetSpace ~
11371
11372 \begin_inset Quotes sld
11373 \end_inset
11374
11375 Search Paths
11376 \begin_inset Quotes srd
11377 \end_inset
11378
11379 .
11380 \end_layout
11381
11382 \begin_layout List
11383 \labelwidthstring 00.00.0000
11384
11385 \series bold
11386 SDCC_LIB
11387 \begin_inset LatexCommand \index{SDCC\_LIB}
11388
11389 \end_inset
11390
11391
11392 \series default
11393  Path, see section
11394 \begin_inset LatexCommand \ref{sub:Search-Paths}
11395
11396 \end_inset
11397
11398 \InsetSpace ~
11399
11400 \begin_inset Quotes sld
11401 \end_inset
11402
11403 Search Paths
11404 \begin_inset Quotes srd
11405 \end_inset
11406
11407 ..
11408 \end_layout
11409
11410 \begin_layout Standard
11411 There are some more environment variables recognized by SDCC, but these
11412  are solely used for debugging purposes.
11413  They can change or disappear very quickly, and will never be documented.
11414 \begin_inset VSpace bigskip
11415 \end_inset
11416
11417
11418 \end_layout
11419
11420 \begin_layout Section
11421 Storage Class Language Extensions
11422 \end_layout
11423
11424 \begin_layout Subsection
11425 MCS51/DS390 Storage Class
11426 \begin_inset LatexCommand \index{Storage class}
11427
11428 \end_inset
11429
11430  Language Extensions
11431 \end_layout
11432
11433 \begin_layout Standard
11434 In addition to the ANSI storage classes SDCC allows the following MCS51
11435  specific storage classes:
11436 \end_layout
11437
11438 \begin_layout Subsubsection
11439 data
11440 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
11441
11442 \end_inset
11443
11444
11445 \begin_inset LatexCommand \index{\_\_data (mcs51, ds390 storage class)}
11446
11447 \end_inset
11448
11449  / near
11450 \begin_inset LatexCommand \index{near (storage class)}
11451
11452 \end_inset
11453
11454
11455 \begin_inset LatexCommand \index{\_\_near (storage class)}
11456
11457 \end_inset
11458
11459
11460 \end_layout
11461
11462 \begin_layout Standard
11463 This is the
11464 \series bold
11465 default
11466 \series default
11467  storage class for the Small Memory model (
11468 \emph on
11469 data
11470 \emph default
11471  and
11472 \emph on
11473 near
11474 \emph default
11475  or the more ANSI-C compliant forms
11476 \emph on
11477 __data
11478 \emph default
11479  and
11480 \emph on
11481 __near
11482 \emph default
11483  can be used synonymously).
11484  Variables declared with this storage class will be allocated in the directly
11485  addressable portion of the internal RAM of a 8051, e.g.:
11486 \end_layout
11487
11488 \begin_layout Verse
11489
11490 \family typewriter
11491 __data unsigned char test_data;
11492 \end_layout
11493
11494 \begin_layout Standard
11495 Writing 0x01 to this variable generates the assembly code:
11496 \end_layout
11497
11498 \begin_layout Verse
11499
11500 \family typewriter
11501 75*00 01\InsetSpace ~
11502 \InsetSpace ~
11503 \InsetSpace ~
11504 mov\InsetSpace ~
11505 \InsetSpace ~
11506 _test_data,#0x01
11507 \end_layout
11508
11509 \begin_layout Subsubsection
11510 xdata
11511 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
11512
11513 \end_inset
11514
11515
11516 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
11517
11518 \end_inset
11519
11520  / far
11521 \begin_inset LatexCommand \index{far (storage class)}
11522
11523 \end_inset
11524
11525
11526 \begin_inset LatexCommand \index{\_\_far (storage class)}
11527
11528 \end_inset
11529
11530
11531 \end_layout
11532
11533 \begin_layout Standard
11534 Variables declared with this storage class will be placed in the external
11535  RAM.
11536  This is the
11537 \series bold
11538 default
11539 \series default
11540  storage class for the Large Memory model, e.g.:
11541 \end_layout
11542
11543 \begin_layout Verse
11544
11545 \family typewriter
11546 __xdata unsigned char test_xdata;
11547 \end_layout
11548
11549 \begin_layout Standard
11550 Writing 0x01 to this variable generates the assembly code:
11551 \end_layout
11552
11553 \begin_layout Verse
11554
11555 \family typewriter
11556 90s00r00\InsetSpace ~
11557 \InsetSpace ~
11558 \InsetSpace ~
11559 mov\InsetSpace ~
11560 \InsetSpace ~
11561 dptr,#_test_xdata
11562 \newline
11563 74\InsetSpace ~
11564 01\InsetSpace ~
11565 \InsetSpace ~
11566 \InsetSpace ~
11567 \InsetSpace ~
11568 \InsetSpace ~
11569 \InsetSpace ~
11570 mov\InsetSpace ~
11571 \InsetSpace ~
11572 a,#0x01
11573 \newline
11574 F0\InsetSpace ~
11575 \InsetSpace ~
11576 \InsetSpace ~
11577 \InsetSpace ~
11578 \InsetSpace ~
11579 \InsetSpace ~
11580 \InsetSpace ~
11581 \InsetSpace ~
11582 \InsetSpace ~
11583 movx\InsetSpace ~
11584 @dptr,a
11585 \end_layout
11586
11587 \begin_layout Subsubsection
11588 idata
11589 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
11590
11591 \end_inset
11592
11593
11594 \begin_inset LatexCommand \index{\_\_idata (mcs51, ds390 storage class)}
11595
11596 \end_inset
11597
11598
11599 \end_layout
11600
11601 \begin_layout Standard
11602 Variables declared with this storage class will be allocated into the indirectly
11603  addressable portion of the internal ram of a 8051, e.g.:
11604 \end_layout
11605
11606 \begin_layout Verse
11607
11608 \family typewriter
11609 __idata unsigned char test_idata;
11610 \end_layout
11611
11612 \begin_layout Standard
11613 Writing 0x01 to this variable generates the assembly code:
11614 \end_layout
11615
11616 \begin_layout Verse
11617
11618 \family typewriter
11619 78r00\InsetSpace ~
11620 \InsetSpace ~
11621 \InsetSpace ~
11622 \InsetSpace ~
11623 \InsetSpace ~
11624 \InsetSpace ~
11625 \InsetSpace ~
11626 mov\InsetSpace ~
11627 \InsetSpace ~
11628 r0,#_test_idata
11629 \newline
11630 76\InsetSpace ~
11631 01\InsetSpace ~
11632 \InsetSpace ~
11633 \InsetSpace ~
11634 \InsetSpace ~
11635 \InsetSpace ~
11636 \InsetSpace ~
11637 \InsetSpace ~
11638 mov\InsetSpace ~
11639 \InsetSpace ~
11640 @r0,#0x01
11641 \end_layout
11642
11643 \begin_layout Standard
11644 Please note, the first 128 byte of idata physically access the same RAM
11645  as the data memory.
11646  The original 8051 had 128 byte idata memory, nowadays most devices have
11647  256 byte idata memory.
11648  The stack
11649 \begin_inset LatexCommand \index{stack}
11650
11651 \end_inset
11652
11653  is located in idata memory.
11654 \end_layout
11655
11656 \begin_layout Subsubsection
11657 pdata
11658 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
11659
11660 \end_inset
11661
11662
11663 \begin_inset LatexCommand \index{\_\_pdata (mcs51, ds390 storage class)}
11664
11665 \end_inset
11666
11667
11668 \end_layout
11669
11670 \begin_layout Standard
11671 Paged xdata access is just as straightforward as using the other addressing
11672  modes of a 8051.
11673  It is typically located at the start of xdata and has a maximum size of
11674  256 bytes.
11675  The following example writes 0x01 to the pdata variable.
11676  Please note, pdata access physically accesses xdata memory.
11677  The high byte of the address is determined by port P2
11678 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
11679
11680 \end_inset
11681
11682 (or in case of some 8051 variants by a separate Special Function Register,
11683  see section
11684 \begin_inset LatexCommand \ref{sub:MCS51-variants}
11685
11686 \end_inset
11687
11688 ).
11689  This is the
11690 \series bold
11691 default
11692 \series default
11693  storage class for the Medium Memory model, e.g.:
11694 \end_layout
11695
11696 \begin_layout Verse
11697
11698 \family typewriter
11699 __pdata unsigned char test_pdata;
11700 \end_layout
11701
11702 \begin_layout Standard
11703 Writing 0x01 to this variable generates the assembly code:
11704 \end_layout
11705
11706 \begin_layout Verse
11707
11708 \family typewriter
11709 78r00\InsetSpace ~
11710 \InsetSpace ~
11711 \InsetSpace ~
11712 \InsetSpace ~
11713 \InsetSpace ~
11714 \InsetSpace ~
11715 mov r0,#_test_pdata
11716 \newline
11717 74 01\InsetSpace ~
11718 \InsetSpace ~
11719 \InsetSpace ~
11720 \InsetSpace ~
11721 \InsetSpace ~
11722 \InsetSpace ~
11723 mov a,#0x01
11724 \newline
11725 F2\InsetSpace ~
11726 \InsetSpace ~
11727 \InsetSpace ~
11728 \InsetSpace ~
11729 \InsetSpace ~
11730 \InsetSpace ~
11731 \InsetSpace ~
11732 \InsetSpace ~
11733 \InsetSpace ~
11734 movx @r0,a
11735 \end_layout
11736
11737 \begin_layout Standard
11738 If the -
11739 \begin_inset ERT
11740 status collapsed
11741
11742 \begin_layout Standard
11743
11744
11745 \backslash
11746 /
11747 \end_layout
11748
11749 \end_inset
11750
11751 -xstack
11752 \begin_inset LatexCommand \index{-\/-xstack}
11753
11754 \end_inset
11755
11756  option is used the pdata memory area is followed by the xstack memory area
11757  and the sum of their sizes is limited to 256 bytes.
11758 \end_layout
11759
11760 \begin_layout Subsubsection
11761 code
11762 \begin_inset LatexCommand \index{code}
11763
11764 \end_inset
11765
11766
11767 \begin_inset LatexCommand \index{\_\_code}
11768
11769 \end_inset
11770
11771
11772 \end_layout
11773
11774 \begin_layout Standard
11775 'Variables' declared with this storage class will be placed in the code
11776  memory:
11777 \end_layout
11778
11779 \begin_layout Verse
11780
11781 \family typewriter
11782 __code unsigned char test_code;
11783 \end_layout
11784
11785 \begin_layout Standard
11786 Read access to this variable generates the assembly code:
11787 \end_layout
11788
11789 \begin_layout Verse
11790
11791 \family typewriter
11792 90s00r6F\InsetSpace ~
11793 \InsetSpace ~
11794 \InsetSpace ~
11795 mov dptr,#_test_code
11796 \newline
11797 E4\InsetSpace ~
11798 \InsetSpace ~
11799 \InsetSpace ~
11800 \InsetSpace ~
11801 \InsetSpace ~
11802 \InsetSpace ~
11803 \InsetSpace ~
11804 \InsetSpace ~
11805 \InsetSpace ~
11806 clr a
11807 \newline
11808 93\InsetSpace ~
11809 \InsetSpace ~
11810 \InsetSpace ~
11811 \InsetSpace ~
11812 \InsetSpace ~
11813 \InsetSpace ~
11814 \InsetSpace ~
11815 \InsetSpace ~
11816 \InsetSpace ~
11817 movc a,@a+dptr
11818 \end_layout
11819
11820 \begin_layout Standard
11821
11822 \family typewriter
11823 char
11824 \family default
11825  indexed arrays of characters in code memory can be accessed efficiently:
11826 \end_layout
11827
11828 \begin_layout Verse
11829
11830 \family typewriter
11831 __code char test_array[] = {'c','h','e','a','p'};
11832 \end_layout
11833
11834 \begin_layout Standard
11835 Read access to this array using an 8-bit unsigned index generates the assembly
11836  code:
11837 \end_layout
11838
11839 \begin_layout Verse
11840
11841 \family typewriter
11842 E5*00\InsetSpace ~
11843 \InsetSpace ~
11844 \InsetSpace ~
11845 \InsetSpace ~
11846 \InsetSpace ~
11847 \InsetSpace ~
11848 mov a,_index
11849 \end_layout
11850
11851 \begin_layout Verse
11852
11853 \family typewriter
11854 90s00r41\InsetSpace ~
11855 \InsetSpace ~
11856 \InsetSpace ~
11857 mov dptr,#_test_array
11858 \end_layout
11859
11860 \begin_layout Verse
11861
11862 \family typewriter
11863 93\InsetSpace ~
11864 \InsetSpace ~
11865 \InsetSpace ~
11866 \InsetSpace ~
11867 \InsetSpace ~
11868 \InsetSpace ~
11869 \InsetSpace ~
11870 \InsetSpace ~
11871 \InsetSpace ~
11872 movc a,@a+dptr
11873 \end_layout
11874
11875 \begin_layout Subsubsection
11876 bit
11877 \begin_inset LatexCommand \index{bit}
11878
11879 \end_inset
11880
11881
11882 \begin_inset LatexCommand \index{\_\_bit}
11883
11884 \end_inset
11885
11886
11887 \end_layout
11888
11889 \begin_layout Standard
11890 This is a data-type and a storage class specifier.
11891  When a variable is declared as a bit, it is allocated into the bit addressable
11892  memory of 8051, e.g.:
11893 \end_layout
11894
11895 \begin_layout Verse
11896
11897 \family typewriter
11898 __bit test_bit;
11899 \end_layout
11900
11901 \begin_layout Standard
11902 Writing 1 to this variable generates the assembly code:
11903 \end_layout
11904
11905 \begin_layout Verse
11906
11907 \family typewriter
11908 D2*00\InsetSpace ~
11909 \InsetSpace ~
11910 \InsetSpace ~
11911 \InsetSpace ~
11912 \InsetSpace ~
11913 \InsetSpace ~
11914 \InsetSpace ~
11915 setb\InsetSpace ~
11916 _test_bit
11917 \end_layout
11918
11919 \begin_layout Standard
11920 The bit addressable memory consists of 128 bits which are located from 0x20
11921  to 0x2f in data memory.
11922 \newline
11923 Apart from this 8051 specific storage class most
11924  architectures support ANSI-C bitfields
11925 \begin_inset LatexCommand \index{bitfields}
11926
11927 \end_inset
11928
11929
11930 \begin_inset Foot
11931 status open
11932
11933 \begin_layout Standard
11934 Not really meant as examples, but nevertheless showing what bitfields are
11935  about: device/include/mc68hc908qy.h and support/regression/tests/bitfields.c
11936 \end_layout
11937
11938 \end_inset
11939
11940 .
11941  In accordance with ISO/IEC 9899 bits and bitfields without an explicit
11942  signed modifier are implemented as unsigned.
11943 \end_layout
11944
11945 \begin_layout Subsubsection
11946 sfr
11947 \begin_inset LatexCommand \index{sfr}
11948
11949 \end_inset
11950
11951
11952 \begin_inset LatexCommand \index{\_\_sfr}
11953
11954 \end_inset
11955
11956  / sfr16
11957 \begin_inset LatexCommand \index{sfr16}
11958
11959 \end_inset
11960
11961
11962 \begin_inset LatexCommand \index{\_\_sfr16}
11963
11964 \end_inset
11965
11966  / sfr32
11967 \begin_inset LatexCommand \index{sfr32}
11968
11969 \end_inset
11970
11971
11972 \begin_inset LatexCommand \index{\_\_sfr32}
11973
11974 \end_inset
11975
11976  / sbit
11977 \begin_inset LatexCommand \index{\_\_sbit}
11978
11979 \end_inset
11980
11981
11982 \begin_inset LatexCommand \index{sbit}
11983
11984 \end_inset
11985
11986
11987 \end_layout
11988
11989 \begin_layout Standard
11990 Like the bit keyword,
11991 \emph on
11992 sfr / sfr16 / sfr32 / sbit
11993 \emph default
11994 signify both a data-type and storage class, they are used to describe the
11995 \emph on
11996 s
11997 \emph default
11998 pecial
11999 \emph on
12000 f
12001 \emph default
12002 unction
12003 \emph on
12004 r
12005 \emph default
12006 egisters and
12007 \emph on
12008 s
12009 \emph default
12010 pecial
12011 \emph on
12012 bit
12013 \emph default
12014  variables of a 8051, eg:
12015 \end_layout
12016
12017 \begin_layout Verse
12018
12019 \family typewriter
12020 __sfr __at
12021 \begin_inset LatexCommand \index{at}
12022
12023 \end_inset
12024
12025
12026 \begin_inset LatexCommand \index{\_\_at}
12027
12028 \end_inset
12029
12030  (0x80) P0;\InsetSpace ~
12031  /* special function register P0 at location 0x80 */
12032 \newline
12033
12034 \newline
12035 /* 16 bit
12036  special function register combination for timer 0
12037 \newline
12038 \InsetSpace ~
12039 \InsetSpace ~
12040  with the high byte at
12041  location 0x8C and the low byte at location 0x8A */
12042 \newline
12043 __sfr16 __at (0x8C8A)
12044  TMR0;
12045 \newline
12046
12047 \newline
12048 __sbit __at
12049 \begin_inset LatexCommand \index{at}
12050
12051 \end_inset
12052
12053
12054 \begin_inset LatexCommand \index{\_\_at}
12055
12056 \end_inset
12057
12058  (0xd7) CY;\InsetSpace ~
12059  /* CY (Carry Flag
12060 \begin_inset LatexCommand \index{Flags}
12061
12062 \end_inset
12063
12064
12065 \begin_inset LatexCommand \index{Carry flag}
12066
12067 \end_inset
12068
12069 ) */
12070 \end_layout
12071
12072 \begin_layout Standard
12073 Special function registers which are located on an address dividable by
12074  8 are bit-addressable, an
12075 \emph on
12076  sbit
12077 \emph default
12078  addresses a specific bit within these sfr.
12079 \newline
12080 16 Bit and 32 bit special function
12081  register combinations which require a certain access order are better not
12082  declared using
12083 \emph on
12084 sfr16
12085 \emph default
12086  or
12087 \emph on
12088 sfr32.
12089
12090 \emph default
12091  Allthough SDCC usually accesses them Least Significant Byte (LSB) first,
12092  this is not guaranteed.
12093 \newline
12094
12095 \end_layout
12096
12097 \begin_layout Standard
12098 Please note, if you use a header file which was written for another compiler
12099  then the sfr / sfr16 / sfr32 / sbit Storage Class extensions will most
12100  likely be
12101 \emph on
12102 not
12103 \emph default
12104 compatible.
12105  Specifically the syntax
12106 \family typewriter
12107 \InsetSpace ~
12108 sfr P0 = 0x80;\InsetSpace ~
12109
12110 \family default
12111  is compiled
12112 \emph on
12113 without warning
12114 \emph default
12115  by SDCC to an assignment of 0x80 to a variable called P0
12116 \family typewriter
12117
12118 \begin_inset Marginal
12119 status collapsed
12120
12121 \begin_layout Standard
12122
12123 \series bold
12124 \InsetSpace ~
12125 !
12126 \end_layout
12127
12128 \end_inset
12129
12130 .
12131 \family default
12132 Nevertheless it is possible to write header files
12133 \begin_inset LatexCommand \index{Header files}
12134
12135 \end_inset
12136
12137
12138 \begin_inset LatexCommand \index{Include files}
12139
12140 \end_inset
12141
12142  which can be shared among different compilers (see section
12143 \begin_inset LatexCommand \ref{sec:Porting-code-to-other-compilers}
12144
12145 \end_inset
12146
12147 ).
12148 \end_layout
12149
12150 \begin_layout Subsubsection
12151 Pointers
12152 \begin_inset LatexCommand \index{Pointer}
12153
12154 \end_inset
12155
12156  to MCS51/DS390 specific memory spaces
12157 \end_layout
12158
12159 \begin_layout Standard
12160 SDCC allows (via language extensions) pointers to explicitly point to any
12161  of the memory spaces
12162 \begin_inset LatexCommand \index{Memory model}
12163
12164 \end_inset
12165
12166  of the 8051.
12167  In addition to the explicit pointers, the compiler uses (by default) generic
12168  pointers which can be used to point to any of the memory spaces.
12169 \newline
12170
12171 \newline
12172 Pointer
12173  declaration examples:
12174 \end_layout
12175
12176 \begin_layout Verse
12177
12178 \family typewriter
12179 /* pointer physically in internal ram pointing to object in external ram
12180  */
12181 \newline
12182 __xdata unsigned char * __data p;
12183 \newline
12184
12185 \newline
12186 /* pointer physically in external ram
12187  pointing to object in internal ram */
12188 \newline
12189 __data unsigned char * __xdata p;
12190 \newline
12191
12192 \newline
12193 /*
12194  pointer physically in code rom pointing to data in xdata space */
12195 \newline
12196 __xdata
12197  unsigned char * __code p;
12198 \newline
12199
12200 \newline
12201 /* pointer physically in code space pointing to
12202  data in code space */
12203 \newline
12204 __code unsigned char * __code p;
12205 \newline
12206
12207 \newline
12208 /* generic pointer
12209  physically located in xdata space */
12210 \newline
12211 unsigned char * __xdata p;
12212 \newline
12213
12214 \newline
12215 /* generic
12216  pointer physically located in default memory space */
12217 \newline
12218 unsigned char * p;
12219 \newline
12220
12221 \newline
12222 /*
12223  the following is a function pointer
12224 \begin_inset LatexCommand \index{function pointer}
12225
12226 \end_inset
12227
12228  physically located in data space */
12229 \newline
12230 char (* __data fp)(void);
12231 \end_layout
12232
12233 \begin_layout Standard
12234 Well you get the idea.
12235 \newline
12236
12237 \newline
12238 All unqualified pointers are treated as 3-byte (4-byte
12239  for the ds390)
12240 \emph on
12241 generic
12242 \emph default
12243  pointers.
12244 \size small
12245
12246 \newline
12247
12248 \newline
12249
12250 \size default
12251 The highest order byte of the
12252 \emph on
12253 generic
12254 \emph default
12255  pointers contains the data space information.
12256  Assembler support routines are called whenever data is stored or retrieved
12257  using
12258 \emph on
12259 generic
12260 \emph default
12261  pointers.
12262  These are useful for developing reusable library
12263 \begin_inset LatexCommand \index{Libraries}
12264
12265 \end_inset
12266
12267  routines.
12268  Explicitly specifying the pointer
12269 \begin_inset LatexCommand \index{pointer}
12270
12271 \end_inset
12272
12273  type will generate the most efficient code.
12274 \end_layout
12275
12276 \begin_layout Subsubsection
12277 Notes on MCS51 memory
12278 \begin_inset LatexCommand \index{MCS51 memory}
12279
12280 \end_inset
12281
12282  layout
12283 \end_layout
12284
12285 \begin_layout Standard
12286 The 8051 family of microcontrollers have a minimum of 128 bytes of internal
12287  RAM memory which is structured as follows:
12288 \newline
12289
12290 \newline
12291 - Bytes 00-1F - 32 bytes to hold
12292  up to 4 banks of the registers R0 to R7,
12293 \newline
12294 - Bytes 20-2F - 16 bytes to hold
12295  128 bit
12296 \begin_inset LatexCommand \index{bit}
12297
12298 \end_inset
12299
12300  variables and,
12301 \newline
12302 - Bytes 30-7F - 80 bytes for general purpose use.
12303 \newline
12304
12305 \end_layout
12306
12307 \begin_layout Standard
12308 Additionally some members of the MCS51 family may have up to 128 bytes of
12309  additional, indirectly addressable, internal RAM memory (
12310 \emph on
12311 idata
12312 \emph default
12313
12314 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
12315
12316 \end_inset
12317
12318
12319 \begin_inset LatexCommand \index{\_\_idata (mcs51, ds390 storage class)}
12320
12321 \end_inset
12322
12323 ).
12324  Furthermore, some chips may have some built in external memory (
12325 \emph on
12326 xdata
12327 \emph default
12328
12329 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
12330
12331 \end_inset
12332
12333
12334 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
12335
12336 \end_inset
12337
12338 ) which should not be confused with the internal, directly addressable RAM
12339  memory (
12340 \emph on
12341 data
12342 \emph default
12343
12344 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
12345
12346 \end_inset
12347
12348
12349 \begin_inset LatexCommand \index{\_\_data (mcs51, ds390 storage class)}
12350
12351 \end_inset
12352
12353 ).
12354  Sometimes this built in
12355 \emph on
12356 xdata
12357 \emph default
12358  memory has to be activated before using it (you can probably find this
12359  information on the datasheet of the microcontroller your are using, see
12360  also section
12361 \begin_inset LatexCommand \ref{sub:Startup-Code}
12362
12363 \end_inset
12364
12365 \InsetSpace ~
12366 Startup-Code).
12367 \end_layout
12368
12369 \begin_layout Standard
12370 Normally SDCC will only use the first bank
12371 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
12372
12373 \end_inset
12374
12375  of registers (register bank 0), but it is possible to specify that other
12376  banks of registers (keyword
12377 \emph on
12378 using
12379 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
12380
12381 \end_inset
12382
12383
12384 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
12385
12386 \end_inset
12387
12388
12389 \emph default
12390 ) should be used for example in interrupt
12391 \begin_inset LatexCommand \index{interrupt}
12392
12393 \end_inset
12394
12395
12396 \begin_inset LatexCommand \index{\_\_interrupt}
12397
12398 \end_inset
12399
12400  routines.
12401  By default, the compiler will place the stack after the last byte of allocated
12402  memory for variables.
12403  For example, if the first 2 banks of registers are used, and only four
12404  bytes are used for
12405 \emph on
12406 data
12407 \emph default
12408  variables, it will position the base of the internal stack at address 20
12409  (0x14).
12410  This implies that as the stack
12411 \begin_inset LatexCommand \index{stack}
12412
12413 \end_inset
12414
12415  grows, it will use up the remaining register banks, and the 16 bytes used
12416  by the 128 bit variables, and 80 bytes for general purpose use.
12417  If any bit variables are used, the data variables will be placed in unused
12418  register banks and after the byte holding the last bit variable.
12419  For example, if register banks 0 and 1 are used, and there are 9 bit variables
12420  (two bytes used),
12421 \emph on
12422 data
12423 \emph default
12424  variables will be placed starting from address 0x10 to 0x20 and continue
12425  at address 0x22.
12426  You can also use -
12427 \begin_inset ERT
12428 status collapsed
12429
12430 \begin_layout Standard
12431
12432
12433 \backslash
12434 /
12435 \end_layout
12436
12437 \end_inset
12438
12439 -data-loc
12440 \begin_inset LatexCommand \index{-\/-data-loc <Value>}
12441
12442 \end_inset
12443
12444  to specify the start address of the
12445 \emph on
12446 data
12447 \emph default
12448  and -
12449 \begin_inset ERT
12450 status collapsed
12451
12452 \begin_layout Standard
12453
12454
12455 \backslash
12456 /
12457 \end_layout
12458
12459 \end_inset
12460
12461 -iram-size
12462 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
12463
12464 \end_inset
12465
12466  to specify the size of the total internal RAM (
12467 \emph on
12468 data
12469 \emph default
12470 +
12471 \emph on
12472 idata
12473 \emph default
12474 ).
12475 \newline
12476
12477 \end_layout
12478
12479 \begin_layout Standard
12480 By default the 8051 linker will place the stack after the last byte of (i)data
12481  variables.
12482  Option -
12483 \begin_inset ERT
12484 status collapsed
12485
12486 \begin_layout Standard
12487
12488
12489 \backslash
12490 /
12491 \end_layout
12492
12493 \end_inset
12494
12495 -stack-loc
12496 \begin_inset LatexCommand \index{-\/-stack-loc <Value>}
12497
12498 \end_inset
12499
12500  allows you to specify the start of the stack, i.e.
12501  you could start it after any data in the general purpose area.
12502  If your microcontroller has additional indirectly addressable internal
12503  RAM (
12504 \emph on
12505 idata
12506 \emph default
12507 ) you can place the stack on it.
12508  You may also need to use -
12509 \begin_inset ERT
12510 status collapsed
12511
12512 \begin_layout Standard
12513
12514
12515 \backslash
12516 /
12517 \end_layout
12518
12519 \end_inset
12520
12521 -xdata-loc
12522 \begin_inset LatexCommand \index{-\/-xdata-loc<Value>}
12523
12524 \end_inset
12525
12526  to set the start address of the external RAM (
12527 \emph on
12528 xdata
12529 \emph default
12530 ) and -
12531 \begin_inset ERT
12532 status collapsed
12533
12534 \begin_layout Standard
12535
12536
12537 \backslash
12538 /
12539 \end_layout
12540
12541 \end_inset
12542
12543 -xram-size
12544 \begin_inset LatexCommand \index{-\/-xram-size <Value>}
12545
12546 \end_inset
12547
12548  to specify its size.
12549  Same goes for the code memory, using -
12550 \begin_inset ERT
12551 status collapsed
12552
12553 \begin_layout Standard
12554
12555
12556 \backslash
12557 /
12558 \end_layout
12559
12560 \end_inset
12561
12562 -code-loc
12563 \begin_inset LatexCommand \index{-\/-code-loc <Value>}
12564
12565 \end_inset
12566
12567  and -
12568 \begin_inset ERT
12569 status collapsed
12570
12571 \begin_layout Standard
12572
12573
12574 \backslash
12575 /
12576 \end_layout
12577
12578 \end_inset
12579
12580 -code-size
12581 \begin_inset LatexCommand \index{-\/-code-size <Value>}
12582
12583 \end_inset
12584
12585 .
12586  If in doubt, don't specify any options and see if the resulting memory
12587  layout is appropriate, then you can adjust it.
12588 \end_layout
12589
12590 \begin_layout Standard
12591 The linker generates two files with memory allocation information.
12592  The first, with extension .map
12593 \begin_inset LatexCommand \index{<file>.map}
12594
12595 \end_inset
12596
12597  shows all the variables and segments.
12598  The second with extension .mem
12599 \begin_inset LatexCommand \index{<file>.mem}
12600
12601 \end_inset
12602
12603  shows the final memory layout.
12604  The linker will complain either if memory segments overlap, there is not
12605  enough memory, or there is not enough space for stack.
12606  If you get any linking warnings and/or errors related to stack or segments
12607  allocation, take a look at either the .map or .mem files to find out what
12608  the problem is.
12609  The .mem file may even suggest a solution to the problem.
12610 \begin_inset VSpace bigskip
12611 \end_inset
12612
12613
12614 \end_layout
12615
12616 \begin_layout Subsection
12617 Z80/Z180 Storage Class
12618 \begin_inset LatexCommand \index{Z80!Storage class}
12619
12620 \end_inset
12621
12622  Language Extensions
12623 \end_layout
12624
12625 \begin_layout Subsubsection
12626 sfr
12627 \begin_inset LatexCommand \index{sfr}
12628
12629 \end_inset
12630
12631
12632 \begin_inset LatexCommand \index{\_\_sfr}
12633
12634 \end_inset
12635
12636  (in/out to 8-bit addresses)
12637 \end_layout
12638
12639 \begin_layout Standard
12640 The Z80
12641 \begin_inset LatexCommand \index{Z80}
12642
12643 \end_inset
12644
12645  family has separate address spaces for memory and
12646 \emph on
12647 i
12648 \emph default
12649 nput/
12650 \emph on
12651 o
12652 \emph default
12653 utput memory.
12654  I/O memory
12655 \begin_inset LatexCommand \index{I/O memory (Z80, Z180)}
12656
12657 \end_inset
12658
12659
12660 \begin_inset LatexCommand \index{Z80!I/O memory}
12661
12662 \end_inset
12663
12664
12665 \begin_inset LatexCommand \index{Z180!I/O memory}
12666
12667 \end_inset
12668
12669  is accessed with special instructions, e.g.:
12670 \end_layout
12671
12672 \begin_layout Verse
12673
12674 \family typewriter
12675 sfr at 0x78 IoPort;\InsetSpace ~
12676 \InsetSpace ~
12677 /* define a var in I/O space at 78h called IoPort */
12678 \end_layout
12679
12680 \begin_layout Standard
12681 Writing 0x01 to this variable generates the assembly code:
12682 \end_layout
12683
12684 \begin_layout Verse
12685
12686 \family typewriter
12687 3E 01\InsetSpace ~
12688 \InsetSpace ~
12689 \InsetSpace ~
12690 \InsetSpace ~
12691 \InsetSpace ~
12692 \InsetSpace ~
12693 ld a,#0x01
12694 \newline
12695 D3 78\InsetSpace ~
12696 \InsetSpace ~
12697 \InsetSpace ~
12698 \InsetSpace ~
12699 \InsetSpace ~
12700 \InsetSpace ~
12701 out (_IoPort),a
12702 \end_layout
12703
12704 \begin_layout Subsubsection
12705 banked sfr
12706 \begin_inset LatexCommand \index{sfr}
12707
12708 \end_inset
12709
12710
12711 \begin_inset LatexCommand \index{\_\_sfr}
12712
12713 \end_inset
12714
12715  (in/out to 16-bit addresses)
12716 \end_layout
12717
12718 \begin_layout Standard
12719 The keyword
12720 \emph on
12721 banked
12722 \emph default
12723  is used to support 16 bit addresses in I/O memory e.g.:
12724 \end_layout
12725
12726 \begin_layout Verse
12727
12728 \family typewriter
12729 sfr banked at
12730 \begin_inset LatexCommand \index{at}
12731
12732 \end_inset
12733
12734
12735 \begin_inset LatexCommand \index{\_\_at}
12736
12737 \end_inset
12738
12739  0x123 IoPort;
12740 \end_layout
12741
12742 \begin_layout Standard
12743 Writing 0x01 to this variable generates the assembly code:
12744 \end_layout
12745
12746 \begin_layout Verse
12747
12748 \family typewriter
12749 01 23 01\InsetSpace ~
12750 \InsetSpace ~
12751 \InsetSpace ~
12752 ld bc,#_IoPort
12753 \newline
12754 3E 01\InsetSpace ~
12755 \InsetSpace ~
12756 \InsetSpace ~
12757 \InsetSpace ~
12758 \InsetSpace ~
12759 \InsetSpace ~
12760 ld a,#0x01
12761 \newline
12762 ED 79\InsetSpace ~
12763 \InsetSpace ~
12764 \InsetSpace ~
12765 \InsetSpace ~
12766 \InsetSpace ~
12767 \InsetSpace ~
12768 out (c),a
12769 \end_layout
12770
12771 \begin_layout Subsubsection
12772 sfr
12773 \begin_inset LatexCommand \index{sfr}
12774
12775 \end_inset
12776
12777
12778 \begin_inset LatexCommand \index{\_\_sfr}
12779
12780 \end_inset
12781
12782  (in0/out0 to 8 bit addresses on Z180
12783 \begin_inset LatexCommand \index{Z180}
12784
12785 \end_inset
12786
12787 /HD64180
12788 \begin_inset LatexCommand \index{HD64180 (see Z180)}
12789
12790 \end_inset
12791
12792 )
12793 \end_layout
12794
12795 \begin_layout Standard
12796 The compiler option -
12797 \begin_inset ERT
12798 status collapsed
12799
12800 \begin_layout Standard
12801
12802
12803 \backslash
12804 /
12805 \end_layout
12806
12807 \end_inset
12808
12809 -portmode
12810 \begin_inset LatexCommand \index{Z180!Options!-\/-portmode}
12811
12812 \end_inset
12813
12814 =180 (80) and a compiler #pragma\InsetSpace ~
12815 portmode
12816 \begin_inset LatexCommand \index{Z180!Pragmas!\#pragma portmode}
12817
12818 \end_inset
12819
12820  z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructio
12821 ns
12822 \family typewriter
12823 in0/out0
12824 \family default
12825  instead of
12826 \family typewriter
12827 in/out
12828 \family default
12829 .
12830  If you include the file z180.h this will be set automatically.
12831 \begin_inset VSpace bigskip
12832 \end_inset
12833
12834
12835 \end_layout
12836
12837 \begin_layout Subsection
12838 HC08 Storage Class
12839 \begin_inset LatexCommand \index{HC08!Storage class}
12840
12841 \end_inset
12842
12843  Language Extensions
12844 \end_layout
12845
12846 \begin_layout Subsubsection
12847 data
12848 \begin_inset LatexCommand \index{data (hc08 storage class)}
12849
12850 \end_inset
12851
12852
12853 \begin_inset LatexCommand \index{\_\_data (hc08 storage class)}
12854
12855 \end_inset
12856
12857
12858 \end_layout
12859
12860 \begin_layout Standard
12861 The data storage class declares a variable that resides in the first 256
12862  bytes of memory (the direct page).
12863  The HC08
12864 \begin_inset LatexCommand \index{HC08}
12865
12866 \end_inset
12867
12868  is most efficient at accessing variables (especially pointers) stored here.
12869 \end_layout
12870
12871 \begin_layout Subsubsection
12872 xdata
12873 \begin_inset LatexCommand \index{xdata (hc08 storage class)}
12874
12875 \end_inset
12876
12877
12878 \begin_inset LatexCommand \index{\_\_xdata (hc08 storage class)}
12879
12880 \end_inset
12881
12882
12883 \end_layout
12884
12885 \begin_layout Standard
12886 The xdata storage class declares a variable that can reside anywhere in
12887  memory.
12888  This is the default if no storage class is specified.
12889 \begin_inset VSpace bigskip
12890 \end_inset
12891
12892
12893 \end_layout
12894
12895 \begin_layout Section
12896 Absolute Addressing
12897 \begin_inset LatexCommand \index{Absolute addressing}
12898
12899 \end_inset
12900
12901
12902 \end_layout
12903
12904 \begin_layout Standard
12905 Data items can be assigned an absolute address with the
12906 \emph on
12907 at
12908 \begin_inset LatexCommand \index{at}
12909
12910 \end_inset
12911
12912
12913 \begin_inset LatexCommand \index{\_\_at}
12914
12915 \end_inset
12916
12917  <address>
12918 \emph default
12919  keyword, in addition to a storage class, e.g.:
12920 \end_layout
12921
12922 \begin_layout Verse
12923
12924 \family typewriter
12925 xdata
12926 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
12927
12928 \end_inset
12929
12930
12931 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
12932
12933 \end_inset
12934
12935  at
12936 \begin_inset LatexCommand \index{at}
12937
12938 \end_inset
12939
12940
12941 \begin_inset LatexCommand \index{\_\_at}
12942
12943 \end_inset
12944
12945  0x7ffe unsigned int chksum;
12946 \end_layout
12947
12948 \begin_layout Standard
12949 or, better conforming to ISO/IEC 9899 C:
12950 \end_layout
12951
12952 \begin_layout Verse
12953
12954 \family typewriter
12955 __xdata __at (0x7ffe) unsigned int chksum;
12956 \end_layout
12957
12958 \begin_layout Standard
12959 In the above example the variable chksum will be located at 0x7ffe and 0x7fff
12960  of the external ram.
12961  The compiler does
12962 \emph on
12963 not
12964 \emph default
12965  reserve any space for variables declared in this way
12966 \begin_inset Marginal
12967 status collapsed
12968
12969 \begin_layout Standard
12970
12971 \series bold
12972 \InsetSpace ~
12973 !
12974 \end_layout
12975
12976 \end_inset
12977
12978  (they are implemented with an equate in the assembler).
12979  Thus it is left to the programmer to make sure there are no overlaps with
12980  other variables that are declared without the absolute address.
12981  The assembler listing file (.lst
12982 \begin_inset LatexCommand \index{<file>.lst}
12983
12984 \end_inset
12985
12986 ) and the linker output files (.rst
12987 \begin_inset LatexCommand \index{<file>.rst}
12988
12989 \end_inset
12990
12991 ) and (.map
12992 \begin_inset LatexCommand \index{<file>.map}
12993
12994 \end_inset
12995
12996 ) are good places to look for such overlaps.
12997 \end_layout
12998
12999 \begin_layout Standard
13000 If however you provide an initializer
13001 \begin_inset LatexCommand \index{Variable initialization}
13002
13003 \end_inset
13004
13005  actual memory allocation will take place and overlaps will be detected
13006  by the linker.
13007  E.g.:
13008 \end_layout
13009
13010 \begin_layout Verse
13011
13012 \family typewriter
13013 __code __at (0x7ff0) char Id[5] =
13014 \begin_inset Quotes sld
13015 \end_inset
13016
13017 SDCC
13018 \begin_inset Quotes srd
13019 \end_inset
13020
13021 ;
13022 \end_layout
13023
13024 \begin_layout Standard
13025 In the above example the variable Id will be located from 0x7ff0 to 0x7ff4
13026  in code memory.
13027 \end_layout
13028
13029 \begin_layout Standard
13030 In case of memory mapped I/O devices the keyword
13031 \emph on
13032 volatile
13033 \emph default
13034  has to be used to tell the compiler that accesses might not be removed:
13035 \end_layout
13036
13037 \begin_layout Verse
13038
13039 \family typewriter
13040 volatile
13041 \begin_inset LatexCommand \index{volatile}
13042
13043 \end_inset
13044
13045  __xdata
13046 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
13047
13048 \end_inset
13049
13050  __at
13051 \begin_inset LatexCommand \index{at}
13052
13053 \end_inset
13054
13055  (0x8000) unsigned char PORTA_8255;
13056 \end_layout
13057
13058 \begin_layout Standard
13059 For some architectures (mcs51) array accesses are more efficient if an (xdata/fa
13060 r) array
13061 \family typewriter
13062 \size footnotesize
13063
13064 \begin_inset LatexCommand \index{Aligned array}
13065
13066 \end_inset
13067
13068
13069 \family default
13070 \size default
13071  starts at a block (256 byte) boundary
13072 \begin_inset LatexCommand \index{block boundary}
13073
13074 \end_inset
13075
13076  (section
13077 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
13078
13079 \end_inset
13080
13081  has an example).
13082 \newline
13083 Absolute addresses can be specified for variables in all
13084  storage classes, e.g.:
13085 \end_layout
13086
13087 \begin_layout Verse
13088
13089 \family typewriter
13090 __bit
13091 \begin_inset LatexCommand \index{bit}
13092
13093 \end_inset
13094
13095  __at
13096 \begin_inset LatexCommand \index{at}
13097
13098 \end_inset
13099
13100  (0x02) bvar;
13101 \end_layout
13102
13103 \begin_layout Standard
13104 The above example will allocate the variable at offset 0x02 in the bit-addressab
13105 le space.
13106  There is no real advantage to assigning absolute addresses to variables
13107  in this manner, unless you want strict control over all the variables allocated.
13108  One possible use would be to write hardware portable code.
13109  For example, if you have a routine that uses one or more of the microcontroller
13110  I/O pins, and such pins are different for two different hardwares, you
13111  can declare the I/O pins in your routine using:
13112 \end_layout
13113
13114 \begin_layout Verse
13115
13116 \family typewriter
13117 extern volatile
13118 \begin_inset LatexCommand \index{volatile}
13119
13120 \end_inset
13121
13122  __bit MOSI;\InsetSpace ~
13123 \InsetSpace ~
13124 \InsetSpace ~
13125 \InsetSpace ~
13126 /* master out, slave in */
13127 \newline
13128 extern volatile __bit MISO;\InsetSpace ~
13129 \InsetSpace ~
13130 \InsetSpace ~
13131 \InsetSpace ~
13132 /* master
13133  in, slave out */
13134 \newline
13135 extern volatile __bit MCLK;\InsetSpace ~
13136 \InsetSpace ~
13137 \InsetSpace ~
13138 \InsetSpace ~
13139 /* master clock */
13140 \newline
13141
13142 \newline
13143 /* Input and
13144  Output of a byte on a 3-wire serial bus.
13145 \newline
13146 \InsetSpace ~
13147 \InsetSpace ~
13148 \InsetSpace ~
13149 If needed adapt polarity of clock,
13150  polarity of data and bit order
13151 \newline
13152 \InsetSpace ~
13153 */
13154 \newline
13155 unsigned char spi_io(unsigned char out_byte)
13156 \newline
13157 {
13158 \newline
13159 \InsetSpace ~
13160 \InsetSpace ~
13161 \InsetSpace ~
13162 \InsetSpace ~
13163 un
13164 signed char i=8;
13165 \newline
13166 \InsetSpace ~
13167 \InsetSpace ~
13168 \InsetSpace ~
13169 \InsetSpace ~
13170 do {
13171 \newline
13172 \InsetSpace ~
13173 \InsetSpace ~
13174 \InsetSpace ~
13175 \InsetSpace ~
13176 \InsetSpace ~
13177 \InsetSpace ~
13178 \InsetSpace ~
13179 \InsetSpace ~
13180 MOSI = out_byte & 0x80;
13181 \newline
13182 \InsetSpace ~
13183 \InsetSpace ~
13184 \InsetSpace ~
13185 \InsetSpace ~
13186 \InsetSpace ~
13187 \InsetSpace ~
13188 \InsetSpace ~
13189 \InsetSpace ~
13190 out_byte <<= 1;
13191 \newline
13192 \InsetSpace ~
13193 \InsetSpace ~
13194 \InsetSpace ~
13195 \InsetSpace ~
13196 \InsetSpace ~
13197 \InsetSpace ~
13198 \InsetSpace ~
13199 \InsetSpace ~
13200 MCLK = 1;
13201 \newline
13202 \InsetSpace ~
13203 \InsetSpace ~
13204 \InsetSpace ~
13205 \InsetSpace ~
13206 \InsetSpace ~
13207 \InsetSpace ~
13208 \InsetSpace ~
13209 \InsetSpace ~
13210 /* _asm
13211  nop _endasm; */\InsetSpace ~
13212 \InsetSpace ~
13213 \InsetSpace ~
13214 \InsetSpace ~
13215 \InsetSpace ~
13216 \InsetSpace ~
13217 \InsetSpace ~
13218 \InsetSpace ~
13219 /* for slow peripherals */
13220 \newline
13221 \InsetSpace ~
13222 \InsetSpace ~
13223 \InsetSpace ~
13224 \InsetSpace ~
13225 \InsetSpace ~
13226 \InsetSpace ~
13227 \InsetSpace ~
13228 \InsetSpace ~
13229 if(MISO)
13230 \newline
13231 \InsetSpace ~
13232 \InsetSpace ~
13233 \InsetSpace ~
13234 \InsetSpace ~
13235 \InsetSpace ~
13236 \InsetSpace ~
13237 \InsetSpace ~
13238 \InsetSpace ~
13239 \InsetSpace ~
13240 \InsetSpace ~
13241 \InsetSpace ~
13242 \InsetSpace ~
13243 out_byte += 1;
13244 \newline
13245 \InsetSpace ~
13246 \InsetSpace ~
13247 \InsetSpace ~
13248 \InsetSpace ~
13249 \InsetSpace ~
13250 \InsetSpace ~
13251 \InsetSpace ~
13252 \InsetSpace ~
13253 MCLK = 0;
13254 \newline
13255 \InsetSpace ~
13256 \InsetSpace ~
13257 \InsetSpace ~
13258 \InsetSpace ~
13259 }
13260  while(--i);
13261 \newline
13262 \InsetSpace ~
13263 \InsetSpace ~
13264 \InsetSpace ~
13265 \InsetSpace ~
13266 return out_byte;
13267 \newline
13268 }
13269 \end_layout
13270
13271 \begin_layout Standard
13272 Then, someplace in the code for the first hardware you would use
13273 \end_layout
13274
13275 \begin_layout Verse
13276
13277 \family typewriter
13278 __bit __at
13279 \begin_inset LatexCommand \index{at}
13280
13281 \end_inset
13282
13283
13284 \begin_inset LatexCommand \index{\_\_at}
13285
13286 \end_inset
13287
13288  (0x80) MOSI;\InsetSpace ~
13289 \InsetSpace ~
13290 \InsetSpace ~
13291 \InsetSpace ~
13292 /* I/O port 0, bit 0 */
13293 \newline
13294 __bit __at (0x81) MISO;\InsetSpace ~
13295 \InsetSpace ~
13296 \InsetSpace ~
13297 \InsetSpace ~
13298 /* I/O port 0,
13299  bit 1 */
13300 \newline
13301 __bit __at (0x82) MCLK;\InsetSpace ~
13302 \InsetSpace ~
13303 \InsetSpace ~
13304 \InsetSpace ~
13305 /* I/O port 0, bit 2 */
13306 \end_layout
13307
13308 \begin_layout Standard
13309 Similarly, for the second hardware you would use
13310 \end_layout
13311
13312 \begin_layout Verse
13313
13314 \family typewriter
13315 __bit __at (0x83) MOSI;\InsetSpace ~
13316 \InsetSpace ~
13317 \InsetSpace ~
13318 \InsetSpace ~
13319 /* I/O port 0, bit 3 */
13320 \newline
13321 __bit __at (0x91) MISO;\InsetSpace ~
13322 \InsetSpace ~
13323 \InsetSpace ~
13324 \InsetSpace ~
13325 /*
13326  I/O port 1, bit 1 */
13327 \newline
13328 __bit
13329 \begin_inset LatexCommand \index{bit}
13330
13331 \end_inset
13332
13333  __at (0x92) MCLK;\InsetSpace ~
13334 \InsetSpace ~
13335 \InsetSpace ~
13336 \InsetSpace ~
13337 /* I/O port 1, bit 2 */
13338 \end_layout
13339
13340 \begin_layout Standard
13341 and you can use the same hardware dependent routine without changes, as
13342  for example in a library.
13343  This is somehow similar to sbit, but only one absolute address has to be
13344  specified in the whole project.
13345 \begin_inset VSpace bigskip
13346 \end_inset
13347
13348
13349 \end_layout
13350
13351 \begin_layout Section
13352 Parameters
13353 \begin_inset LatexCommand \index{Parameters}
13354
13355 \end_inset
13356
13357
13358 \begin_inset LatexCommand \index{function parameter}
13359
13360 \end_inset
13361
13362  & Local Variables
13363 \begin_inset LatexCommand \index{local variables}
13364
13365 \end_inset
13366
13367
13368 \begin_inset LatexCommand \label{sec:Parameters-and-Local-Variables}
13369
13370 \end_inset
13371
13372
13373 \end_layout
13374
13375 \begin_layout Standard
13376 Automatic (local) variables and parameters to functions can either be placed
13377  on the stack or in data-space.
13378  The default action of the compiler is to place these variables in the internal
13379  RAM (for small model) or external RAM (for medium or large model).
13380  This in fact makes them similar to
13381 \emph on
13382 static
13383 \begin_inset LatexCommand \index{static}
13384
13385 \end_inset
13386
13387
13388 \emph default
13389  so by default functions are non-reentrant
13390 \begin_inset LatexCommand \index{reentrant}
13391
13392 \end_inset
13393
13394 .
13395 \newline
13396
13397 \newline
13398 They can be placed on the stack
13399 \begin_inset LatexCommand \index{stack}
13400
13401 \end_inset
13402
13403  by using the
13404 \emph on
13405  -
13406 \begin_inset ERT
13407 status collapsed
13408
13409 \begin_layout Standard
13410
13411
13412 \backslash
13413 /
13414 \end_layout
13415
13416 \end_inset
13417
13418 -stack-auto
13419 \begin_inset LatexCommand \index{-\/-stack-auto}
13420
13421 \end_inset
13422
13423
13424 \emph default
13425  option, by using
13426 \emph on
13427 #pragma\InsetSpace ~
13428 stackauto
13429 \emph default
13430
13431 \begin_inset LatexCommand \index{\#pragma stackauto}
13432
13433 \end_inset
13434
13435  or by using the
13436 \emph on
13437 reentrant
13438 \begin_inset LatexCommand \index{reentrant}
13439
13440 \end_inset
13441
13442
13443 \emph default
13444  keyword in the function declaration, e.g.:
13445 \end_layout
13446
13447 \begin_layout Verse
13448
13449 \family typewriter
13450 unsigned char foo(char i) __reentrant
13451 \newline
13452 {
13453 \newline
13454 \InsetSpace ~
13455 \InsetSpace ~
13456 \InsetSpace ~
13457 \InsetSpace ~
13458 ...
13459 \newline
13460 }
13461 \end_layout
13462
13463 \begin_layout Standard
13464 Since stack space on 8051 is limited, the
13465 \emph on
13466 reentrant
13467 \emph default
13468 keyword or the
13469 \emph on
13470  -
13471 \begin_inset ERT
13472 status collapsed
13473
13474 \begin_layout Standard
13475
13476
13477 \backslash
13478 /
13479 \end_layout
13480
13481 \end_inset
13482
13483 -stack-auto
13484 \emph default
13485  option should be used sparingly.
13486  Note that the reentrant keyword just means that the parameters & local
13487  variables will be allocated to the stack, it
13488 \emph on
13489 does not
13490 \emph default
13491  mean that the function is register bank
13492 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
13493
13494 \end_inset
13495
13496  independent.
13497 \newline
13498
13499 \newline
13500 Local variables
13501 \begin_inset LatexCommand \index{local variables}
13502
13503 \end_inset
13504
13505  can be assigned storage classes and absolute
13506 \begin_inset LatexCommand \index{Absolute addressing}
13507
13508 \end_inset
13509
13510  addresses, e.g.:
13511 \end_layout
13512
13513 \begin_layout Verse
13514
13515 \family typewriter
13516 unsigned char foo()
13517 \newline
13518 {
13519 \newline
13520 \InsetSpace ~
13521 \InsetSpace ~
13522 \InsetSpace ~
13523 \InsetSpace ~
13524 __xdata unsigned char i;
13525 \newline
13526 \InsetSpace ~
13527 \InsetSpace ~
13528 \InsetSpace ~
13529 \InsetSpace ~
13530 __bit bvar;
13531 \newline
13532 \InsetSpace ~
13533 \InsetSpace ~
13534 \InsetSpace ~
13535 \InsetSpace ~
13536 __data __at
13537 \begin_inset LatexCommand \index{at}
13538
13539 \end_inset
13540
13541  (0x31) unsigned char j;
13542 \newline
13543 \InsetSpace ~
13544 \InsetSpace ~
13545 \InsetSpace ~
13546 \InsetSpace ~
13547 ...
13548 \newline
13549 }
13550 \end_layout
13551
13552 \begin_layout Standard
13553 In the above example the variable
13554 \emph on
13555 i
13556 \emph default
13557  will be allocated in the external ram,
13558 \emph on
13559 bvar
13560 \emph default
13561  in bit addressable space and
13562 \emph on
13563  j
13564 \emph default
13565  in internal ram.
13566  When compiled with
13567 \emph on
13568 -
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 -stack-auto
13582 \emph default
13583  or when a function is declared as
13584 \emph on
13585 reentrant
13586 \emph default
13587  this should only be done for static variables.
13588 \end_layout
13589
13590 \begin_layout Standard
13591 Parameters
13592 \begin_inset LatexCommand \index{function parameter}
13593
13594 \end_inset
13595
13596  however are not allowed any storage class
13597 \begin_inset LatexCommand \index{Storage class}
13598
13599 \end_inset
13600
13601 , (storage classes for parameters will be ignored), their allocation is
13602  governed by the memory model in use, and the reentrancy options.
13603 \end_layout
13604
13605 \begin_layout Standard
13606 It is however allowed to use bit parameters in reentrant functions and also
13607  non-static local bit variables are supported.
13608  Efficient use is limited to 8 semi-bitregisters in bit space.
13609  They are pushed and popped to stack
13610 \begin_inset LatexCommand \index{stack}
13611
13612 \end_inset
13613
13614  as a single byte just like the normal registers.
13615 \end_layout
13616
13617 \begin_layout Section
13618 Overlaying
13619 \begin_inset LatexCommand \label{sub:Overlaying}
13620
13621 \end_inset
13622
13623
13624 \begin_inset LatexCommand \index{Overlaying}
13625
13626 \end_inset
13627
13628
13629 \end_layout
13630
13631 \begin_layout Standard
13632 For non-reentrant
13633 \begin_inset LatexCommand \index{reentrant}
13634
13635 \end_inset
13636
13637  functions SDCC will try to reduce internal ram space usage by overlaying
13638  parameters and local variables of a function (if possible).
13639  Parameters and local variables
13640 \begin_inset LatexCommand \index{local variables}
13641
13642 \end_inset
13643
13644  of a function will be allocated to an overlayable segment if the function
13645  has
13646 \emph on
13647 no other function calls and the function is non-reentrant and the memory
13648  model
13649 \begin_inset LatexCommand \index{Memory model}
13650
13651 \end_inset
13652
13653  is small.
13654
13655 \emph default
13656  If an explicit storage class
13657 \begin_inset LatexCommand \index{Storage class}
13658
13659 \end_inset
13660
13661  is specified for a local variable, it will NOT be overlayed.
13662 \end_layout
13663
13664 \begin_layout Standard
13665 Note that the compiler (not the linkage editor) makes the decision for overlayin
13666 g the data items.
13667  Functions that are called from an interrupt service routine
13668 \begin_inset Marginal
13669 status collapsed
13670
13671 \begin_layout Standard
13672
13673 \series bold
13674 !
13675 \end_layout
13676
13677 \end_inset
13678
13679  should be preceded by a #pragma\InsetSpace ~
13680 nooverlay
13681 \begin_inset LatexCommand \index{\#pragma nooverlay}
13682
13683 \end_inset
13684
13685  if they are not reentrant.
13686 \end_layout
13687
13688 \begin_layout Standard
13689 Also note that the compiler does not do any processing of inline assembler
13690  code, so the compiler might incorrectly assign local variables and parameters
13691  of a function into the overlay segment if the inline assembler code calls
13692  other c-functions that might use the overlay.
13693  In that case the #pragma\InsetSpace ~
13694 nooverlay should be used.
13695 \end_layout
13696
13697 \begin_layout Standard
13698 Parameters and local variables of functions that contain 16 or 32 bit multiplica
13699 tion
13700 \begin_inset LatexCommand \index{Multiplication}
13701
13702 \end_inset
13703
13704  or division
13705 \begin_inset LatexCommand \index{Division}
13706
13707 \end_inset
13708
13709  will NOT be overlayed since these are implemented using external functions,
13710  e.g.:
13711 \end_layout
13712
13713 \begin_layout Verse
13714
13715 \family typewriter
13716 #pragma save
13717 \newline
13718 #pragma nooverlay
13719 \begin_inset LatexCommand \index{\#pragma nooverlay}
13720
13721 \end_inset
13722
13723
13724 \newline
13725 void set_error(unsigned char errcd)
13726 \newline
13727 {
13728 \newline
13729 \InsetSpace ~
13730 \InsetSpace ~
13731 \InsetSpace ~
13732 \InsetSpace ~
13733 P3 = errcd;
13734 \newline
13735 }
13736 \newline
13737 #pragma restore
13738 \newline
13739
13740 \newline
13741 void some_isr
13742  () __interrupt
13743 \begin_inset LatexCommand \index{interrupt}
13744
13745 \end_inset
13746
13747  (2)
13748 \newline
13749 {
13750 \newline
13751 \InsetSpace ~
13752 \InsetSpace ~
13753 \InsetSpace ~
13754 \InsetSpace ~
13755 ...
13756 \newline
13757 \InsetSpace ~
13758 \InsetSpace ~
13759 \InsetSpace ~
13760 \InsetSpace ~
13761 set_error(10);
13762 \newline
13763 \InsetSpace ~
13764 \InsetSpace ~
13765 \InsetSpace ~
13766 \InsetSpace ~
13767 ...
13768 \newline
13769 }
13770 \end_layout
13771
13772 \begin_layout Standard
13773 In the above example the parameter
13774 \emph on
13775 errcd
13776 \emph default
13777  for the function
13778 \emph on
13779 set_error
13780 \emph default
13781  would be assigned to the overlayable segment if the #pragma\InsetSpace ~
13782 nooverlay was
13783  not present, this could cause unpredictable runtime behavior when called
13784  from an interrupt service routine.
13785  The #pragma\InsetSpace ~
13786 nooverlay ensures that the parameters and local variables for
13787  the function are NOT overlayed.
13788 \begin_inset VSpace bigskip
13789 \end_inset
13790
13791
13792 \end_layout
13793
13794 \begin_layout Section
13795 Interrupt Service Routines
13796 \begin_inset LatexCommand \label{sub:Interrupt-Service-Routines}
13797
13798 \end_inset
13799
13800
13801 \end_layout
13802
13803 \begin_layout Subsection
13804 General Information
13805 \end_layout
13806
13807 \begin_layout Standard
13808 SDCC allows
13809 \emph on
13810 i
13811 \emph default
13812 nterrupt
13813 \emph on
13814 s
13815 \emph default
13816 ervice
13817 \emph on
13818 r
13819 \emph default
13820 outines to be coded in C, with some extended keywords.
13821 \end_layout
13822
13823 \begin_layout Verse
13824
13825 \family typewriter
13826 void timer_isr (void) __interrupt (1) __using (1)
13827 \newline
13828 {
13829 \newline
13830 \InsetSpace ~
13831 \InsetSpace ~
13832 \InsetSpace ~
13833 \InsetSpace ~
13834 ...
13835 \newline
13836 }
13837 \end_layout
13838
13839 \begin_layout Standard
13840 The optional number following the
13841 \emph on
13842 interrupt
13843 \begin_inset LatexCommand \index{interrupt}
13844
13845 \end_inset
13846
13847
13848 \begin_inset LatexCommand \index{\_\_interrupt}
13849
13850 \end_inset
13851
13852
13853 \emph default
13854  keyword is the interrupt number this routine will service.
13855  When present, the compiler will insert a call to this routine in the interrupt
13856  vector table
13857 \begin_inset LatexCommand \index{interrupt vector table}
13858
13859 \end_inset
13860
13861  for the interrupt number specified.
13862  If you have multiple source files in your project, interrupt service routines
13863  can be present in any of them, but a prototype of the isr MUST be present
13864  or included in the file that contains the function
13865 \emph on
13866 main
13867 \emph default
13868 .
13869  The optional (8051 specific) keyword
13870 \emph on
13871 using
13872 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
13873
13874 \end_inset
13875
13876
13877 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
13878
13879 \end_inset
13880
13881
13882 \emph default
13883  can be used to tell the compiler to use the specified register bank when
13884  generating code for this function.
13885 \newline
13886 Interrupt service routines open the door
13887  for some very interesting bugs:
13888 \end_layout
13889
13890 \begin_layout Subsubsection
13891 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-volatile}
13892
13893 \end_inset
13894
13895 Common interrupt pitfall: variable not declared
13896 \emph on
13897 volatile
13898 \end_layout
13899
13900 \begin_layout Standard
13901 If an interrupt service routine changes variables which are accessed by
13902  other functions these variables have to be declared
13903 \emph on
13904 volatile
13905 \emph default
13906
13907 \begin_inset LatexCommand \index{volatile}
13908
13909 \end_inset
13910
13911 .
13912  See
13913 \begin_inset LatexCommand \url{http://en.wikipedia.org/wiki/Volatile_variable}
13914
13915 \end_inset
13916
13917  .
13918 \end_layout
13919
13920 \begin_layout Subsubsection
13921 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-atomic}
13922
13923 \end_inset
13924
13925 Common interrupt pitfall:
13926 \emph on
13927 non-atomic access
13928 \end_layout
13929
13930 \begin_layout Standard
13931 If the access to these variables is not
13932 \emph on
13933 atomic
13934 \begin_inset LatexCommand \index{atomic}
13935
13936 \end_inset
13937
13938
13939 \emph default
13940  (i.e.
13941  the processor needs more than one instruction for the access and could
13942  be interrupted while accessing the variable) the interrupt must be disabled
13943  during the access to avoid inconsistent data.
13944 \newline
13945 Access to 16 or 32 bit variables
13946  is obviously not atomic on 8 bit CPUs and should be protected by disabling
13947  interrupts.
13948  You're not automatically on the safe side if you use 8 bit variables though.
13949  We need an example here: f.e.
13950  on the 8051 the harmless looking
13951 \begin_inset Quotes srd
13952 \end_inset
13953
13954
13955 \family typewriter
13956 flags\InsetSpace ~
13957 |=\InsetSpace ~
13958 0x80;
13959 \family default
13960
13961 \begin_inset Quotes sld
13962 \end_inset
13963
13964  is not atomic if
13965 \family typewriter
13966 flags
13967 \family default
13968  resides in xdata.
13969  Setting
13970 \begin_inset Quotes srd
13971 \end_inset
13972
13973
13974 \family typewriter
13975 flags\InsetSpace ~
13976 |=\InsetSpace ~
13977 0x40;
13978 \family default
13979
13980 \begin_inset Quotes sld
13981 \end_inset
13982
13983  from within an interrupt routine might get lost if the interrupt occurs
13984  at the wrong time.
13985 \begin_inset Quotes sld
13986 \end_inset
13987
13988
13989 \family typewriter
13990 counter\InsetSpace ~
13991 +=\InsetSpace ~
13992 8;
13993 \family default
13994
13995 \begin_inset Quotes srd
13996 \end_inset
13997
13998  is not atomic on the 8051 even if
13999 \family typewriter
14000 counter
14001 \family default
14002  is located in data memory.
14003 \newline
14004 Bugs like these are hard to reproduce and can
14005  cause a lot of trouble.
14006 \end_layout
14007
14008 \begin_layout Subsubsection
14009 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-stack-overflow}
14010
14011 \end_inset
14012
14013 Common interrupt pitfall:
14014 \emph on
14015 stack overflow
14016 \end_layout
14017
14018 \begin_layout Standard
14019 The return address and the registers used in the interrupt service routine
14020  are saved on the stack
14021 \begin_inset LatexCommand \index{stack}
14022
14023 \end_inset
14024
14025  so there must be sufficient stack space.
14026  If there isn't variables or registers (or even the return address itself)
14027  will be corrupted.
14028  This
14029 \emph on
14030 stack overflow
14031 \emph default
14032
14033 \begin_inset LatexCommand \index{stack overflow}
14034
14035 \end_inset
14036
14037  is most likely to happen if the interrupt occurs during the
14038 \begin_inset Quotes sld
14039 \end_inset
14040
14041 deepest
14042 \begin_inset Quotes srd
14043 \end_inset
14044
14045  subroutine when the stack is already in use for f.e.
14046  many return addresses.
14047 \end_layout
14048
14049 \begin_layout Subsubsection
14050 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-reentrant}
14051
14052 \end_inset
14053
14054 Common interrupt pitfall:
14055 \emph on
14056 use of non-reentrant functions
14057 \end_layout
14058
14059 \begin_layout Standard
14060 A special note here, int (16 bit) and long (32 bit) integer division
14061 \begin_inset LatexCommand \index{Division}
14062
14063 \end_inset
14064
14065 , multiplication
14066 \begin_inset LatexCommand \index{Multiplication}
14067
14068 \end_inset
14069
14070  & modulus
14071 \begin_inset LatexCommand \index{Modulus}
14072
14073 \end_inset
14074
14075  and floating-point
14076 \begin_inset LatexCommand \index{Floating point support}
14077
14078 \end_inset
14079
14080  operations are implemented using external support routines.
14081  If an interrupt service routine needs to do any of these operations then
14082  the support routines (as mentioned in a following section) will have to
14083  be recompiled using the
14084 \emph on
14085  -
14086 \begin_inset ERT
14087 status collapsed
14088
14089 \begin_layout Standard
14090
14091
14092 \backslash
14093 /
14094 \end_layout
14095
14096 \end_inset
14097
14098 -stack-auto
14099 \begin_inset LatexCommand \index{-\/-stack-auto}
14100
14101 \end_inset
14102
14103
14104 \emph default
14105  option and the source file will need to be compiled using the
14106 \emph on
14107 -
14108 \begin_inset ERT
14109 status collapsed
14110
14111 \begin_layout Standard
14112
14113
14114 \backslash
14115 /
14116 \end_layout
14117
14118 \end_inset
14119
14120 -int-long-reent
14121 \emph default
14122
14123 \begin_inset LatexCommand \index{-\/-int-long-reent}
14124
14125 \end_inset
14126
14127  compiler option.
14128 \newline
14129 Note, the type promotion
14130 \begin_inset LatexCommand \index{type promotion}
14131
14132 \end_inset
14133
14134  required by ANSI C can cause 16 bit routines to be used
14135 \begin_inset Marginal
14136 status collapsed
14137
14138 \begin_layout Standard
14139
14140 \series bold
14141 \InsetSpace ~
14142 !
14143 \end_layout
14144
14145 \end_inset
14146
14147  without the programmer being aware of it.
14148  See f.e.
14149  the cast
14150 \family typewriter
14151 (unsigned char)(tail-1)
14152 \family default
14153  within the if clause in section
14154 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
14155
14156 \end_inset
14157
14158 .
14159 \end_layout
14160
14161 \begin_layout Standard
14162 Calling other functions from an interrupt service routine is not recommended,
14163  avoid it if possible.
14164  Note that when some function is called from an interrupt service routine
14165  it should be preceded by a #pragma\InsetSpace ~
14166 nooverlay
14167 \begin_inset LatexCommand \index{\#pragma nooverlay}
14168
14169 \end_inset
14170
14171  if it is not reentrant.
14172  Furthermore nonreentrant functions should not be called from the main program
14173  while the interrupt service routine might be active.
14174  They also must not be called from low priority interrupt service routines
14175  while a high priority interrupt service routine might be active.
14176  You could use semaphores or make the function
14177 \emph on
14178  critical
14179 \emph default
14180  if all parameters are passed in registers.
14181 \newline
14182  Also see section
14183 \begin_inset LatexCommand \ref{sub:Overlaying}
14184
14185 \end_inset
14186
14187 \InsetSpace ~
14188 about Overlaying and section
14189 \begin_inset LatexCommand \ref{sub:Functions-using-private-banks}
14190
14191 \end_inset
14192
14193 \InsetSpace ~
14194 about Functions using private register banks.
14195 \begin_inset VSpace bigskip
14196 \end_inset
14197
14198
14199 \end_layout
14200
14201 \begin_layout Subsection
14202 MCS51/DS390 Interrupt Service Routines
14203 \end_layout
14204
14205 \begin_layout Standard
14206 Interrupt
14207 \begin_inset LatexCommand \index{interrupt}
14208
14209 \end_inset
14210
14211  numbers and the corresponding address & descriptions for the Standard 8051/8052
14212  are listed below.
14213  SDCC will automatically adjust the
14214 \begin_inset LatexCommand \index{interrupt vector table}
14215
14216 \end_inset
14217
14218  to the maximum interrupt number specified.
14219 \newline
14220
14221 \end_layout
14222
14223 \begin_layout Standard
14224 \align center
14225 \begin_inset Tabular
14226 <lyxtabular version="3" rows="9" columns="3">
14227 <features>
14228 <column alignment="center" valignment="top" leftline="true" width="0in">
14229 <column alignment="left" valignment="top" leftline="true" width="0in">
14230 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0in">
14231 <row topline="true" bottomline="true">
14232 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14233 \begin_inset Text
14234
14235 \begin_layout Standard
14236 Interrupt #
14237 \end_layout
14238
14239 \end_inset
14240 </cell>
14241 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14242 \begin_inset Text
14243
14244 \begin_layout Standard
14245 Description
14246 \end_layout
14247
14248 \end_inset
14249 </cell>
14250 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14251 \begin_inset Text
14252
14253 \begin_layout Standard
14254 Vector Address
14255 \end_layout
14256
14257 \end_inset
14258 </cell>
14259 </row>
14260 <row topline="true">
14261 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14262 \begin_inset Text
14263
14264 \begin_layout Standard
14265 0
14266 \end_layout
14267
14268 \end_inset
14269 </cell>
14270 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14271 \begin_inset Text
14272
14273 \begin_layout Standard
14274 External 0
14275 \end_layout
14276
14277 \end_inset
14278 </cell>
14279 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14280 \begin_inset Text
14281
14282 \begin_layout Standard
14283 0x0003
14284 \end_layout
14285
14286 \end_inset
14287 </cell>
14288 </row>
14289 <row topline="true">
14290 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14291 \begin_inset Text
14292
14293 \begin_layout Standard
14294 1
14295 \end_layout
14296
14297 \end_inset
14298 </cell>
14299 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14300 \begin_inset Text
14301
14302 \begin_layout Standard
14303 Timer 0
14304 \end_layout
14305
14306 \end_inset
14307 </cell>
14308 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14309 \begin_inset Text
14310
14311 \begin_layout Standard
14312 0x000b
14313 \end_layout
14314
14315 \end_inset
14316 </cell>
14317 </row>
14318 <row topline="true">
14319 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14320 \begin_inset Text
14321
14322 \begin_layout Standard
14323 2
14324 \end_layout
14325
14326 \end_inset
14327 </cell>
14328 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14329 \begin_inset Text
14330
14331 \begin_layout Standard
14332 External 1
14333 \end_layout
14334
14335 \end_inset
14336 </cell>
14337 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14338 \begin_inset Text
14339
14340 \begin_layout Standard
14341 0x0013
14342 \end_layout
14343
14344 \end_inset
14345 </cell>
14346 </row>
14347 <row topline="true">
14348 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14349 \begin_inset Text
14350
14351 \begin_layout Standard
14352 3
14353 \end_layout
14354
14355 \end_inset
14356 </cell>
14357 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14358 \begin_inset Text
14359
14360 \begin_layout Standard
14361 Timer 1
14362 \end_layout
14363
14364 \end_inset
14365 </cell>
14366 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14367 \begin_inset Text
14368
14369 \begin_layout Standard
14370 0x001b
14371 \end_layout
14372
14373 \end_inset
14374 </cell>
14375 </row>
14376 <row topline="true">
14377 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14378 \begin_inset Text
14379
14380 \begin_layout Standard
14381 4
14382 \end_layout
14383
14384 \end_inset
14385 </cell>
14386 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14387 \begin_inset Text
14388
14389 \begin_layout Standard
14390 Serial
14391 \end_layout
14392
14393 \end_inset
14394 </cell>
14395 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14396 \begin_inset Text
14397
14398 \begin_layout Standard
14399 0x0023
14400 \end_layout
14401
14402 \end_inset
14403 </cell>
14404 </row>
14405 <row topline="true">
14406 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14407 \begin_inset Text
14408
14409 \begin_layout Standard
14410 5
14411 \end_layout
14412
14413 \end_inset
14414 </cell>
14415 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14416 \begin_inset Text
14417
14418 \begin_layout Standard
14419 Timer 2 (8052)
14420 \end_layout
14421
14422 \end_inset
14423 </cell>
14424 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14425 \begin_inset Text
14426
14427 \begin_layout Standard
14428 0x002b
14429 \end_layout
14430
14431 \end_inset
14432 </cell>
14433 </row>
14434 <row topline="true">
14435 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14436 \begin_inset Text
14437
14438 \begin_layout Standard
14439 ...
14440 \end_layout
14441
14442 \end_inset
14443 </cell>
14444 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14445 \begin_inset Text
14446
14447 \begin_layout Standard
14448
14449 \end_layout
14450
14451 \end_inset
14452 </cell>
14453 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14454 \begin_inset Text
14455
14456 \begin_layout Standard
14457 ...
14458 \end_layout
14459
14460 \end_inset
14461 </cell>
14462 </row>
14463 <row topline="true" bottomline="true">
14464 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14465 \begin_inset Text
14466
14467 \begin_layout Standard
14468 n
14469 \end_layout
14470
14471 \end_inset
14472 </cell>
14473 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14474 \begin_inset Text
14475
14476 \begin_layout Standard
14477
14478 \end_layout
14479
14480 \end_inset
14481 </cell>
14482 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14483 \begin_inset Text
14484
14485 \begin_layout Standard
14486 0x0003 + 8*n
14487 \end_layout
14488
14489 \end_inset
14490 </cell>
14491 </row>
14492 </lyxtabular>
14493
14494 \end_inset
14495
14496
14497 \newline
14498
14499 \end_layout
14500
14501 \begin_layout Standard
14502 If the interrupt service routine is defined without
14503 \emph on
14504 using
14505 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
14506
14507 \end_inset
14508
14509
14510 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
14511
14512 \end_inset
14513
14514
14515 \emph default
14516  a register bank or with register bank 0 (
14517 \emph on
14518 using
14519 \emph default
14520  0), the compiler will save the registers used by itself on the stack upon
14521  entry and restore them at exit, however if such an interrupt service routine
14522  calls another function then the entire register bank will be saved on the
14523  stack.
14524  This scheme may be advantageous for small interrupt service routines which
14525  have low register usage.
14526 \end_layout
14527
14528 \begin_layout Standard
14529 If the interrupt service routine is defined to be using a specific register
14530  bank then only
14531 \emph on
14532 a, b, dptr
14533 \emph default
14534  & psw are saved and restored, if such an interrupt service routine calls
14535  another function (using another register bank) then the entire register
14536  bank of the called function will be saved on the stack
14537 \begin_inset LatexCommand \index{stack}
14538
14539 \end_inset
14540
14541 .
14542  This scheme is recommended for larger interrupt service routines.
14543 \begin_inset VSpace bigskip
14544 \end_inset
14545
14546
14547 \end_layout
14548
14549 \begin_layout Subsection
14550 HC08
14551 \begin_inset LatexCommand \index{HC08}
14552
14553 \end_inset
14554
14555  Interrupt Service Routines
14556 \end_layout
14557
14558 \begin_layout Standard
14559 Since the number of interrupts
14560 \begin_inset LatexCommand \index{HC08!interrupt}
14561
14562 \end_inset
14563
14564  available is chip specific and the interrupt vector table always ends at
14565  the last byte of memory, the interrupt numbers corresponds to the interrupt
14566  vectors in reverse order of address.
14567  For example, interrupt 1 will use the interrupt vector at 0xfffc, interrupt
14568  2 will use the interrupt vector at 0xfffa, and so on.
14569  However, interrupt 0 (the reset vector at 0xfffe) is not redefinable in
14570  this way; instead see section
14571 \begin_inset LatexCommand \ref{sub:Startup-Code}
14572
14573 \end_inset
14574
14575  for details on customizing startup.
14576 \begin_inset VSpace bigskip
14577 \end_inset
14578
14579
14580 \end_layout
14581
14582 \begin_layout Subsection
14583 Z80 Interrupt Service Routines
14584 \end_layout
14585
14586 \begin_layout Standard
14587 The Z80
14588 \begin_inset LatexCommand \index{Z80}
14589
14590 \end_inset
14591
14592  uses several different methods for determining the correct interrupt
14593 \begin_inset LatexCommand \index{Z80!interrupt}
14594
14595 \end_inset
14596
14597  vector depending on the hardware implementation.
14598  Therefore, SDCC ignores the optional interrupt number and does not attempt
14599  to generate an interrupt vector table.
14600 \end_layout
14601
14602 \begin_layout Standard
14603 By default, SDCC generates code for a maskable interrupt, which uses a RETI
14604  instruction to return from the interrupt.
14605  To write an interrupt handler for the non-maskable interrupt, which needs
14606  a RETN instruction instead, add the
14607 \emph on
14608 critical
14609 \emph default
14610  keyword:
14611 \end_layout
14612
14613 \begin_layout Verse
14614
14615 \family typewriter
14616 void nmi_isr (void) critical interrupt
14617 \newline
14618 {
14619 \newline
14620 \InsetSpace ~
14621 \InsetSpace ~
14622 \InsetSpace ~
14623 \InsetSpace ~
14624 ...
14625 \newline
14626 }
14627 \end_layout
14628
14629 \begin_layout Standard
14630 However if you need to create a non-interruptable interrupt service routine
14631  you would also require the
14632 \emph on
14633 critical
14634 \emph default
14635  keyword.
14636  To distinguish between this and an nmi_isr you must provide an interrupt
14637  number.
14638 \begin_inset VSpace bigskip
14639 \end_inset
14640
14641
14642 \end_layout
14643
14644 \begin_layout Section
14645 Enabling and Disabling Interrupts
14646 \end_layout
14647
14648 \begin_layout Subsection
14649 Critical Functions and Critical Statements
14650 \end_layout
14651
14652 \begin_layout Standard
14653 A special keyword may be associated with a block or a function declaring
14654  it as
14655 \emph on
14656 critical
14657 \emph default
14658 .
14659  SDCC will generate code to disable all interrupts
14660 \begin_inset LatexCommand \index{interrupt}
14661
14662 \end_inset
14663
14664  upon entry to a critical function and restore the interrupt enable to the
14665  previous state before returning.
14666  Nesting critical functions will need one additional byte on the stack
14667 \begin_inset LatexCommand \index{stack}
14668
14669 \end_inset
14670
14671  for each call.
14672 \end_layout
14673
14674 \begin_layout Verse
14675
14676 \family typewriter
14677 int foo () __critical
14678 \begin_inset LatexCommand \index{critical}
14679
14680 \end_inset
14681
14682
14683 \begin_inset LatexCommand \index{\_\_critical}
14684
14685 \end_inset
14686
14687
14688 \newline
14689 {
14690 \newline
14691 \InsetSpace ~
14692 \InsetSpace ~
14693 \InsetSpace ~
14694 \InsetSpace ~
14695 ...
14696 \newline
14697 \InsetSpace ~
14698 \InsetSpace ~
14699 \InsetSpace ~
14700 \InsetSpace ~
14701 ...
14702 \newline
14703 }
14704 \end_layout
14705
14706 \begin_layout Standard
14707 The critical attribute maybe used with other attributes like
14708 \emph on
14709 reentrant.
14710 \emph default
14711
14712 \newline
14713 The keyword
14714 \emph on
14715 critical
14716 \emph default
14717  may also be used to disable interrupts more locally:
14718 \end_layout
14719
14720 \begin_layout Verse
14721
14722 \family typewriter
14723 __critical{ i++; }
14724 \end_layout
14725
14726 \begin_layout Standard
14727 More than one statement could have been included in the block.
14728 \end_layout
14729
14730 \begin_layout Subsection
14731 Enabling and Disabling Interrupts directly
14732 \end_layout
14733
14734 \begin_layout Standard
14735 Interrupts
14736 \begin_inset LatexCommand \index{interrupt}
14737
14738 \end_inset
14739
14740  can also be disabled and enabled directly (8051):
14741 \end_layout
14742
14743 \begin_layout Verse
14744
14745 \family typewriter
14746 EA = 0;\InsetSpace ~
14747 \InsetSpace ~
14748 \InsetSpace ~
14749 \InsetSpace ~
14750 \InsetSpace ~
14751 \InsetSpace ~
14752 \InsetSpace ~
14753 \InsetSpace ~
14754 \InsetSpace ~
14755 \InsetSpace ~
14756 \InsetSpace ~
14757 \InsetSpace ~
14758 or:\InsetSpace ~
14759 \InsetSpace ~
14760 \InsetSpace ~
14761 \InsetSpace ~
14762 \InsetSpace ~
14763 \InsetSpace ~
14764 \InsetSpace ~
14765 \InsetSpace ~
14766 \InsetSpace ~
14767 \InsetSpace ~
14768 \InsetSpace ~
14769 EA_SAVE = EA;
14770 \end_layout
14771
14772 \begin_layout Verse
14773
14774 \family typewriter
14775 ...\InsetSpace ~
14776 \InsetSpace ~
14777 \InsetSpace ~
14778 \InsetSpace ~
14779 \InsetSpace ~
14780 \InsetSpace ~
14781 \InsetSpace ~
14782 \InsetSpace ~
14783 \InsetSpace ~
14784 \InsetSpace ~
14785 \InsetSpace ~
14786 \InsetSpace ~
14787 \InsetSpace ~
14788 \InsetSpace ~
14789 \InsetSpace ~
14790 \InsetSpace ~
14791 \InsetSpace ~
14792 \InsetSpace ~
14793 \InsetSpace ~
14794 \InsetSpace ~
14795 \InsetSpace ~
14796 \InsetSpace ~
14797 \InsetSpace ~
14798 \InsetSpace ~
14799 \InsetSpace ~
14800 \InsetSpace ~
14801 \InsetSpace ~
14802 \InsetSpace ~
14803 \InsetSpace ~
14804 \InsetSpace ~
14805 EA = 0;
14806 \end_layout
14807
14808 \begin_layout Verse
14809
14810 \family typewriter
14811 EA = 1;\InsetSpace ~
14812 \InsetSpace ~
14813 \InsetSpace ~
14814 \InsetSpace ~
14815 \InsetSpace ~
14816 \InsetSpace ~
14817 \InsetSpace ~
14818 \InsetSpace ~
14819 \InsetSpace ~
14820 \InsetSpace ~
14821 \InsetSpace ~
14822 \InsetSpace ~
14823 \InsetSpace ~
14824 \InsetSpace ~
14825 \InsetSpace ~
14826 \InsetSpace ~
14827 \InsetSpace ~
14828 \InsetSpace ~
14829 \InsetSpace ~
14830 \InsetSpace ~
14831 \InsetSpace ~
14832 \InsetSpace ~
14833 \InsetSpace ~
14834 \InsetSpace ~
14835 \InsetSpace ~
14836 \InsetSpace ~
14837 ...
14838 \end_layout
14839
14840 \begin_layout Verse
14841
14842 \family typewriter
14843 \InsetSpace ~
14844 \InsetSpace ~
14845 \InsetSpace ~
14846 \InsetSpace ~
14847 \InsetSpace ~
14848 \InsetSpace ~
14849 \InsetSpace ~
14850 \InsetSpace ~
14851 \InsetSpace ~
14852 \InsetSpace ~
14853 \InsetSpace ~
14854 \InsetSpace ~
14855 \InsetSpace ~
14856 \InsetSpace ~
14857 \InsetSpace ~
14858 \InsetSpace ~
14859 \InsetSpace ~
14860 \InsetSpace ~
14861 \InsetSpace ~
14862 \InsetSpace ~
14863 \InsetSpace ~
14864 \InsetSpace ~
14865 \InsetSpace ~
14866 \InsetSpace ~
14867 \InsetSpace ~
14868 \InsetSpace ~
14869 \InsetSpace ~
14870 \InsetSpace ~
14871 \InsetSpace ~
14872 \InsetSpace ~
14873 \InsetSpace ~
14874 \InsetSpace ~
14875 \InsetSpace ~
14876 EA = EA_SAVE;
14877 \end_layout
14878
14879 \begin_layout Standard
14880 On other architectures which have seperate opcodes for enabling and disabling
14881  interrupts you might want to make use of defines with inline assembly
14882 \begin_inset LatexCommand \index{Assembler routines}
14883
14884 \end_inset
14885
14886  (HC08
14887 \begin_inset LatexCommand \index{HC08!interrupt}
14888
14889 \end_inset
14890
14891 ):
14892 \end_layout
14893
14894 \begin_layout Verse
14895
14896 \family typewriter
14897 #define CLI _asm
14898 \begin_inset LatexCommand \index{\_asm}
14899
14900 \end_inset
14901
14902 \InsetSpace ~
14903 \InsetSpace ~
14904 cli\InsetSpace ~
14905 \InsetSpace ~
14906 _endasm
14907 \begin_inset LatexCommand \index{\_endasm}
14908
14909 \end_inset
14910
14911 ;
14912 \end_layout
14913
14914 \begin_layout Verse
14915
14916 \family typewriter
14917 #define SEI _asm\InsetSpace ~
14918 \InsetSpace ~
14919 sei\InsetSpace ~
14920 \InsetSpace ~
14921 _endasm;
14922 \end_layout
14923
14924 \begin_layout Verse
14925
14926 \family typewriter
14927 ...
14928 \end_layout
14929
14930 \begin_layout Standard
14931 Note: it is sometimes sufficient to disable only a specific interrupt source
14932  like f.e.
14933  a timer or serial interrupt by manipulating an
14934 \emph on
14935 interrupt mask
14936 \begin_inset LatexCommand \index{interrupt mask}
14937
14938 \end_inset
14939
14940
14941 \emph default
14942  register.
14943 \end_layout
14944
14945 \begin_layout Standard
14946 Usually the time during which interrupts are disabled should be kept as
14947  short as possible.
14948  This minimizes both
14949 \emph on
14950 interrupt latency
14951 \emph default
14952
14953 \begin_inset LatexCommand \index{interrupt latency}
14954
14955 \end_inset
14956
14957  (the time between the occurrence of the interrupt and the execution of
14958  the first code in the interrupt routine) and
14959 \emph on
14960 interrupt jitter
14961 \emph default
14962
14963 \begin_inset LatexCommand \index{interrupt jitter}
14964
14965 \end_inset
14966
14967  (the difference between the shortest and the longest interrupt latency).
14968  These really are something different, f.e.
14969  a serial interrupt has to be served before its buffer overruns so it cares
14970  for the maximum interrupt latency, whereas it does not care about jitter.
14971  On a loudspeaker driven via a digital to analog converter which is fed
14972  by an interrupt a latency of a few milliseconds might be tolerable, whereas
14973  a much smaller jitter will be very audible.
14974 \end_layout
14975
14976 \begin_layout Standard
14977 You can reenable interrupts within an interrupt routine and on some architecture
14978 s you can make use of two (or more) levels of
14979 \emph on
14980 interrupt priorities
14981 \emph default
14982
14983 \begin_inset LatexCommand \index{interrupt priority}
14984
14985 \end_inset
14986
14987 .
14988  On some architectures which don't support interrupt priorities these can
14989  be implemented by manipulating the interrupt mask and reenabling interrupts
14990  within the interrupt routine.
14991  Check there is sufficient space on the stack
14992 \begin_inset LatexCommand \index{stack}
14993
14994 \end_inset
14995
14996  and don't add complexity unless you have to.
14997 \end_layout
14998
14999 \begin_layout Subsection
15000 Semaphore
15001 \begin_inset LatexCommand \index{semaphore}
15002
15003 \end_inset
15004
15005  locking (mcs51/ds390)
15006 \end_layout
15007
15008 \begin_layout Standard
15009 Some architectures (mcs51/ds390) have an atomic
15010 \begin_inset LatexCommand \index{atomic}
15011
15012 \end_inset
15013
15014  bit test andclearinstruction.
15015  These type of instructions are typically used in preemptive multitasking
15016  systems, where a routine f.e.
15017  claims the use of a data structure ('acquires a lock
15018 \begin_inset LatexCommand \index{lock}
15019
15020 \end_inset
15021
15022  on it'), makes some modifications and then releases the lock when the data
15023  structure is consistent again.
15024  The instruction may also be used if interrupt and non-interrupt code have
15025  to compete for a resource.
15026  With the atomic bit test and clear instruction interrupts
15027 \begin_inset LatexCommand \index{interrupt}
15028
15029 \end_inset
15030
15031  don't have to be disabled for the locking operation.
15032 \end_layout
15033
15034 \begin_layout Standard
15035 SDCC generates this instruction if the source follows this pattern:
15036 \end_layout
15037
15038 \begin_layout Verse
15039
15040 \family typewriter
15041 volatile
15042 \begin_inset LatexCommand \index{volatile}
15043
15044 \end_inset
15045
15046  bit resource_is_free;
15047 \newline
15048
15049 \newline
15050 if (resource_is_free)
15051 \newline
15052 \InsetSpace ~
15053 \InsetSpace ~
15054 {
15055 \newline
15056 \InsetSpace ~
15057 \InsetSpace ~
15058 \InsetSpace ~
15059 \InsetSpace ~
15060 resource_is_free=0;
15061 \newline
15062 \InsetSpace ~
15063 \InsetSpace ~
15064 \InsetSpace ~
15065 \InsetSpace ~
15066 ...
15067 \newline
15068 \InsetSpace ~
15069 \InsetSpace ~
15070 \InsetSpace ~
15071 \InsetSpace ~
15072 resource_is_free=
15073 1;
15074 \newline
15075 \InsetSpace ~
15076 \InsetSpace ~
15077 }
15078 \end_layout
15079
15080 \begin_layout Standard
15081 Note, mcs51 and ds390 support only an atomic
15082 \begin_inset LatexCommand \index{atomic}
15083
15084 \end_inset
15085
15086  bit test and
15087 \emph on
15088 clear
15089 \emph default
15090  instruction (as opposed to atomic bit test and
15091 \emph on
15092 set).
15093 \end_layout
15094
15095 \begin_layout Section
15096 Functions using private register banks
15097 \begin_inset LatexCommand \label{sub:Functions-using-private-banks}
15098
15099 \end_inset
15100
15101  (mcs51/ds390)
15102 \end_layout
15103
15104 \begin_layout Standard
15105 Some architectures have support for quickly changing register sets.
15106  SDCC supports this feature with the
15107 \emph on
15108 using
15109 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
15110
15111 \end_inset
15112
15113
15114 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
15115
15116 \end_inset
15117
15118
15119 \emph default
15120  attribute (which tells the compiler to use a register bank
15121 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
15122
15123 \end_inset
15124
15125  other than the default bank zero).
15126  It should only be applied to
15127 \emph on
15128 interrupt
15129 \begin_inset LatexCommand \index{interrupt}
15130
15131 \end_inset
15132
15133
15134 \emph default
15135  functions (see footnote below).
15136  This will in most circumstances make the generated ISR code more efficient
15137  since it will not have to save registers on the stack.
15138 \end_layout
15139
15140 \begin_layout Standard
15141 The
15142 \emph on
15143 using
15144 \emph default
15145  attribute will have no effect on the generated code for a
15146 \emph on
15147 non-interrupt
15148 \emph default
15149  function (but may occasionally be useful anyway
15150 \begin_inset Foot
15151 status open
15152
15153 \begin_layout Standard
15154 possible exception: if a function is called ONLY from 'interrupt' functions
15155  using a particular bank, it can be declared with the same 'using' attribute
15156  as the calling 'interrupt' functions.
15157  For instance, if you have several ISRs using bank one, and all of them
15158  call memcpy(), it might make sense to create a specialized version of memcpy()
15159  'using 1', since this would prevent the ISR from having to save bank zero
15160  to the stack on entry and switch to bank zero before calling the function
15161 \end_layout
15162
15163 \end_inset
15164
15165 ).
15166 \newline
15167
15168 \emph on
15169 (pending: Note, nowadays the
15170 \emph default
15171 using
15172 \emph on
15173  attribute has an effect onthe generated code for a
15174 \emph default
15175 non-interrupt
15176 \emph on
15177  function
15178 \emph default
15179 .
15180 \emph on
15181 )
15182 \end_layout
15183
15184 \begin_layout Standard
15185 An
15186 \emph on
15187 interrupt
15188 \emph default
15189  function using a non-zero bank will assume that it can trash that register
15190  bank, and will not save it.
15191  Since high-priority interrupts
15192 \begin_inset LatexCommand \index{interrupts}
15193
15194 \end_inset
15195
15196
15197 \begin_inset LatexCommand \index{interrupt priority}
15198
15199 \end_inset
15200
15201  can interrupt low-priority ones on the 8051 and friends, this means that
15202  if a high-priority ISR
15203 \emph on
15204 using
15205 \emph default
15206  a particular bank occurs while processing a low-priority ISR
15207 \emph on
15208 using
15209 \emph default
15210  the same bank, terrible and bad things can happen.
15211  To prevent this, no single register bank should be
15212 \emph on
15213 used
15214 \emph default
15215  by both a high priority and a low priority ISR.
15216  This is probably most easily done by having all high priority ISRs use
15217  one bank and all low priority ISRs use another.
15218  If you have an ISR which can change priority at runtime, you're on your
15219  own: I suggest using the default bank zero and taking the small performance
15220  hit.
15221 \end_layout
15222
15223 \begin_layout Standard
15224 It is most efficient if your ISR calls no other functions.
15225  If your ISR must call other functions, it is most efficient if those functions
15226  use the same bank as the ISR (see note 1 below); the next best is if the
15227  called functions use bank zero.
15228  It is very inefficient to call a function using a different, non-zero bank
15229  from an ISR.
15230 \begin_inset VSpace bigskip
15231 \end_inset
15232
15233
15234 \end_layout
15235
15236 \begin_layout Section
15237 Startup Code
15238 \begin_inset LatexCommand \label{sub:Startup-Code}
15239
15240 \end_inset
15241
15242
15243 \begin_inset LatexCommand \index{Startup code}
15244
15245 \end_inset
15246
15247
15248 \end_layout
15249
15250 \begin_layout Subsection
15251 MCS51/DS390 Startup Code
15252 \end_layout
15253
15254 \begin_layout Standard
15255 The compiler triggers the linker to link certain initialization modules
15256  from the runtime library
15257 \begin_inset LatexCommand \index{Runtime library}
15258
15259 \end_inset
15260
15261  called crt<something>.
15262  Only the necessary ones are linked, for instance crtxstack.asm (GSINIT1,
15263  GSINIT5) is not linked unless the -
15264 \series bold
15265
15266 \begin_inset ERT
15267 status open
15268
15269 \begin_layout Standard
15270
15271
15272 \backslash
15273 /
15274 \end_layout
15275
15276 \end_inset
15277
15278
15279 \series default
15280 -xstack option is used.
15281  These modules are highly entangled by the use of special segments/areas,
15282  but a common layout is shown below:
15283 \end_layout
15284
15285 \begin_layout Verse
15286
15287 \family typewriter
15288 \series bold
15289 \size footnotesize
15290 (main.asm)
15291 \end_layout
15292
15293 \begin_layout Verse
15294
15295 \family typewriter
15296 \size footnotesize
15297 \InsetSpace ~
15298 \InsetSpace ~
15299 \InsetSpace ~
15300 \InsetSpace ~
15301 \InsetSpace ~
15302 \InsetSpace ~
15303 \InsetSpace ~
15304 \InsetSpace ~
15305 .area HOME (CODE)
15306 \newline
15307 __interrupt_vect:
15308 \newline
15309 \InsetSpace ~
15310 \InsetSpace ~
15311 \InsetSpace ~
15312 \InsetSpace ~
15313 \InsetSpace ~
15314 \InsetSpace ~
15315 \InsetSpace ~
15316 \InsetSpace ~
15317 ljmp __sdcc_gsinit_startup
15318 \end_layout
15319
15320 \begin_layout Verse
15321
15322 \family typewriter
15323 \series bold
15324 \size footnotesize
15325 (crtstart.asm)
15326 \end_layout
15327
15328 \begin_layout Verse
15329
15330 \family typewriter
15331 \size footnotesize
15332 \InsetSpace ~
15333 \InsetSpace ~
15334 \InsetSpace ~
15335 \InsetSpace ~
15336 \InsetSpace ~
15337 \InsetSpace ~
15338 \InsetSpace ~
15339 \InsetSpace ~
15340 .area GSINIT0 (CODE)
15341 \newline
15342 __sdcc_gsinit_startup::
15343 \newline
15344 \InsetSpace ~
15345 \InsetSpace ~
15346 \InsetSpace ~
15347 \InsetSpace ~
15348 \InsetSpace ~
15349 \InsetSpace ~
15350 \InsetSpace ~
15351 \InsetSpace ~
15352 mov sp,#__start__stack - 1
15353 \end_layout
15354
15355 \begin_layout Verse
15356
15357 \family typewriter
15358 \series bold
15359 \size footnotesize
15360 (crtxstack.asm)
15361 \end_layout
15362
15363 \begin_layout Verse
15364
15365 \family typewriter
15366 \size footnotesize
15367 \InsetSpace ~
15368 \InsetSpace ~
15369 \InsetSpace ~
15370 \InsetSpace ~
15371 \InsetSpace ~
15372 \InsetSpace ~
15373 \InsetSpace ~
15374 \InsetSpace ~
15375 .area GSINIT1 (CODE)
15376 \newline
15377 __sdcc_init_xstack::
15378 \newline
15379 ; Need to initialize in GSINIT1 in
15380  case the user's __sdcc_external_startup uses the xstack.
15381 \newline
15382 \InsetSpace ~
15383 \InsetSpace ~
15384 \InsetSpace ~
15385 \InsetSpace ~
15386 \InsetSpace ~
15387 \InsetSpace ~
15388 \InsetSpace ~
15389 \InsetSpace ~
15390 mov __XPAGE,#(__start__x
15391 stack >> 8)
15392 \newline
15393 \InsetSpace ~
15394 \InsetSpace ~
15395 \InsetSpace ~
15396 \InsetSpace ~
15397 \InsetSpace ~
15398 \InsetSpace ~
15399 \InsetSpace ~
15400 \InsetSpace ~
15401 mov _spx,#__start__xstack
15402 \end_layout
15403
15404 \begin_layout Verse
15405
15406 \family typewriter
15407 \series bold
15408 \size footnotesize
15409 (crtstart.asm)
15410 \end_layout
15411
15412 \begin_layout Verse
15413
15414 \family typewriter
15415 \size footnotesize
15416 \InsetSpace ~
15417 \InsetSpace ~
15418 \InsetSpace ~
15419 \InsetSpace ~
15420 \InsetSpace ~
15421 \InsetSpace ~
15422 \InsetSpace ~
15423 \InsetSpace ~
15424 .area GSINIT2 (CODE)
15425 \newline
15426 \InsetSpace ~
15427 \InsetSpace ~
15428 \InsetSpace ~
15429 \InsetSpace ~
15430 \InsetSpace ~
15431 \InsetSpace ~
15432 \InsetSpace ~
15433 \InsetSpace ~
15434 lcall __sdcc_external_startup
15435 \newline
15436 \InsetSpace ~
15437 \InsetSpace ~
15438 \InsetSpace ~
15439 \InsetSpace ~
15440 \InsetSpace ~
15441 \InsetSpace ~
15442 \InsetSpace ~
15443 \InsetSpace ~
15444 mov a,dpl
15445 \newline
15446 \InsetSpace ~
15447 \InsetSpace ~
15448 \InsetSpace ~
15449 \InsetSpace ~
15450 \InsetSpace ~
15451 \InsetSpace ~
15452 \InsetSpace ~
15453 \InsetSpace ~
15454 jz __sdcc_init_data
15455 \newline
15456 \InsetSpace ~
15457 \InsetSpace ~
15458 \InsetSpace ~
15459 \InsetSpace ~
15460 \InsetSpace ~
15461 \InsetSpace ~
15462 \InsetSpace ~
15463 \InsetSpace ~
15464 ljmp
15465  __sdcc_program_startup
15466 \newline
15467 __sdcc_init_data:
15468 \end_layout
15469
15470 \begin_layout Verse
15471
15472 \family typewriter
15473 \series bold
15474 \size footnotesize
15475 (crtxinit.asm)
15476 \end_layout
15477
15478 \begin_layout Verse
15479
15480 \family typewriter
15481 \size footnotesize
15482 \InsetSpace ~
15483 \InsetSpace ~
15484 \InsetSpace ~
15485 \InsetSpace ~
15486 \InsetSpace ~
15487 \InsetSpace ~
15488 \InsetSpace ~
15489 \InsetSpace ~
15490 .area GSINIT3 (CODE)
15491 \newline
15492 __mcs51_genXINIT::
15493 \newline
15494 \InsetSpace ~
15495 \InsetSpace ~
15496 \InsetSpace ~
15497 \InsetSpace ~
15498 \InsetSpace ~
15499 \InsetSpace ~
15500 \InsetSpace ~
15501 \InsetSpace ~
15502 mov r1,#l_XINIT
15503 \newline
15504 \InsetSpace ~
15505 \InsetSpace ~
15506 \InsetSpace ~
15507 \InsetSpace ~
15508 \InsetSpace ~
15509 \InsetSpace ~
15510 \InsetSpace ~
15511 \InsetSpace ~
15512 mov a,r1
15513 \newline
15514 \InsetSpace ~
15515 \InsetSpace ~
15516 \InsetSpace ~
15517 \InsetSpace ~
15518 \InsetSpace ~
15519 \InsetSpace ~
15520 \InsetSpace ~
15521 \InsetSpace ~
15522 orl a,#(l_XINIT
15523  >> 8)
15524 \newline
15525 \InsetSpace ~
15526 \InsetSpace ~
15527 \InsetSpace ~
15528 \InsetSpace ~
15529 \InsetSpace ~
15530 \InsetSpace ~
15531 \InsetSpace ~
15532 \InsetSpace ~
15533 jz 00003$
15534 \newline
15535 \InsetSpace ~
15536 \InsetSpace ~
15537 \InsetSpace ~
15538 \InsetSpace ~
15539 \InsetSpace ~
15540 \InsetSpace ~
15541 \InsetSpace ~
15542 \InsetSpace ~
15543 mov r2,#((l_XINIT+255) >> 8)
15544 \newline
15545 \InsetSpace ~
15546 \InsetSpace ~
15547 \InsetSpace ~
15548 \InsetSpace ~
15549 \InsetSpace ~
15550 \InsetSpace ~
15551 \InsetSpace ~
15552 \InsetSpace ~
15553 mov dptr,#s_XINIT
15554 \newline
15555 \InsetSpace ~
15556 \InsetSpace ~
15557 \InsetSpace ~
15558 \InsetSpace ~
15559 \InsetSpace ~
15560 \InsetSpace ~
15561 \InsetSpace ~
15562 \InsetSpace ~
15563 mov r0,#s_XISEG
15564 \newline
15565 \InsetSpace ~
15566 \InsetSpace ~
15567 \InsetSpace ~
15568 \InsetSpace ~
15569 \InsetSpace ~
15570 \InsetSpace ~
15571 \InsetSpace ~
15572 \InsetSpace ~
15573 mov
15574  __XPAGE,#(s_XISEG >> 8)
15575 \newline
15576 00001$:\InsetSpace ~
15577 clr a
15578 \newline
15579 \InsetSpace ~
15580 \InsetSpace ~
15581 \InsetSpace ~
15582 \InsetSpace ~
15583 \InsetSpace ~
15584 \InsetSpace ~
15585 \InsetSpace ~
15586 \InsetSpace ~
15587 movc a,@a+dptr
15588 \newline
15589 \InsetSpace ~
15590 \InsetSpace ~
15591 \InsetSpace ~
15592 \InsetSpace ~
15593 \InsetSpace ~
15594 \InsetSpace ~
15595 \InsetSpace ~
15596 \InsetSpace ~
15597 movx @r0,a
15598 \newline
15599 \InsetSpace ~
15600 \InsetSpace ~
15601 \InsetSpace ~
15602 \InsetSpace ~
15603 \InsetSpace ~
15604 \InsetSpace ~
15605 \InsetSpace ~
15606 \InsetSpace ~
15607 inc dptr
15608 \newline
15609 \InsetSpace ~
15610 \InsetSpace ~
15611 \InsetSpace ~
15612 \InsetSpace ~
15613 \InsetSpace ~
15614 \InsetSpace ~
15615 \InsetSpace ~
15616 \InsetSpace ~
15617 inc
15618  r0
15619 \newline
15620 \InsetSpace ~
15621 \InsetSpace ~
15622 \InsetSpace ~
15623 \InsetSpace ~
15624 \InsetSpace ~
15625 \InsetSpace ~
15626 \InsetSpace ~
15627 \InsetSpace ~
15628 cjne r0,#0,00002$
15629 \newline
15630 \InsetSpace ~
15631 \InsetSpace ~
15632 \InsetSpace ~
15633 \InsetSpace ~
15634 \InsetSpace ~
15635 \InsetSpace ~
15636 \InsetSpace ~
15637 \InsetSpace ~
15638 inc __XPAGE
15639 \newline
15640 00002$:\InsetSpace ~
15641 djnz r1,00001$
15642 \newline
15643 \InsetSpace ~
15644 \InsetSpace ~
15645 \InsetSpace ~
15646 \InsetSpace ~
15647 \InsetSpace ~
15648 \InsetSpace ~
15649 \InsetSpace ~
15650 \InsetSpace ~
15651 djnz r2,00001$
15652 \newline
15653 \InsetSpace ~
15654 \InsetSpace ~
15655 \InsetSpace ~
15656 \InsetSpace ~
15657 \InsetSpace ~
15658 \InsetSpace ~
15659 \InsetSpace ~
15660 \InsetSpace ~
15661 mov __XPAGE,#0
15662 xFF
15663 \newline
15664 00003$:
15665 \end_layout
15666
15667 \begin_layout Verse
15668
15669 \family typewriter
15670 \series bold
15671 \size footnotesize
15672 (crtclear.asm)
15673 \end_layout
15674
15675 \begin_layout Verse
15676
15677 \family typewriter
15678 \size footnotesize
15679 \InsetSpace ~
15680 \InsetSpace ~
15681 \InsetSpace ~
15682 \InsetSpace ~
15683 \InsetSpace ~
15684 \InsetSpace ~
15685 \InsetSpace ~
15686 \InsetSpace ~
15687 .area GSINIT4 (CODE)
15688 \newline
15689 __mcs51_genRAMCLEAR::
15690 \newline
15691 \InsetSpace ~
15692 \InsetSpace ~
15693 \InsetSpace ~
15694 \InsetSpace ~
15695 \InsetSpace ~
15696 \InsetSpace ~
15697 \InsetSpace ~
15698 \InsetSpace ~
15699 clr a
15700 \newline
15701 \InsetSpace ~
15702 \InsetSpace ~
15703 \InsetSpace ~
15704 \InsetSpace ~
15705 \InsetSpace ~
15706 \InsetSpace ~
15707 \InsetSpace ~
15708 \InsetSpace ~
15709 mov r0,#(l_IRAM-1)
15710 \newline
15711 00004$:\InsetSpace ~
15712 mov
15713  @r0,a
15714 \newline
15715 \InsetSpace ~
15716 \InsetSpace ~
15717 \InsetSpace ~
15718 \InsetSpace ~
15719 \InsetSpace ~
15720 \InsetSpace ~
15721 \InsetSpace ~
15722 \InsetSpace ~
15723 djnz r0,00004$
15724 \newline
15725 ; _mcs51_genRAMCLEAR() end
15726 \end_layout
15727
15728 \begin_layout Verse
15729
15730 \family typewriter
15731 \series bold
15732 \size footnotesize
15733 (crtxclear.asm)
15734 \end_layout
15735
15736 \begin_layout Verse
15737
15738 \family typewriter
15739 \size footnotesize
15740 \InsetSpace ~
15741 \InsetSpace ~
15742 \InsetSpace ~
15743 \InsetSpace ~
15744 \InsetSpace ~
15745 \InsetSpace ~
15746 \InsetSpace ~
15747 \InsetSpace ~
15748 .area GSINIT4 (CODE)
15749 \newline
15750 __mcs51_genXRAMCLEAR::
15751 \newline
15752 \InsetSpace ~
15753 \InsetSpace ~
15754 \InsetSpace ~
15755 \InsetSpace ~
15756 \InsetSpace ~
15757 \InsetSpace ~
15758 \InsetSpace ~
15759 \InsetSpace ~
15760 mov r0,#l_PSEG
15761 \newline
15762 \InsetSpace ~
15763 \InsetSpace ~
15764 \InsetSpace ~
15765 \InsetSpace ~
15766 \InsetSpace ~
15767 \InsetSpace ~
15768 \InsetSpace ~
15769 \InsetSpace ~
15770 mov a,r0
15771 \newline
15772 \InsetSpace ~
15773 \InsetSpace ~
15774 \InsetSpace ~
15775 \InsetSpace ~
15776 \InsetSpace ~
15777 \InsetSpace ~
15778 \InsetSpace ~
15779 \InsetSpace ~
15780 orl a,#(l_PSEG
15781  >> 8)
15782 \newline
15783 \InsetSpace ~
15784 \InsetSpace ~
15785 \InsetSpace ~
15786 \InsetSpace ~
15787 \InsetSpace ~
15788 \InsetSpace ~
15789 \InsetSpace ~
15790 \InsetSpace ~
15791 jz 00006$
15792 \newline
15793 \InsetSpace ~
15794 \InsetSpace ~
15795 \InsetSpace ~
15796 \InsetSpace ~
15797 \InsetSpace ~
15798 \InsetSpace ~
15799 \InsetSpace ~
15800 \InsetSpace ~
15801 mov r1,#s_PSEG
15802 \newline
15803 \InsetSpace ~
15804 \InsetSpace ~
15805 \InsetSpace ~
15806 \InsetSpace ~
15807 \InsetSpace ~
15808 \InsetSpace ~
15809 \InsetSpace ~
15810 \InsetSpace ~
15811 mov __XPAGE,#(s_PSEG >> 8)
15812 \newline
15813 \InsetSpace ~
15814 \InsetSpace ~
15815 \InsetSpace ~
15816 \InsetSpace ~
15817 \InsetSpace ~
15818 \InsetSpace ~
15819 \InsetSpace ~
15820 \InsetSpace ~
15821 clr a
15822 \newline
15823 00005$:\InsetSpace ~
15824 movx
15825  @r1,a
15826 \newline
15827 \InsetSpace ~
15828 \InsetSpace ~
15829 \InsetSpace ~
15830 \InsetSpace ~
15831 \InsetSpace ~
15832 \InsetSpace ~
15833 \InsetSpace ~
15834 \InsetSpace ~
15835 inc r1
15836 \newline
15837 \InsetSpace ~
15838 \InsetSpace ~
15839 \InsetSpace ~
15840 \InsetSpace ~
15841 \InsetSpace ~
15842 \InsetSpace ~
15843 \InsetSpace ~
15844 \InsetSpace ~
15845 djnz r0,00005$
15846 \newline
15847 00006$:
15848 \newline
15849 \InsetSpace ~
15850 \InsetSpace ~
15851 \InsetSpace ~
15852 \InsetSpace ~
15853 \InsetSpace ~
15854 \InsetSpace ~
15855 \InsetSpace ~
15856 \InsetSpace ~
15857 mov r0,#l_XSEG
15858 \newline
15859 \InsetSpace ~
15860 \InsetSpace ~
15861 \InsetSpace ~
15862 \InsetSpace ~
15863 \InsetSpace ~
15864 \InsetSpace ~
15865 \InsetSpace ~
15866 \InsetSpace ~
15867 mov a,r0
15868 \newline
15869 \InsetSpace ~
15870 \InsetSpace ~
15871 \InsetSpace ~
15872 \InsetSpace ~
15873 \InsetSpace ~
15874 \InsetSpace ~
15875 \InsetSpace ~
15876 \InsetSpace ~
15877 orl a,#(l_XSEG >>
15878  8)
15879 \newline
15880 \InsetSpace ~
15881 \InsetSpace ~
15882 \InsetSpace ~
15883 \InsetSpace ~
15884 \InsetSpace ~
15885 \InsetSpace ~
15886 \InsetSpace ~
15887 \InsetSpace ~
15888 jz 00008$
15889 \newline
15890 \InsetSpace ~
15891 \InsetSpace ~
15892 \InsetSpace ~
15893 \InsetSpace ~
15894 \InsetSpace ~
15895 \InsetSpace ~
15896 \InsetSpace ~
15897 \InsetSpace ~
15898 mov r1,#((l_XSEG + 255) >> 8)
15899 \newline
15900 \InsetSpace ~
15901 \InsetSpace ~
15902 \InsetSpace ~
15903 \InsetSpace ~
15904 \InsetSpace ~
15905 \InsetSpace ~
15906 \InsetSpace ~
15907 \InsetSpace ~
15908 mov dptr,#s_XSEG
15909 \newline
15910 \InsetSpace ~
15911 \InsetSpace ~
15912 \InsetSpace ~
15913 \InsetSpace ~
15914 \InsetSpace ~
15915 \InsetSpace ~
15916 \InsetSpace ~
15917 \InsetSpace ~
15918 clr a
15919 \newline
15920 00007$:\InsetSpace ~
15921 movx
15922  @dptr,a
15923 \newline
15924 \InsetSpace ~
15925 \InsetSpace ~
15926 \InsetSpace ~
15927 \InsetSpace ~
15928 \InsetSpace ~
15929 \InsetSpace ~
15930 \InsetSpace ~
15931 \InsetSpace ~
15932 inc dptr
15933 \newline
15934 \InsetSpace ~
15935 \InsetSpace ~
15936 \InsetSpace ~
15937 \InsetSpace ~
15938 \InsetSpace ~
15939 \InsetSpace ~
15940 \InsetSpace ~
15941 \InsetSpace ~
15942 djnz r0,00007$
15943 \newline
15944 \InsetSpace ~
15945 \InsetSpace ~
15946 \InsetSpace ~
15947 \InsetSpace ~
15948 \InsetSpace ~
15949 \InsetSpace ~
15950 \InsetSpace ~
15951 \InsetSpace ~
15952 djnz r1,00007$
15953 \newline
15954 00008$:
15955 \end_layout
15956
15957 \begin_layout Verse
15958
15959 \family typewriter
15960 \series bold
15961 \size footnotesize
15962 (crtxstack.asm)
15963 \end_layout
15964
15965 \begin_layout Verse
15966
15967 \family typewriter
15968 \size footnotesize
15969 \InsetSpace ~
15970 \InsetSpace ~
15971 \InsetSpace ~
15972 \InsetSpace ~
15973 \InsetSpace ~
15974 \InsetSpace ~
15975 \InsetSpace ~
15976 \InsetSpace ~
15977 .area GSINIT5 (CODE)
15978 \newline
15979 ; Need to initialize in GSINIT5 because __mcs51_genXINIT
15980  modifies __XPAGE
15981 \newline
15982 ; and __mcs51_genRAMCLEAR modifies _spx.
15983 \newline
15984 \InsetSpace ~
15985 \InsetSpace ~
15986 \InsetSpace ~
15987 \InsetSpace ~
15988 \InsetSpace ~
15989 \InsetSpace ~
15990 \InsetSpace ~
15991 \InsetSpace ~
15992 mov __XPAGE,#(__start__x
15993 stack >> 8)
15994 \newline
15995 \InsetSpace ~
15996 \InsetSpace ~
15997 \InsetSpace ~
15998 \InsetSpace ~
15999 \InsetSpace ~
16000 \InsetSpace ~
16001 \InsetSpace ~
16002 \InsetSpace ~
16003 mov _spx,#__start__xstack
16004 \end_layout
16005
16006 \begin_layout Verse
16007
16008 \family typewriter
16009 \series bold
16010 \size footnotesize
16011 (application modules)
16012 \end_layout
16013
16014 \begin_layout Verse
16015
16016 \family typewriter
16017 \size footnotesize
16018 \InsetSpace ~
16019 \InsetSpace ~
16020 \InsetSpace ~
16021 \InsetSpace ~
16022 \InsetSpace ~
16023 \InsetSpace ~
16024 \InsetSpace ~
16025 \InsetSpace ~
16026 .area GSINIT (CODE)
16027 \end_layout
16028
16029 \begin_layout Verse
16030
16031 \family typewriter
16032 \series bold
16033 \size footnotesize
16034 (main.asm)
16035 \end_layout
16036
16037 \begin_layout Verse
16038
16039 \family typewriter
16040 \size footnotesize
16041 \InsetSpace ~
16042 \InsetSpace ~
16043 \InsetSpace ~
16044 \InsetSpace ~
16045 \InsetSpace ~
16046 \InsetSpace ~
16047 \InsetSpace ~
16048 \InsetSpace ~
16049 .area GSFINAL (CODE)
16050 \newline
16051 \InsetSpace ~
16052 \InsetSpace ~
16053 \InsetSpace ~
16054 \InsetSpace ~
16055 \InsetSpace ~
16056 \InsetSpace ~
16057 \InsetSpace ~
16058 \InsetSpace ~
16059 ljmp __sdcc_program_startup
16060 \newline
16061 ;---------------------------------
16062 -----------------------
16063 \newline
16064 ; Home
16065 \newline
16066 ;--------------------------------------------------
16067 ------
16068 \newline
16069 \InsetSpace ~
16070 \InsetSpace ~
16071 \InsetSpace ~
16072 \InsetSpace ~
16073 \InsetSpace ~
16074 \InsetSpace ~
16075 \InsetSpace ~
16076 \InsetSpace ~
16077 .area HOME (CODE)
16078 \newline
16079 \InsetSpace ~
16080 \InsetSpace ~
16081 \InsetSpace ~
16082 \InsetSpace ~
16083 \InsetSpace ~
16084 \InsetSpace ~
16085 \InsetSpace ~
16086 \InsetSpace ~
16087 .area CSEG (CODE)
16088 \newline
16089 __sdcc_program_startup:
16090 \newline
16091 \InsetSpace ~
16092 \InsetSpace ~
16093 \InsetSpace ~
16094 \InsetSpace ~
16095 \InsetSpace ~
16096 \InsetSpace ~
16097 \InsetSpace ~
16098 \InsetSpace ~
16099 lcall _main
16100 \newline
16101 ;
16102  return from main will lock up
16103 \newline
16104 \InsetSpace ~
16105 \InsetSpace ~
16106 \InsetSpace ~
16107 \InsetSpace ~
16108 \InsetSpace ~
16109 \InsetSpace ~
16110 \InsetSpace ~
16111 \InsetSpace ~
16112 sjmp .
16113 \end_layout
16114
16115 \begin_layout Standard
16116 One of these modules (crtstart.asm) contains a call to the C routine
16117 \emph on
16118 _sdcc_external_startup()
16119 \begin_inset LatexCommand \index{\_sdcc\_external\_startup()}
16120
16121 \end_inset
16122
16123
16124 \emph default
16125 at the start of the CODE area.
16126  This routine is also in the runtime library
16127 \begin_inset LatexCommand \index{Runtime library}
16128
16129 \end_inset
16130
16131  and returns 0 by default.
16132  If this routine returns a non-zero value, the static & global variable
16133  initialization will be skipped and the function main will be invoked.
16134  Otherwise static & global variables will be initialized before the function
16135  main is invoked.
16136  You could add an
16137 \emph on
16138 _sdcc_external_startup()
16139 \emph default
16140  routine to your program to override the default if you need to setup hardware
16141  or perform some other critical operation prior to static & global variable
16142  initialization
16143 \begin_inset LatexCommand \index{Variable initialization}
16144
16145 \end_inset
16146
16147 .
16148  On some mcs51 variants xdata
16149 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
16150
16151 \end_inset
16152
16153  memory has to be explicitly enabled before it can be accessed or if the
16154  watchdog
16155 \begin_inset LatexCommand \index{watchdog}
16156
16157 \end_inset
16158
16159  needs to be disabled, this is the place to do it.
16160  The startup code clears all internal data memory, 256 bytes by default,
16161  but from 0 to n-1 if
16162 \emph on
16163 -
16164 \begin_inset ERT
16165 status collapsed
16166
16167 \begin_layout Standard
16168
16169
16170 \backslash
16171 /
16172 \end_layout
16173
16174 \end_inset
16175
16176 -iram-size
16177 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
16178
16179 \end_inset
16180
16181 n
16182 \emph default
16183  is used.
16184  (recommended for Chipcon CC1010).
16185 \end_layout
16186
16187 \begin_layout Standard
16188 See also the compiler options
16189 \emph on
16190 -
16191 \begin_inset ERT
16192 status collapsed
16193
16194 \begin_layout Standard
16195
16196
16197 \backslash
16198 /
16199 \end_layout
16200
16201 \end_inset
16202
16203 -no-xinit
16204 \emph default
16205 -
16206 \emph on
16207 opt
16208 \emph default
16209
16210 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
16211
16212 \end_inset
16213
16214 ,
16215 \emph on
16216 -
16217 \begin_inset ERT
16218 status collapsed
16219
16220 \begin_layout Standard
16221
16222
16223 \backslash
16224 /
16225 \end_layout
16226
16227 \end_inset
16228
16229 -main-return
16230 \emph default
16231
16232 \begin_inset LatexCommand \index{-\/-main-return}
16233
16234 \end_inset
16235
16236  and section
16237 \begin_inset LatexCommand \ref{sub:MCS51-variants}
16238
16239 \end_inset
16240
16241  about MCS51-variants.
16242 \newline
16243
16244 \end_layout
16245
16246 \begin_layout Standard
16247 While these initialization modules are meant as generic startup code there
16248  might be the need for customization.
16249  Let's assume the return value of
16250 \emph on
16251 _sdcc_external_startup()
16252 \emph default
16253  in
16254 \emph on
16255 crtstart.asm
16256 \emph default
16257  should not be checked (or
16258 \emph on
16259 _sdcc_external_startup()
16260 \emph default
16261  should not be called at all).
16262  The recommended way would be to copy
16263 \emph on
16264 crtstart.asm
16265 \emph default
16266  (f.e.
16267  from
16268 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/device/lib/mcs51/crtstart.asm}
16269
16270 \end_inset
16271
16272 ) into the source directory, adapt it there, then assemble it with
16273 \emph on
16274 asx8051 -plosgff
16275 \begin_inset Foot
16276 status open
16277
16278 \begin_layout Standard
16279 \begin_inset Quotes sld
16280 \end_inset
16281
16282 -plosgff
16283 \begin_inset Quotes srd
16284 \end_inset
16285
16286  are the assembler options used in
16287 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/lib/mcs51/Makefile.in?view=markup }
16288
16289 \end_inset
16290
16291
16292 \end_layout
16293
16294 \end_inset
16295
16296  crtstart.asm
16297 \emph default
16298  and when linking your project explicitely specify
16299 \emph on
16300 crtstart.rel
16301 \emph default
16302 .
16303  As a bonus a listing of the relocated object file
16304 \emph on
16305 crtstart.rst
16306 \emph default
16307  is generated.
16308 \end_layout
16309
16310 \begin_layout Standard
16311 \begin_inset VSpace bigskip
16312 \end_inset
16313
16314
16315 \end_layout
16316
16317 \begin_layout Subsection
16318 HC08 Startup Code
16319 \end_layout
16320
16321 \begin_layout Standard
16322 The HC08
16323 \begin_inset LatexCommand \index{HC08}
16324
16325 \end_inset
16326
16327  startup code follows the same scheme as the MCS51 startup code.
16328 \begin_inset VSpace bigskip
16329 \end_inset
16330
16331
16332 \end_layout
16333
16334 \begin_layout Subsection
16335 Z80 Startup Code
16336 \end_layout
16337
16338 \begin_layout Standard
16339 On the Z80
16340 \begin_inset LatexCommand \index{Z80}
16341
16342 \end_inset
16343
16344  the startup code is inserted by linking with crt0.o which is generated from
16345  sdcc/device/lib/z80/crt0.s.
16346  If you need a different startup code you can use the compiler option
16347 \emph on
16348 -
16349 \series bold
16350 \emph default
16351
16352 \begin_inset ERT
16353 status collapsed
16354
16355 \begin_layout Standard
16356
16357
16358 \backslash
16359 /
16360 \end_layout
16361
16362 \end_inset
16363
16364
16365 \series default
16366 \emph on
16367 -no-std-crt0
16368 \emph default
16369
16370 \begin_inset LatexCommand \index{-\/-no-std-crt0}
16371
16372 \end_inset
16373
16374  and provide your own crt0.o.
16375 \begin_inset VSpace bigskip
16376 \end_inset
16377
16378
16379 \end_layout
16380
16381 \begin_layout Section
16382 Inline Assembler Code
16383 \begin_inset LatexCommand \index{Assembler routines}
16384
16385 \end_inset
16386
16387
16388 \end_layout
16389
16390 \begin_layout Subsection
16391 A Step by Step Introduction
16392 \begin_inset LatexCommand \label{sub:A-Step-by Assembler Introduction}
16393
16394 \end_inset
16395
16396
16397 \end_layout
16398
16399 \begin_layout Standard
16400 Starting from a small snippet of c-code this example shows for the MCS51
16401  how to use inline assembly, access variables, a function parameter and
16402  an array in xdata memory.
16403  The example uses an MCS51 here but is easily adapted for other architectures.
16404  This is a buffer routine which should be optimized:
16405 \end_layout
16406
16407 \begin_layout Verse
16408
16409 \family typewriter
16410 \size footnotesize
16411 unsigned char __far
16412 \begin_inset LatexCommand \index{far (storage class)}
16413
16414 \end_inset
16415
16416
16417 \begin_inset LatexCommand \index{\_\_far (storage class)}
16418
16419 \end_inset
16420
16421  __at
16422 \begin_inset LatexCommand \index{at}
16423
16424 \end_inset
16425
16426
16427 \begin_inset LatexCommand \index{\_\_at}
16428
16429 \end_inset
16430
16431 (0x7f00) buf[0x100];
16432 \begin_inset LatexCommand \index{Aligned array}
16433
16434 \end_inset
16435
16436
16437 \newline
16438 unsigned char head, tail;\InsetSpace ~
16439 \InsetSpace ~
16440 \InsetSpace ~
16441 \InsetSpace ~
16442 \InsetSpace ~
16443 \InsetSpace ~
16444 \InsetSpace ~
16445 \InsetSpace ~
16446 \InsetSpace ~
16447 \InsetSpace ~
16448 \InsetSpace ~
16449 \InsetSpace ~
16450 \InsetSpace ~
16451 \InsetSpace ~
16452 \InsetSpace ~
16453 \InsetSpace ~
16454 \InsetSpace ~
16455 /* if interrupts
16456 \begin_inset LatexCommand \index{interrupt}
16457
16458 \end_inset
16459
16460  are involved see
16461 \newline
16462 \InsetSpace ~
16463 \InsetSpace ~
16464 \InsetSpace ~
16465 \InsetSpace ~
16466 \InsetSpace ~
16467 \InsetSpace ~
16468 \InsetSpace ~
16469 \InsetSpace ~
16470 \InsetSpace ~
16471 \InsetSpace ~
16472 \InsetSpace ~
16473 \InsetSpace ~
16474 \InsetSpace ~
16475 \InsetSpace ~
16476 \InsetSpace ~
16477 \InsetSpace ~
16478 \InsetSpace ~
16479 \InsetSpace ~
16480 \InsetSpace ~
16481 \InsetSpace ~
16482 \InsetSpace ~
16483 \InsetSpace ~
16484 \InsetSpace ~
16485 \InsetSpace ~
16486 \InsetSpace ~
16487 \InsetSpace ~
16488 \InsetSpace ~
16489 \InsetSpace ~
16490 \InsetSpace ~
16491 \InsetSpace ~
16492 \InsetSpace ~
16493 \InsetSpace ~
16494 \InsetSpace ~
16495 \InsetSpace ~
16496 \InsetSpace ~
16497 \InsetSpace ~
16498 \InsetSpace ~
16499 \InsetSpace ~
16500 \InsetSpace ~
16501 \InsetSpace ~
16502 \InsetSpace ~
16503 \InsetSpace ~
16504 \InsetSpace ~
16505 \InsetSpace ~
16506 \InsetSpace ~
16507 section
16508 \begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
16509
16510 \end_inset
16511
16512  about
16513 \series bold
16514  volatile
16515 \series default
16516  */
16517 \newline
16518
16519 \newline
16520 void to_buffer( unsigned char c )
16521 \newline
16522 {
16523 \newline
16524 \InsetSpace ~
16525 \InsetSpace ~
16526 \InsetSpace ~
16527 \InsetSpace ~
16528 if( head != (unsigned char)(tail-1)
16529  )\InsetSpace ~
16530 /* cast
16531 \series bold
16532 needed
16533 \series default
16534  to avoid promotion
16535 \begin_inset LatexCommand \index{promotion to signed int}
16536
16537 \end_inset
16538
16539
16540 \begin_inset LatexCommand \index{type promotion}
16541
16542 \end_inset
16543
16544  to integer */
16545 \begin_inset Marginal
16546 status collapsed
16547
16548 \begin_layout Standard
16549
16550 \series bold
16551 \InsetSpace ~
16552 !
16553 \end_layout
16554
16555 \end_inset
16556
16557
16558 \newline
16559 \InsetSpace ~
16560 \InsetSpace ~
16561 \InsetSpace ~
16562 \InsetSpace ~
16563 \InsetSpace ~
16564 \InsetSpace ~
16565 \InsetSpace ~
16566 \InsetSpace ~
16567 buf[ head++ ] = c;\InsetSpace ~
16568 \InsetSpace ~
16569 \InsetSpace ~
16570 \InsetSpace ~
16571 \InsetSpace ~
16572 \InsetSpace ~
16573 \InsetSpace ~
16574 \InsetSpace ~
16575 \InsetSpace ~
16576 \InsetSpace ~
16577 \InsetSpace ~
16578 \InsetSpace ~
16579 \InsetSpace ~
16580 \InsetSpace ~
16581 \InsetSpace ~
16582 \InsetSpace ~
16583 /* access to a 256 byte aligned array */
16584 \newline
16585 }
16586 \end_layout
16587
16588 \begin_layout Standard
16589 If the code snippet (assume it is saved in buffer.c) is compiled with SDCC
16590  then a corresponding buffer.asm file is generated.
16591  We define a new function
16592 \family typewriter
16593 to_buffer_asm()
16594 \family default
16595  in file buffer.c in which we cut and paste the generated code, removing
16596  unwanted comments and some ':'.
16597  Then add
16598 \begin_inset Quotes sld
16599 \end_inset
16600
16601
16602 \series bold
16603 _asm
16604 \series default
16605
16606 \begin_inset Quotes srd
16607 \end_inset
16608
16609  and
16610 \begin_inset Quotes sld
16611 \end_inset
16612
16613
16614 \series bold
16615 _endasm;
16616 \series default
16617
16618 \begin_inset Quotes srd
16619 \end_inset
16620
16621
16622 \begin_inset Foot
16623 status open
16624
16625 \begin_layout Standard
16626 Note, that the single underscore form (_asm and _endasm) are not C99-compatible,
16627  and for C-99 compatibility, the double-underscore form (__asm and __endasm)
16628  has to be used.
16629  The latter is also used in the library functions.
16630 \end_layout
16631
16632 \end_inset
16633
16634  to the beginning and the end of the function body:
16635 \end_layout
16636
16637 \begin_layout Verse
16638
16639 \family typewriter
16640 \size footnotesize
16641 /* With a cut and paste from the .asm file, we have something to start with.
16642 \newline
16643 \InsetSpace ~
16644 \InsetSpace ~
16645 \InsetSpace ~
16646 The
16647  function is not yet OK! (registers aren't saved) */
16648 \newline
16649 void to_buffer_asm(
16650  unsigned char c )
16651 \newline
16652 {
16653 \newline
16654 \InsetSpace ~
16655 \InsetSpace ~
16656 \InsetSpace ~
16657 \InsetSpace ~
16658 _asm
16659 \begin_inset LatexCommand \index{\_asm}
16660
16661 \end_inset
16662
16663
16664 \begin_inset LatexCommand \index{\_\_asm}
16665
16666 \end_inset
16667
16668
16669 \newline
16670 \InsetSpace ~
16671 \InsetSpace ~
16672 \InsetSpace ~
16673 \InsetSpace ~
16674 mov\InsetSpace ~
16675 \InsetSpace ~
16676 r2,dpl
16677 \newline
16678 ;buffer.c if( head != (unsigned char)(tail-1) ) \InsetSpace ~
16679 /* cast
16680 \series bold
16681 needed
16682 \series default
16683  to avoid promotion
16684 \begin_inset LatexCommand \index{promotion to signed int}
16685
16686 \end_inset
16687
16688
16689 \begin_inset LatexCommand \index{type promotion}
16690
16691 \end_inset
16692
16693  to integer */
16694 \newline
16695 \InsetSpace ~
16696 \InsetSpace ~
16697 \InsetSpace ~
16698 \InsetSpace ~
16699 mov\InsetSpace ~
16700 \InsetSpace ~
16701 a,_tail
16702 \newline
16703 \InsetSpace ~
16704 \InsetSpace ~
16705 \InsetSpace ~
16706 \InsetSpace ~
16707 dec\InsetSpace ~
16708 \InsetSpace ~
16709 a
16710 \newline
16711 \InsetSpace ~
16712 \InsetSpace ~
16713 \InsetSpace ~
16714 \InsetSpace ~
16715 mov\InsetSpace ~
16716 \InsetSpace ~
16717 r3,a
16718 \newline
16719 \InsetSpace ~
16720 \InsetSpace ~
16721 \InsetSpace ~
16722 \InsetSpace ~
16723 mov\InsetSpace ~
16724 \InsetSpace ~
16725 a,_head
16726 \newline
16727 \InsetSpace ~
16728 \InsetSpace ~
16729 \InsetSpace ~
16730 \InsetSpace ~
16731 cjne a,ar3,00106$
16732 \newline
16733 \InsetSpace ~
16734 \InsetSpace ~
16735 \InsetSpace ~
16736 \InsetSpace ~
16737 ret
16738 \newline
16739 00106$:
16740 \newline
16741 ;buffer.c
16742  buf[ head++ ] = c; /* access to a 256 byte aligned array */
16743 \begin_inset LatexCommand \index{Aligned array}
16744
16745 \end_inset
16746
16747
16748 \newline
16749 \InsetSpace ~
16750 \InsetSpace ~
16751 \InsetSpace ~
16752 \InsetSpace ~
16753 mov\InsetSpace ~
16754 \InsetSpace ~
16755 r3,_head
16756 \newline
16757 \InsetSpace ~
16758 \InsetSpace ~
16759 \InsetSpace ~
16760 \InsetSpace ~
16761 inc\InsetSpace ~
16762 \InsetSpace ~
16763 _head
16764 \newline
16765 \InsetSpace ~
16766 \InsetSpace ~
16767 \InsetSpace ~
16768 \InsetSpace ~
16769 mov\InsetSpace ~
16770 \InsetSpace ~
16771 dpl,r3
16772 \newline
16773 \InsetSpace ~
16774 \InsetSpace ~
16775 \InsetSpace ~
16776 \InsetSpace ~
16777 mov\InsetSpace ~
16778 \InsetSpace ~
16779 dph,#(_buf >> 8)
16780 \newline
16781 \InsetSpace ~
16782 \InsetSpace ~
16783 \InsetSpace ~
16784 \InsetSpace ~
16785 mov\InsetSpace ~
16786 \InsetSpace ~
16787 a,r2
16788 \newline
16789 \InsetSpace ~
16790 \InsetSpace ~
16791 \InsetSpace ~
16792 \InsetSpace ~
16793 movx @dptr,a
16794 \newline
16795 00103$:
16796 \newline
16797 \InsetSpace ~
16798 \InsetSpace ~
16799 \InsetSpace ~
16800 \InsetSpace ~
16801 ret
16802 \newline
16803 \InsetSpace ~
16804 \InsetSpace ~
16805 \InsetSpace ~
16806 \InsetSpace ~
16807 _end
16808 asm
16809 \begin_inset LatexCommand \index{\_endasm}
16810
16811 \end_inset
16812
16813
16814 \begin_inset LatexCommand \index{\_\_endasm}
16815
16816 \end_inset
16817
16818 ;
16819 \newline
16820 }
16821 \end_layout
16822
16823 \begin_layout Standard
16824 The new file buffer.c should compile with only one warning about the unreferenced
16825  function argument 'c'.
16826  Now we hand-optimize the assembly code and insert an #define USE_ASSEMBLY
16827  (1) and finally have:
16828 \end_layout
16829
16830 \begin_layout Verse
16831
16832 \family typewriter
16833 \size footnotesize
16834 unsigned char __far __at(0x7f00) buf[0x100];
16835 \newline
16836 unsigned char head, tail;
16837 \newline
16838 #define
16839  USE_ASSEMBLY (1)
16840 \newline
16841
16842 \newline
16843 #if !USE_ASSEMBLY
16844 \newline
16845
16846 \newline
16847 void to_buffer( unsigned char c )
16848 \newline
16849 {
16850 \newline
16851 \InsetSpace ~
16852 \InsetSpace ~
16853 \InsetSpace ~
16854 \InsetSpace ~
16855 if(
16856  head != (unsigned char)(tail-1) )
16857 \newline
16858 \InsetSpace ~
16859 \InsetSpace ~
16860 \InsetSpace ~
16861 \InsetSpace ~
16862 \InsetSpace ~
16863 \InsetSpace ~
16864 \InsetSpace ~
16865 \InsetSpace ~
16866 buf[ head++ ] = c;
16867 \newline
16868 }
16869 \newline
16870
16871 \newline
16872 #else
16873 \newline
16874
16875 \newline
16876 void to_buffer(
16877  unsigned char c )
16878 \newline
16879 {
16880 \newline
16881 \InsetSpace ~
16882 \InsetSpace ~
16883 \InsetSpace ~
16884 \InsetSpace ~
16885 c; // to avoid warning: unreferenced function argument
16886 \newline
16887 \InsetSpace ~
16888 \InsetSpace ~
16889 \InsetSpace ~
16890 \InsetSpace ~
16891 _asm
16892 \begin_inset LatexCommand \index{\_asm}
16893
16894 \end_inset
16895
16896
16897 \begin_inset LatexCommand \index{\_\_asm}
16898
16899 \end_inset
16900
16901
16902 \newline
16903 \InsetSpace ~
16904 \InsetSpace ~
16905 \InsetSpace ~
16906 \InsetSpace ~
16907 \InsetSpace ~
16908 \InsetSpace ~
16909 \InsetSpace ~
16910 \InsetSpace ~
16911 ; save used registers here.
16912 \newline
16913 \InsetSpace ~
16914 \InsetSpace ~
16915 \InsetSpace ~
16916 \InsetSpace ~
16917 \InsetSpace ~
16918 \InsetSpace ~
16919 \InsetSpace ~
16920 \InsetSpace ~
16921 ; If we were still using r2,r3 we would have to
16922  push them here.
16923 \newline
16924 ; if( head != (unsigned char)(tail-1) )
16925 \newline
16926 \InsetSpace ~
16927 \InsetSpace ~
16928 \InsetSpace ~
16929 \InsetSpace ~
16930 \InsetSpace ~
16931 \InsetSpace ~
16932 \InsetSpace ~
16933 \InsetSpace ~
16934 mov\InsetSpace ~
16935  a,_tail
16936 \newline
16937 \InsetSpace ~
16938 \InsetSpace ~
16939 \InsetSpace ~
16940 \InsetSpace ~
16941 \InsetSpace ~
16942 \InsetSpace ~
16943 \InsetSpace ~
16944 \InsetSpace ~
16945 dec\InsetSpace ~
16946  a
16947 \newline
16948 \InsetSpace ~
16949 \InsetSpace ~
16950 \InsetSpace ~
16951 \InsetSpace ~
16952 \InsetSpace ~
16953 \InsetSpace ~
16954 \InsetSpace ~
16955 \InsetSpace ~
16956 xrl\InsetSpace ~
16957
16958  a,_head
16959 \newline
16960 \InsetSpace ~
16961 \InsetSpace ~
16962 \InsetSpace ~
16963 \InsetSpace ~
16964 \InsetSpace ~
16965 \InsetSpace ~
16966 \InsetSpace ~
16967 \InsetSpace ~
16968 ; we could do an ANL a,#0x0f here to use a smaller buffer (see below)
16969 \newline
16970 \InsetSpace ~
16971 \InsetSpace ~
16972 \InsetSpace ~
16973 \InsetSpace ~
16974 \InsetSpace ~
16975 \InsetSpace ~
16976 \InsetSpace ~
16977 \InsetSpace ~
16978 jz\InsetSpace ~
16979 \InsetSpace ~
16980
16981  t_b_end$
16982 \newline
16983 \InsetSpace ~
16984 \InsetSpace ~
16985 \InsetSpace ~
16986 \InsetSpace ~
16987 \InsetSpace ~
16988 \InsetSpace ~
16989 \InsetSpace ~
16990 \InsetSpace ~
16991 ;
16992 \newline
16993 ; buf[ head++ ] = c;
16994 \newline
16995 \InsetSpace ~
16996 \InsetSpace ~
16997 \InsetSpace ~
16998 \InsetSpace ~
16999 \InsetSpace ~
17000 \InsetSpace ~
17001 \InsetSpace ~
17002 \InsetSpace ~
17003 mov\InsetSpace ~
17004  a,dpl \InsetSpace ~
17005 \InsetSpace ~
17006 \InsetSpace ~
17007 \InsetSpace ~
17008 \InsetSpace ~
17009 \InsetSpace ~
17010 \InsetSpace ~
17011 ; dpl holds lower byte of function
17012  argument
17013 \newline
17014 \InsetSpace ~
17015 \InsetSpace ~
17016 \InsetSpace ~
17017 \InsetSpace ~
17018 \InsetSpace ~
17019 \InsetSpace ~
17020 \InsetSpace ~
17021 \InsetSpace ~
17022 mov\InsetSpace ~
17023  dpl,_head \InsetSpace ~
17024 \InsetSpace ~
17025 \InsetSpace ~
17026 ; buf is 0x100 byte aligned so head can be used directly
17027 \newline
17028 \InsetSpace ~
17029 \InsetSpace ~
17030 \InsetSpace ~
17031 \InsetSpace ~
17032 \InsetSpace ~
17033 \InsetSpace ~
17034 \InsetSpace ~
17035 \InsetSpace ~
17036 m
17037 ov\InsetSpace ~
17038  dph,#(_buf>>8)
17039 \newline
17040 \InsetSpace ~
17041 \InsetSpace ~
17042 \InsetSpace ~
17043 \InsetSpace ~
17044 \InsetSpace ~
17045 \InsetSpace ~
17046 \InsetSpace ~
17047 \InsetSpace ~
17048 movx @dptr,a
17049 \newline
17050 \InsetSpace ~
17051 \InsetSpace ~
17052 \InsetSpace ~
17053 \InsetSpace ~
17054 \InsetSpace ~
17055 \InsetSpace ~
17056 \InsetSpace ~
17057 \InsetSpace ~
17058 inc \InsetSpace ~
17059 _head
17060 \newline
17061 \InsetSpace ~
17062 \InsetSpace ~
17063 \InsetSpace ~
17064 \InsetSpace ~
17065 \InsetSpace ~
17066 \InsetSpace ~
17067 \InsetSpace ~
17068 \InsetSpace ~
17069 ; we could do an ANL _head,#0x0f here
17070  to use a smaller buffer (see above)
17071 \newline
17072 t_b_end$:
17073 \newline
17074 \InsetSpace ~
17075 \InsetSpace ~
17076 \InsetSpace ~
17077 \InsetSpace ~
17078 \InsetSpace ~
17079 \InsetSpace ~
17080 \InsetSpace ~
17081 \InsetSpace ~
17082 ; restore used registers here
17083 \newline
17084 \InsetSpace ~
17085 \InsetSpace ~
17086 \InsetSpace ~
17087 \InsetSpace ~
17088 _endas
17089 m
17090 \begin_inset LatexCommand \index{\_endasm}
17091
17092 \end_inset
17093
17094
17095 \begin_inset LatexCommand \index{\_\_endasm}
17096
17097 \end_inset
17098
17099 ;
17100 \newline
17101 }
17102 \newline
17103 #endif
17104 \end_layout
17105
17106 \begin_layout Standard
17107 The inline assembler code can contain any valid code understood by the assembler
17108 , this includes any assembler directives and comment lines.
17109  The assembler does not like some characters like ':' or ''' in comments.
17110  You'll find an 100+ pages assembler manual in sdcc/as/doc/asxhtm.html
17111 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
17112
17113 \end_inset
17114
17115
17116 \begin_inset LatexCommand \index{Assembler documentation}
17117
17118 \end_inset
17119
17120  or online at
17121 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
17122
17123 \end_inset
17124
17125 \InsetSpace ~
17126 .
17127 \end_layout
17128
17129 \begin_layout Standard
17130 The compiler does not do any validation of the code within the
17131 \family typewriter
17132 _asm
17133 \begin_inset LatexCommand \index{\_asm}
17134
17135 \end_inset
17136
17137
17138 \begin_inset LatexCommand \index{\_\_asm}
17139
17140 \end_inset
17141
17142  ...
17143  _endasm
17144 \size footnotesize
17145
17146 \begin_inset LatexCommand \index{\_endasm}
17147
17148 \end_inset
17149
17150
17151 \begin_inset LatexCommand \index{\_\_endasm}
17152
17153 \end_inset
17154
17155
17156 \size default
17157 ;
17158 \family default
17159  keyword pair.
17160  Specifically it will not know which registers are used and thus register
17161  pushing/popping
17162 \begin_inset LatexCommand \index{push/pop}
17163
17164 \end_inset
17165
17166  has to be done manually.
17167 \end_layout
17168
17169 \begin_layout Standard
17170 It is recommended that each assembly instruction (including labels) be placed
17171  in a separate line (as the example shows).
17172  When the -
17173 \begin_inset ERT
17174 status collapsed
17175
17176 \begin_layout Standard
17177
17178
17179 \backslash
17180 /
17181 \end_layout
17182
17183 \end_inset
17184
17185 -
17186 \emph on
17187 peep-asm
17188 \begin_inset LatexCommand \index{-\/-peep-asm}
17189
17190 \end_inset
17191
17192
17193 \emph default
17194  command line option is used, the inline assembler code will be passed through
17195  the peephole optimizer
17196 \begin_inset LatexCommand \index{Peephole optimizer}
17197
17198 \end_inset
17199
17200 .
17201  There are only a few (if any) cases where this option makes sense, it might
17202  cause some unexpected changes in the inline assembler code.
17203  Please go through the peephole optimizer rules defined in file
17204 \emph on
17205 SDCCpeeph.def
17206 \emph default
17207  before using this option.
17208 \end_layout
17209
17210 \begin_layout Subsection
17211 Naked Functions
17212 \begin_inset LatexCommand \label{sub:Naked-Functions}
17213
17214 \end_inset
17215
17216
17217 \begin_inset LatexCommand \index{Naked functions}
17218
17219 \end_inset
17220
17221
17222 \end_layout
17223
17224 \begin_layout Standard
17225 A special keyword may be associated with a function declaring it as
17226 \emph on
17227 _naked
17228 \begin_inset LatexCommand \index{\_naked}
17229
17230 \end_inset
17231
17232
17233 \begin_inset LatexCommand \index{\_\_naked}
17234
17235 \end_inset
17236
17237 .
17238 \emph default
17239 The
17240 \emph on
17241 _naked
17242 \emph default
17243  function modifier attribute prevents the compiler from generating prologue
17244 \begin_inset LatexCommand \index{function prologue}
17245
17246 \end_inset
17247
17248  and epilogue
17249 \begin_inset LatexCommand \index{function epilogue}
17250
17251 \end_inset
17252
17253  code for that function.
17254  This means that the user is entirely responsible for such things as saving
17255  any registers that may need to be preserved, selecting the proper register
17256  bank, generating the
17257 \emph on
17258 return
17259 \emph default
17260  instruction at the end, etc.
17261  Practically, this means that the contents of the function must be written
17262  in inline assembler.
17263  This is particularly useful for interrupt functions, which can have a large
17264  (and often unnecessary) prologue/epilogue.
17265  For example, compare the code generated by these two functions:
17266 \end_layout
17267
17268 \begin_layout Verse
17269
17270 \family typewriter
17271 volatile
17272 \begin_inset LatexCommand \index{volatile}
17273
17274 \end_inset
17275
17276  data unsigned char counter;
17277 \newline
17278
17279 \newline
17280 void simpleInterrupt(void) __interrupt
17281 \begin_inset LatexCommand \index{interrupt}
17282
17283 \end_inset
17284
17285
17286 \begin_inset LatexCommand \index{\_\_interrupt}
17287
17288 \end_inset
17289
17290  (1)
17291 \newline
17292 {
17293 \newline
17294 \InsetSpace ~
17295 \InsetSpace ~
17296 \InsetSpace ~
17297 \InsetSpace ~
17298 counter++;
17299 \newline
17300 }
17301 \newline
17302
17303 \newline
17304 void nakedInterrupt(void) __interrupt (2) __naked
17305 \newline
17306 {
17307 \newline
17308 \InsetSpace ~
17309 \InsetSpace ~
17310 \InsetSpace ~
17311 \InsetSpace ~
17312 _asm
17313 \begin_inset LatexCommand \index{\_asm}
17314
17315 \end_inset
17316
17317
17318 \begin_inset LatexCommand \index{\_\_asm}
17319
17320 \end_inset
17321
17322
17323 \newline
17324 \InsetSpace ~
17325 \InsetSpace ~
17326 \InsetSpace ~
17327 \InsetSpace ~
17328 \InsetSpace ~
17329 \InsetSpace ~
17330 inc\InsetSpace ~
17331 \InsetSpace ~
17332 \InsetSpace ~
17333 \InsetSpace ~
17334 \InsetSpace ~
17335 _counter ; does not change flags, no need to save psw
17336 \newline
17337 \InsetSpace ~
17338 \InsetSpace ~
17339 \InsetSpace ~
17340 \InsetSpace ~
17341 \InsetSpace ~
17342 \InsetSpace ~
17343 reti\InsetSpace ~
17344 \InsetSpace ~
17345 \InsetSpace ~
17346 \InsetSpace ~
17347 ; MUST explicitly
17348  include ret or reti in _naked function.
17349 \newline
17350 \InsetSpace ~
17351 \InsetSpace ~
17352 \InsetSpace ~
17353 \InsetSpace ~
17354 _endasm
17355 \begin_inset LatexCommand \index{\_endasm}
17356
17357 \end_inset
17358
17359
17360 \begin_inset LatexCommand \index{\_\_endasm}
17361
17362 \end_inset
17363
17364 ;
17365 \newline
17366 }
17367 \end_layout
17368
17369 \begin_layout Standard
17370 For an 8051 target, the generated simpleInterrupt looks like:
17371 \end_layout
17372
17373 \begin_layout Verse
17374
17375 \family typewriter
17376 Note, this is an
17377 \emph on
17378 outdated
17379 \emph default
17380  example, recent versions of SDCC generate
17381 \newline
17382 the
17383 \emph on
17384 same
17385 \emph default
17386  code for simpleInterrupt() and nakedInterrupt()!
17387 \newline
17388
17389 \newline
17390 _simpleInterrupt:
17391 \newline
17392 \InsetSpace ~
17393 \InsetSpace ~
17394 \InsetSpace ~
17395 \InsetSpace ~
17396 push\InsetSpace ~
17397 \InsetSpace ~
17398 \InsetSpace ~
17399 \InsetSpace ~
17400 acc
17401 \newline
17402 \InsetSpace ~
17403 \InsetSpace ~
17404 \InsetSpace ~
17405 \InsetSpace ~
17406 push\InsetSpace ~
17407 \InsetSpace ~
17408 \InsetSpace ~
17409 \InsetSpace ~
17410 b
17411 \newline
17412 \InsetSpace ~
17413 \InsetSpace ~
17414 \InsetSpace ~
17415 \InsetSpace ~
17416 pu
17417 sh\InsetSpace ~
17418 \InsetSpace ~
17419 \InsetSpace ~
17420 \InsetSpace ~
17421 dpl
17422 \newline
17423 \InsetSpace ~
17424 \InsetSpace ~
17425 \InsetSpace ~
17426 \InsetSpace ~
17427 push\InsetSpace ~
17428 \InsetSpace ~
17429 \InsetSpace ~
17430 \InsetSpace ~
17431 dph
17432 \newline
17433 \InsetSpace ~
17434 \InsetSpace ~
17435 \InsetSpace ~
17436 \InsetSpace ~
17437 push\InsetSpace ~
17438 \InsetSpace ~
17439 \InsetSpace ~
17440 \InsetSpace ~
17441 psw
17442 \newline
17443 \InsetSpace ~
17444 \InsetSpace ~
17445 \InsetSpace ~
17446 \InsetSpace ~
17447 mov\InsetSpace ~
17448 \InsetSpace ~
17449 \InsetSpace ~
17450 \InsetSpace ~
17451 \InsetSpace ~
17452 psw,#0x00
17453 \newline
17454 \InsetSpace ~
17455 \InsetSpace ~
17456 \InsetSpace ~
17457 \InsetSpace ~
17458 inc\InsetSpace ~
17459 \InsetSpace ~
17460 \InsetSpace ~
17461 \InsetSpace ~
17462 \InsetSpace ~
17463 _counter
17464 \newline
17465 \InsetSpace ~
17466 \InsetSpace ~
17467 \InsetSpace ~
17468 \InsetSpace ~
17469 pop\InsetSpace ~
17470 \InsetSpace ~
17471 \InsetSpace ~
17472 \InsetSpace ~
17473 \InsetSpace ~
17474 psw
17475 \newline
17476 \InsetSpace ~
17477 \InsetSpace ~
17478 \InsetSpace ~
17479 \InsetSpace ~
17480 pop\InsetSpace ~
17481 \InsetSpace ~
17482 \InsetSpace ~
17483 \InsetSpace ~
17484 \InsetSpace ~
17485 dph
17486 \newline
17487 \InsetSpace ~
17488 \InsetSpace ~
17489 \InsetSpace ~
17490 \InsetSpace ~
17491 pop\InsetSpace ~
17492 \InsetSpace ~
17493 \InsetSpace ~
17494 \InsetSpace ~
17495 \InsetSpace ~
17496 dpl
17497 \newline
17498 \InsetSpace ~
17499 \InsetSpace ~
17500 \InsetSpace ~
17501 \InsetSpace ~
17502 pop\InsetSpace ~
17503 \InsetSpace ~
17504 \InsetSpace ~
17505 \InsetSpace ~
17506 \InsetSpace ~
17507 b
17508 \newline
17509 \InsetSpace ~
17510 \InsetSpace ~
17511 \InsetSpace ~
17512 \InsetSpace ~
17513 pop\InsetSpace ~
17514 \InsetSpace ~
17515 \InsetSpace ~
17516 \InsetSpace ~
17517 \InsetSpace ~
17518 acc
17519 \newline
17520 \InsetSpace ~
17521 \InsetSpace ~
17522 \InsetSpace ~
17523 \InsetSpace ~
17524 reti
17525 \end_layout
17526
17527 \begin_layout Standard
17528 whereas nakedInterrupt looks like:
17529 \end_layout
17530
17531 \begin_layout Verse
17532
17533 \family typewriter
17534 _nakedInterrupt:
17535 \newline
17536 \InsetSpace ~
17537 \InsetSpace ~
17538 \InsetSpace ~
17539 \InsetSpace ~
17540 inc\InsetSpace ~
17541 \InsetSpace ~
17542 \InsetSpace ~
17543 \InsetSpace ~
17544 _counter ; does not change flags, no need to save psw
17545 \newline
17546 \InsetSpace ~
17547 \InsetSpace ~
17548 \InsetSpace ~
17549 \InsetSpace ~
17550 reti\InsetSpace ~
17551 \InsetSpace ~
17552 \InsetSpace ~
17553 \InsetSpace ~
17554 \InsetSpace ~
17555 \InsetSpace ~
17556 \InsetSpace ~
17557 \InsetSpace ~
17558 \InsetSpace ~
17559 \InsetSpace ~
17560 \InsetSpace ~
17561 \InsetSpace ~
17562 ;
17563  MUST explicitly include ret or reti in _naked function
17564 \end_layout
17565
17566 \begin_layout Standard
17567 The related directive #pragma exclude
17568 \begin_inset LatexCommand \index{\#pragma exclude}
17569
17570 \end_inset
17571
17572  allows a more fine grained control over pushing & popping
17573 \begin_inset LatexCommand \index{push/pop}
17574
17575 \end_inset
17576
17577  the registers.
17578 \end_layout
17579
17580 \begin_layout Standard
17581 While there is nothing preventing you from writing C code inside a
17582 \family typewriter
17583 _naked
17584 \family default
17585  function, there are many ways to shoot yourself in the foot doing this,
17586  and it is recommended that you stick to inline assembler.
17587 \end_layout
17588
17589 \begin_layout Subsection
17590 Use of Labels within Inline Assembler
17591 \end_layout
17592
17593 \begin_layout Standard
17594 SDCC allows the use of in-line assembler with a few restrictions regarding
17595  labels.
17596  All labels defined within inline assembler code have to be of the form
17597 \emph on
17598 nnnnn$
17599 \emph default
17600  where nnnnn is a number less than 100 (which implies a limit of utmost
17601  100 inline assembler labels
17602 \emph on
17603 per function
17604 \emph default
17605 \noun on
17606 )
17607 \noun default
17608 .
17609 \begin_inset Foot
17610 status open
17611
17612 \begin_layout Standard
17613 This is a slightly more stringent rule than absolutely necessary, but stays
17614  always on the safe side.
17615  Labels in the form of nnnnn$ are local labels in the assembler, locality
17616  of which is confined within two labels of the standard form.
17617  The compiler uses the same form for labels within a function (but starting
17618  from nnnnn=00100); and places always a standard label at the beginning
17619  of a function, thus limiting the locality of labels within the scope of
17620  the function.
17621  So, if the inline assembler part would be embedded into C-code, an improperly
17622  placed non-local label in the assembler would break up the reference space
17623  for labels created by the compiler for the C-code, leading to an assembling
17624  error.
17625 \end_layout
17626
17627 \begin_layout Standard
17628 The numeric part of local labels does not need to have 5 digits (although
17629  this is the form of labels output by the compiler), any valid integer will
17630  do.
17631  Please refer to the assemblers documentation for further details.
17632 \end_layout
17633
17634 \end_inset
17635
17636
17637 \end_layout
17638
17639 \begin_layout Verse
17640
17641 \family typewriter
17642 _asm
17643 \begin_inset LatexCommand \index{\_asm}
17644
17645 \end_inset
17646
17647
17648 \begin_inset LatexCommand \index{\_\_asm}
17649
17650 \end_inset
17651
17652
17653 \newline
17654 \InsetSpace ~
17655 \InsetSpace ~
17656 \InsetSpace ~
17657 \InsetSpace ~
17658 mov\InsetSpace ~
17659 \InsetSpace ~
17660 \InsetSpace ~
17661 \InsetSpace ~
17662 \InsetSpace ~
17663 b,#10
17664 \newline
17665 00001$:
17666 \newline
17667 \InsetSpace ~
17668 \InsetSpace ~
17669 \InsetSpace ~
17670 \InsetSpace ~
17671 djnz\InsetSpace ~
17672 \InsetSpace ~
17673 \InsetSpace ~
17674 \InsetSpace ~
17675 b,00001$
17676 \newline
17677 _endasm
17678 \begin_inset LatexCommand \index{\_endasm}
17679
17680 \end_inset
17681
17682
17683 \begin_inset LatexCommand \index{\_\_endasm}
17684
17685 \end_inset
17686
17687  ;
17688 \end_layout
17689
17690 \begin_layout Standard
17691 Inline assembler code cannot reference any C-labels, however it can reference
17692  labels
17693 \begin_inset LatexCommand \index{Labels}
17694
17695 \end_inset
17696
17697  defined by the inline assembler, e.g.:
17698 \end_layout
17699
17700 \begin_layout Verse
17701
17702 \family typewriter
17703 foo() {
17704 \newline
17705 \InsetSpace ~
17706 \InsetSpace ~
17707 \InsetSpace ~
17708 \InsetSpace ~
17709 /* some c code */
17710 \newline
17711 \InsetSpace ~
17712 \InsetSpace ~
17713 \InsetSpace ~
17714 \InsetSpace ~
17715 _asm
17716 \newline
17717 \InsetSpace ~
17718 \InsetSpace ~
17719 \InsetSpace ~
17720 \InsetSpace ~
17721 \InsetSpace ~
17722 \InsetSpace ~
17723 ; some assembler code
17724 \newline
17725 \InsetSpace ~
17726 \InsetSpace ~
17727 \InsetSpace ~
17728 \InsetSpace ~
17729 \InsetSpace ~
17730 \InsetSpace ~
17731 ljmp 0003$
17732 \newline
17733 \InsetSpace ~
17734 \InsetSpace ~
17735 \InsetSpace ~
17736 \InsetSpace ~
17737 _endasm;
17738 \newline
17739 \InsetSpace ~
17740 \InsetSpace ~
17741 \InsetSpace ~
17742 \InsetSpace ~
17743 /* some
17744  more c code */
17745 \newline
17746 clabel:\InsetSpace ~
17747 \InsetSpace ~
17748 /* inline assembler cannot reference this label */
17749 \begin_inset Foot
17750 status open
17751
17752 \begin_layout Standard
17753 Here, the C-label
17754 \family typewriter
17755 clabel
17756 \family default
17757  is translated by the compiler into a local label, so the locality of labels
17758  within the function is not broken.
17759 \end_layout
17760
17761 \end_inset
17762
17763
17764 \newline
17765 \InsetSpace ~
17766 \InsetSpace ~
17767 \InsetSpace ~
17768 \InsetSpace ~
17769 _asm
17770 \newline
17771 \InsetSpace ~
17772 \InsetSpace ~
17773 \InsetSpace ~
17774 \InsetSpace ~
17775 0003$: ;label (can be referenced by inline assembler only)
17776 \newline
17777 \InsetSpace ~
17778 \InsetSpace ~
17779 \InsetSpace ~
17780 \InsetSpace ~
17781 _endasm
17782 \begin_inset LatexCommand \index{\_endasm}
17783
17784 \end_inset
17785
17786
17787 \begin_inset LatexCommand \index{\_\_endasm}
17788
17789 \end_inset
17790
17791  ;
17792 \newline
17793 \InsetSpace ~
17794 \InsetSpace ~
17795 \InsetSpace ~
17796 \InsetSpace ~
17797 /* some more c code */
17798 \newline
17799 }
17800 \end_layout
17801
17802 \begin_layout Standard
17803 In other words inline assembly code can access labels defined in inline
17804  assembly within the scope of the function.
17805  The same goes the other way, i.e.
17806  labels defines in inline assembly can not be accessed by C statements.
17807 \end_layout
17808
17809 \begin_layout Section
17810 Interfacing with Assembler Code
17811 \begin_inset LatexCommand \index{Assembler routines}
17812
17813 \end_inset
17814
17815
17816 \end_layout
17817
17818 \begin_layout Subsection
17819 Global Registers used for Parameter Passing
17820 \begin_inset LatexCommand \index{Parameter passing}
17821
17822 \end_inset
17823
17824
17825 \end_layout
17826
17827 \begin_layout Standard
17828 The compiler always uses the global registers
17829 \emph on
17830 DPL, DPH
17831 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
17832
17833 \end_inset
17834
17835
17836 \begin_inset LatexCommand \index{DPTR}
17837
17838 \end_inset
17839
17840 , B
17841 \begin_inset LatexCommand \index{B (mcs51, ds390 register)}
17842
17843 \end_inset
17844
17845
17846 \emph default
17847 and
17848 \emph on
17849  ACC
17850 \begin_inset LatexCommand \index{ACC (mcs51, ds390 register)}
17851
17852 \end_inset
17853
17854
17855 \emph default
17856  to pass the first (non-bit) parameter to a function, and also to pass the
17857  return value
17858 \begin_inset LatexCommand \index{return value}
17859
17860 \end_inset
17861
17862 of function; according to the following scheme: one byte return value in
17863 \emph on
17864 DPL
17865 \emph default
17866 , two byte value in
17867 \emph on
17868 DPL
17869 \emph default
17870  (LSB) and
17871 \emph on
17872 DPH
17873 \emph default
17874  (MSB).
17875  three byte values (generic pointers) in
17876 \emph on
17877 DPH
17878 \emph default
17879 ,
17880 \emph on
17881 DPL
17882 \emph default
17883  and
17884 \emph on
17885 B
17886 \emph default
17887 , and four byte values in
17888 \emph on
17889 DPH
17890 \emph default
17891 ,
17892 \emph on
17893 DPL
17894 \emph default
17895 ,
17896 \emph on
17897  B
17898 \emph default
17899  and
17900 \emph on
17901 ACC
17902 \emph default
17903 .
17904  Generic pointers
17905 \begin_inset LatexCommand \index{generic pointer}
17906
17907 \end_inset
17908
17909  contain type of accessed memory in
17910 \emph on
17911 B
17912 \emph default
17913 :
17914 \series bold
17915 0x00
17916 \series default
17917  -- xdata/far,
17918 \series bold
17919 0x40
17920 \series default
17921  -- idata/near -- ,
17922 \series bold
17923 0x60
17924 \series default
17925  -- pdata,
17926 \series bold
17927 0x80
17928 \series default
17929  -- code
17930 \begin_inset Note Note
17931 status collapsed
17932
17933 \begin_layout Standard
17934 This might not be the case of certain memory models (medium???)
17935 \end_layout
17936
17937 \end_inset
17938
17939 .
17940 \end_layout
17941
17942 \begin_layout Standard
17943 The second parameter onwards is either allocated on the stack (for reentrant
17944  routines or if -
17945 \begin_inset ERT
17946 status collapsed
17947
17948 \begin_layout Standard
17949
17950
17951 \backslash
17952 /
17953 \end_layout
17954
17955 \end_inset
17956
17957 -stack-auto is used) or in data/xdata memory (depending on the memory model).
17958 \end_layout
17959
17960 \begin_layout Standard
17961 Bit parameters are passed in a virtual register called 'bits' in bit-addressable
17962  space for reentrant functions or allocated directly in bit memory otherwise.
17963 \end_layout
17964
17965 \begin_layout Standard
17966 Functions (with two or more parameters or bit parameters) that are called
17967  through function pointers
17968 \begin_inset LatexCommand \index{function pointers}
17969
17970 \end_inset
17971
17972  must therefor be reentrant so the compiler knows how to pass the parameters.
17973 \end_layout
17974
17975 \begin_layout Subsection
17976 Registers usage
17977 \end_layout
17978
17979 \begin_layout Standard
17980 Unless the called function is declared as
17981 \family typewriter
17982 _naked
17983 \family default
17984
17985 \begin_inset LatexCommand \index{naked}
17986
17987 \end_inset
17988
17989 , or the -
17990 \begin_inset ERT
17991 status collapsed
17992
17993 \begin_layout Standard
17994
17995
17996 \backslash
17997 /
17998 \end_layout
17999
18000 \end_inset
18001
18002 -callee-saves
18003 \begin_inset LatexCommand \index{-\/-callee-saves}
18004
18005 \end_inset
18006
18007 /-
18008 \begin_inset ERT
18009 status collapsed
18010
18011 \begin_layout Standard
18012
18013
18014 \backslash
18015 /
18016 \end_layout
18017
18018 \end_inset
18019
18020 -all-callee-saves command line option or the corresponding callee_saves
18021  pragma are used, the caller will save the registers (
18022 \emph on
18023 R0-R7
18024 \emph default
18025 ) around the call, so the called function can destroy they content freely.
18026 \end_layout
18027
18028 \begin_layout Standard
18029 If the called function is not declared as
18030 \family typewriter
18031 _naked
18032 \family default
18033 , the caller will swap register banks around the call, if caller and callee
18034  use different register banks (having them defined by the
18035 \family typewriter
18036 _using
18037 \family default
18038  modifier).
18039 \end_layout
18040
18041 \begin_layout Standard
18042 The called function can also use
18043 \emph on
18044 DPL
18045 \emph default
18046 ,
18047 \emph on
18048 DPH
18049 \emph default
18050 ,
18051 \emph on
18052 B
18053 \emph default
18054  and
18055 \emph on
18056 ACC
18057 \emph default
18058  observing that they are used for parameter/return value passing.
18059 \end_layout
18060
18061 \begin_layout Subsection
18062 Assembler Routine (non-reentrant)
18063 \end_layout
18064
18065 \begin_layout Standard
18066 In the following example
18067 \begin_inset LatexCommand \index{reentrant}
18068
18069 \end_inset
18070
18071
18072 \begin_inset LatexCommand \index{Assembler routines (non-reentrant)}
18073
18074 \end_inset
18075
18076  the function c_func calls an assembler routine asm_func, which takes two
18077  parameters
18078 \begin_inset LatexCommand \index{function parameter}
18079
18080 \end_inset
18081
18082 .
18083 \end_layout
18084
18085 \begin_layout Verse
18086
18087 \family typewriter
18088 extern int asm_func(unsigned char, unsigned char);
18089 \newline
18090
18091 \newline
18092 int c_func (unsigned char
18093  i, unsigned char j)
18094 \newline
18095 {
18096 \newline
18097 \InsetSpace ~
18098 \InsetSpace ~
18099 \InsetSpace ~
18100 \InsetSpace ~
18101 return asm_func(i,j);
18102 \newline
18103 }
18104 \newline
18105
18106 \newline
18107 int main()
18108 \newline
18109 {
18110 \newline
18111 \InsetSpace ~
18112 \InsetSpace ~
18113 \InsetSpace ~
18114 \InsetSpace ~
18115 return c_func(10,9);
18116 \newline
18117 }
18118 \end_layout
18119
18120 \begin_layout Standard
18121 The corresponding assembler function is:
18122 \end_layout
18123
18124 \begin_layout Verse
18125
18126 \family typewriter
18127 .globl _asm_func_PARM_2
18128 \newline
18129 \InsetSpace ~
18130 \InsetSpace ~
18131 \InsetSpace ~
18132 \InsetSpace ~
18133 \InsetSpace ~
18134 \InsetSpace ~
18135 \InsetSpace ~
18136 \InsetSpace ~
18137 .globl _asm_func
18138 \newline
18139 \InsetSpace ~
18140 \InsetSpace ~
18141 \InsetSpace ~
18142 \InsetSpace ~
18143 \InsetSpace ~
18144 \InsetSpace ~
18145 \InsetSpace ~
18146 \InsetSpace ~
18147 .area OSEG
18148 \newline
18149 _asm_func_PARM_2:
18150 \newline
18151 \InsetSpace ~
18152 \InsetSpace ~
18153 \InsetSpace ~
18154 \InsetSpace ~
18155 \InsetSpace ~
18156 \InsetSpace ~
18157 \InsetSpace ~
18158 \InsetSpace ~
18159 .ds 1
18160 \newline
18161 \InsetSpace ~
18162 \InsetSpace ~
18163 \InsetSpace ~
18164 \InsetSpace ~
18165 \InsetSpace ~
18166 \InsetSpace ~
18167 \InsetSpace ~
18168 \InsetSpace ~
18169 .area
18170  CSEG
18171 \newline
18172 _asm_func:
18173 \newline
18174 \InsetSpace ~
18175 \InsetSpace ~
18176 \InsetSpace ~
18177 \InsetSpace ~
18178 \InsetSpace ~
18179 \InsetSpace ~
18180 \InsetSpace ~
18181 \InsetSpace ~
18182 mov\InsetSpace ~
18183 \InsetSpace ~
18184 \InsetSpace ~
18185 \InsetSpace ~
18186 a,dpl
18187 \newline
18188 \InsetSpace ~
18189 \InsetSpace ~
18190 \InsetSpace ~
18191 \InsetSpace ~
18192 \InsetSpace ~
18193 \InsetSpace ~
18194 \InsetSpace ~
18195 \InsetSpace ~
18196 add\InsetSpace ~
18197 \InsetSpace ~
18198 \InsetSpace ~
18199 \InsetSpace ~
18200 a,_asm_func_PARM_2
18201 \newline
18202 \InsetSpace ~
18203 \InsetSpace ~
18204 \InsetSpace ~
18205 \InsetSpace ~
18206 \InsetSpace ~
18207 \InsetSpace ~
18208 \InsetSpace ~
18209 \InsetSpace ~
18210 mov\InsetSpace ~
18211 \InsetSpace ~
18212 \InsetSpace ~
18213 \InsetSpace ~
18214 dpl,a
18215 \newline
18216 \InsetSpace ~
18217 \InsetSpace ~
18218 \InsetSpace ~
18219 \InsetSpace ~
18220 \InsetSpace ~
18221 \InsetSpace ~
18222 \InsetSpace ~
18223 \InsetSpace ~
18224 mov\InsetSpace ~
18225 \InsetSpace ~
18226 \InsetSpace ~
18227 \InsetSpace ~
18228 dph
18229 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
18230
18231 \end_inset
18232
18233 ,#0x00
18234 \newline
18235 \InsetSpace ~
18236 \InsetSpace ~
18237 \InsetSpace ~
18238 \InsetSpace ~
18239 \InsetSpace ~
18240 \InsetSpace ~
18241 \InsetSpace ~
18242 \InsetSpace ~
18243 ret
18244 \end_layout
18245
18246 \begin_layout Standard
18247 The parameter naming convention is _<function_name>_PARM_<n>, where n is
18248  the parameter number starting from 1, and counting from the left.
18249  The first parameter is passed in
18250 \emph on
18251 DPH
18252 \emph default
18253 ,
18254 \emph on
18255 DPL
18256 \emph default
18257 ,
18258 \emph on
18259 B
18260 \emph default
18261  and
18262 \emph on
18263 ACC
18264 \emph default
18265  according to the description above.
18266  The variable name for the second parameter will be _<function_name>_PARM_2.
18267 \newline
18268
18269 \newline
18270 Assem
18271 ble the assembler routine with the following command:
18272 \newline
18273
18274 \newline
18275
18276 \family sans
18277 \series bold
18278 asx8051 -losg asmfunc.asm
18279 \newline
18280
18281 \newline
18282
18283 \family default
18284 \series default
18285 Then compile and link the assembler routine to the C source file with the
18286  following command:
18287 \newline
18288
18289 \newline
18290
18291 \family sans
18292 \series bold
18293 sdcc cfunc.c asmfunc.rel
18294 \end_layout
18295
18296 \begin_layout Subsection
18297 Assembler Routine (reentrant)
18298 \end_layout
18299
18300 \begin_layout Standard
18301 In this case
18302 \begin_inset LatexCommand \index{reentrant}
18303
18304 \end_inset
18305
18306
18307 \begin_inset LatexCommand \index{Assembler routines (reentrant)}
18308
18309 \end_inset
18310
18311  the second parameter
18312 \begin_inset LatexCommand \index{function parameter}
18313
18314 \end_inset
18315
18316  onwards will be passed on the stack, the parameters are pushed from right
18317  to left i.e.
18318  before the call the second leftmost parameter will be on the top of the
18319  stack (the leftmost parameter is passed in registers).
18320  Here is an example:
18321 \end_layout
18322
18323 \begin_layout Verse
18324
18325 \family typewriter
18326 extern int asm_func(unsigned char, unsigned char, unsigned char) reentrant;
18327 \newline
18328
18329 \newline
18330 int
18331  c_func (unsigned char i, unsigned char j, unsigned char k) reentrant
18332 \newline
18333 {
18334 \newline
18335 \InsetSpace ~
18336 \InsetSpace ~
18337 \InsetSpace ~
18338 \InsetSpace ~
18339 return
18340  asm_func(i,j,k);
18341 \newline
18342 }
18343 \newline
18344
18345 \newline
18346 int main()
18347 \newline
18348 {
18349 \newline
18350 \InsetSpace ~
18351 \InsetSpace ~
18352 \InsetSpace ~
18353 \InsetSpace ~
18354 return c_func(10,9,8);
18355 \newline
18356 }
18357 \end_layout
18358
18359 \begin_layout Standard
18360 The corresponding (unoptimized) assembler routine is:
18361 \end_layout
18362
18363 \begin_layout Verse
18364
18365 \family typewriter
18366 .globl _asm_func
18367 \newline
18368 _asm_func:
18369 \newline
18370 \InsetSpace ~
18371 \InsetSpace ~
18372 \InsetSpace ~
18373 \InsetSpace ~
18374 push\InsetSpace ~
18375 _bp
18376 \newline
18377 \InsetSpace ~
18378 \InsetSpace ~
18379 \InsetSpace ~
18380 \InsetSpace ~
18381 mov\InsetSpace ~
18382 \InsetSpace ~
18383 _bp,sp\InsetSpace ~
18384 \InsetSpace ~
18385 \InsetSpace ~
18386 \InsetSpace ~
18387 \InsetSpace ~
18388 \InsetSpace ~
18389 ;stack contains: _bp, return address,
18390  second parameter, third parameter
18391 \newline
18392 \InsetSpace ~
18393 \InsetSpace ~
18394 \InsetSpace ~
18395 \InsetSpace ~
18396 mov\InsetSpace ~
18397 \InsetSpace ~
18398 r2,dpl
18399 \newline
18400 \InsetSpace ~
18401 \InsetSpace ~
18402 \InsetSpace ~
18403 \InsetSpace ~
18404 mov\InsetSpace ~
18405 \InsetSpace ~
18406 a,_bp
18407 \newline
18408 \InsetSpace ~
18409 \InsetSpace ~
18410 \InsetSpace ~
18411 \InsetSpace ~
18412 add\InsetSpace ~
18413 \InsetSpace ~
18414 a,#0xfd\InsetSpace ~
18415 \InsetSpace ~
18416 \InsetSpace ~
18417 \InsetSpace ~
18418 \InsetSpace ~
18419 ;calculate
18420  pointer to the second parameter
18421 \newline
18422 \InsetSpace ~
18423 \InsetSpace ~
18424 \InsetSpace ~
18425 \InsetSpace ~
18426 mov\InsetSpace ~
18427 \InsetSpace ~
18428 r0,a
18429 \newline
18430 \InsetSpace ~
18431 \InsetSpace ~
18432 \InsetSpace ~
18433 \InsetSpace ~
18434 mov\InsetSpace ~
18435 \InsetSpace ~
18436 a,_bp
18437 \newline
18438 \InsetSpace ~
18439 \InsetSpace ~
18440 \InsetSpace ~
18441 \InsetSpace ~
18442 add\InsetSpace ~
18443 \InsetSpace ~
18444 a,#0xfc\InsetSpace ~
18445 \InsetSpace ~
18446 \InsetSpace ~
18447 \InsetSpace ~
18448 \InsetSpace ~
18449 ;calculate pointer
18450  to the rightmost parameter
18451 \newline
18452 \InsetSpace ~
18453 \InsetSpace ~
18454 \InsetSpace ~
18455 \InsetSpace ~
18456 mov\InsetSpace ~
18457 \InsetSpace ~
18458 r1,a
18459 \newline
18460 \InsetSpace ~
18461 \InsetSpace ~
18462 \InsetSpace ~
18463 \InsetSpace ~
18464 mov\InsetSpace ~
18465 \InsetSpace ~
18466 a,@r0
18467 \newline
18468 \InsetSpace ~
18469 \InsetSpace ~
18470 \InsetSpace ~
18471 \InsetSpace ~
18472 add\InsetSpace ~
18473 \InsetSpace ~
18474 a,@r1
18475 \newline
18476 \InsetSpace ~
18477 \InsetSpace ~
18478 \InsetSpace ~
18479 \InsetSpace ~
18480 add\InsetSpace ~
18481 \InsetSpace ~
18482 a,r2\InsetSpace ~
18483 \InsetSpace ~
18484 \InsetSpace ~
18485 \InsetSpace ~
18486 \InsetSpace ~
18487 \InsetSpace ~
18488 \InsetSpace ~
18489 \InsetSpace ~
18490 ;calculate the
18491  result (= sum of all three parameters)
18492 \newline
18493 \InsetSpace ~
18494 \InsetSpace ~
18495 \InsetSpace ~
18496 \InsetSpace ~
18497 mov\InsetSpace ~
18498 \InsetSpace ~
18499 dpl,a\InsetSpace ~
18500 \InsetSpace ~
18501 \InsetSpace ~
18502 \InsetSpace ~
18503 \InsetSpace ~
18504 \InsetSpace ~
18505 \InsetSpace ~
18506 ;return value goes into dptr
18507  (cast into int)
18508 \newline
18509 \InsetSpace ~
18510 \InsetSpace ~
18511 \InsetSpace ~
18512 \InsetSpace ~
18513 mov\InsetSpace ~
18514 \InsetSpace ~
18515 dph,#0x00
18516 \newline
18517 \InsetSpace ~
18518 \InsetSpace ~
18519 \InsetSpace ~
18520 \InsetSpace ~
18521 mov\InsetSpace ~
18522 \InsetSpace ~
18523 sp,_bp
18524 \newline
18525 \InsetSpace ~
18526 \InsetSpace ~
18527 \InsetSpace ~
18528 \InsetSpace ~
18529 pop\InsetSpace ~
18530 \InsetSpace ~
18531 _bp
18532 \newline
18533 \InsetSpace ~
18534 \InsetSpace ~
18535 \InsetSpace ~
18536 \InsetSpace ~
18537 ret
18538 \end_layout
18539
18540 \begin_layout Standard
18541 The compiling and linking procedure remains the same, however note the extra
18542  entry & exit linkage required for the assembler code, _bp is the stack
18543  frame pointer and is used to compute the offset into the stack for parameters
18544  and local variables.
18545 \begin_inset VSpace bigskip
18546 \end_inset
18547
18548
18549 \end_layout
18550
18551 \begin_layout Section
18552 int (16 bit)
18553 \begin_inset LatexCommand \index{int (16 bit)}
18554
18555 \end_inset
18556
18557  and long (32 bit)
18558 \begin_inset LatexCommand \index{long (32 bit)}
18559
18560 \end_inset
18561
18562  Support
18563 \end_layout
18564
18565 \begin_layout Standard
18566 For signed & unsigned int (16 bit) and long (32 bit) variables, division,
18567  multiplication and modulus operations are implemented by support routines.
18568  These support routines are all developed in ANSI-C to facilitate porting
18569  to other MCUs, although some model specific assembler optimizations are
18570  used.
18571  The following files contain the described routines, all of them can be
18572  found in <installdir>/share/sdcc/lib.
18573 \newline
18574
18575 \end_layout
18576
18577 \begin_layout Standard
18578 \align center
18579 \begin_inset Tabular
18580 <lyxtabular version="3" rows="11" columns="2">
18581 <features>
18582 <column alignment="left" valignment="top" leftline="true" width="0">
18583 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
18584 <row topline="true" bottomline="true">
18585 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18586 \begin_inset Text
18587
18588 \begin_layout Standard
18589
18590 \series bold
18591 Function
18592 \end_layout
18593
18594 \end_inset
18595 </cell>
18596 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18597 \begin_inset Text
18598
18599 \begin_layout Standard
18600
18601 \series bold
18602 Description
18603 \end_layout
18604
18605 \end_inset
18606 </cell>
18607 </row>
18608 <row topline="true">
18609 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18610 \begin_inset Text
18611
18612 \begin_layout Standard
18613 _mulint.c
18614 \end_layout
18615
18616 \end_inset
18617 </cell>
18618 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18619 \begin_inset Text
18620
18621 \begin_layout Standard
18622 16 bit multiplication
18623 \end_layout
18624
18625 \end_inset
18626 </cell>
18627 </row>
18628 <row topline="true">
18629 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18630 \begin_inset Text
18631
18632 \begin_layout Standard
18633 _divsint.c
18634 \end_layout
18635
18636 \end_inset
18637 </cell>
18638 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18639 \begin_inset Text
18640
18641 \begin_layout Standard
18642  signed 16 bit division (calls _divuint)
18643 \end_layout
18644
18645 \end_inset
18646 </cell>
18647 </row>
18648 <row topline="true">
18649 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18650 \begin_inset Text
18651
18652 \begin_layout Standard
18653 _divuint.c
18654 \end_layout
18655
18656 \end_inset
18657 </cell>
18658 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18659 \begin_inset Text
18660
18661 \begin_layout Standard
18662  unsigned 16 bit division
18663 \end_layout
18664
18665 \end_inset
18666 </cell>
18667 </row>
18668 <row topline="true">
18669 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18670 \begin_inset Text
18671
18672 \begin_layout Standard
18673 _modsint.c
18674 \end_layout
18675
18676 \end_inset
18677 </cell>
18678 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18679 \begin_inset Text
18680
18681 \begin_layout Standard
18682 signed 16 bit modulus (calls _moduint)
18683 \end_layout
18684
18685 \end_inset
18686 </cell>
18687 </row>
18688 <row topline="true">
18689 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18690 \begin_inset Text
18691
18692 \begin_layout Standard
18693 _moduint.c
18694 \end_layout
18695
18696 \end_inset
18697 </cell>
18698 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18699 \begin_inset Text
18700
18701 \begin_layout Standard
18702 unsigned 16 bit modulus
18703 \end_layout
18704
18705 \end_inset
18706 </cell>
18707 </row>
18708 <row topline="true">
18709 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18710 \begin_inset Text
18711
18712 \begin_layout Standard
18713 _mullong.c
18714 \end_layout
18715
18716 \end_inset
18717 </cell>
18718 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18719 \begin_inset Text
18720
18721 \begin_layout Standard
18722 32 bit multiplication
18723 \end_layout
18724
18725 \end_inset
18726 </cell>
18727 </row>
18728 <row topline="true">
18729 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18730 \begin_inset Text
18731
18732 \begin_layout Standard
18733 _divslong.c
18734 \end_layout
18735
18736 \end_inset
18737 </cell>
18738 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18739 \begin_inset Text
18740
18741 \begin_layout Standard
18742  signed 32 division (calls _divulong)
18743 \end_layout
18744
18745 \end_inset
18746 </cell>
18747 </row>
18748 <row topline="true">
18749 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18750 \begin_inset Text
18751
18752 \begin_layout Standard
18753 _divulong.c
18754 \end_layout
18755
18756 \end_inset
18757 </cell>
18758 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18759 \begin_inset Text
18760
18761 \begin_layout Standard
18762 unsigned 32 division
18763 \end_layout
18764
18765 \end_inset
18766 </cell>
18767 </row>
18768 <row topline="true">
18769 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18770 \begin_inset Text
18771
18772 \begin_layout Standard
18773 _modslong.c
18774 \end_layout
18775
18776 \end_inset
18777 </cell>
18778 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18779 \begin_inset Text
18780
18781 \begin_layout Standard
18782  signed 32 bit modulus (calls _modulong)
18783 \end_layout
18784
18785 \end_inset
18786 </cell>
18787 </row>
18788 <row topline="true" bottomline="true">
18789 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18790 \begin_inset Text
18791
18792 \begin_layout Standard
18793 _modulong.c
18794 \end_layout
18795
18796 \end_inset
18797 </cell>
18798 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18799 \begin_inset Text
18800
18801 \begin_layout Standard
18802 unsigned 32 bit modulus
18803 \end_layout
18804
18805 \end_inset
18806 </cell>
18807 </row>
18808 </lyxtabular>
18809
18810 \end_inset
18811
18812
18813 \newline
18814
18815 \end_layout
18816
18817 \begin_layout Standard
18818 Since they are compiled as
18819 \emph on
18820 non-reentrant
18821 \emph default
18822
18823 \begin_inset LatexCommand \index{reentrant}
18824
18825 \end_inset
18826
18827 , interrupt
18828 \begin_inset LatexCommand \index{interrupt}
18829
18830 \end_inset
18831
18832  service routines should not do any of the above operations.
18833  If this is unavoidable then the above routines will need to be compiled
18834  with the
18835 \emph on
18836 -
18837 \begin_inset ERT
18838 status collapsed
18839
18840 \begin_layout Standard
18841
18842
18843 \backslash
18844 /
18845 \end_layout
18846
18847 \end_inset
18848
18849 -stack-auto
18850 \begin_inset LatexCommand \index{-\/-stack-auto}
18851
18852 \end_inset
18853
18854
18855 \emph default
18856  option, after which the source program will have to be compiled with
18857 \emph on
18858 -
18859 \begin_inset ERT
18860 status collapsed
18861
18862 \begin_layout Standard
18863
18864
18865 \backslash
18866 /
18867 \end_layout
18868
18869 \end_inset
18870
18871 -int-long-reent
18872 \begin_inset LatexCommand \index{-\/-int-long-reent}
18873
18874 \end_inset
18875
18876
18877 \emph default
18878  option.
18879  Notice that you don't have to call these routines directly.
18880  The compiler will use them automatically every time an integer operation
18881  is required.
18882 \end_layout
18883
18884 \begin_layout Section
18885 Floating Point Support
18886 \begin_inset LatexCommand \index{Floating point support}
18887
18888 \end_inset
18889
18890
18891 \end_layout
18892
18893 \begin_layout Standard
18894 SDCC supports IEEE (single precision 4 bytes) floating point numbers.
18895  The floating point support routines are derived from gcc's floatlib.c and
18896  consist of the following routines:
18897 \newline
18898
18899 \end_layout
18900
18901 \begin_layout Standard
18902 \align center
18903
18904 \size footnotesize
18905 \begin_inset Tabular
18906 <lyxtabular version="3" rows="17" columns="2">
18907 <features>
18908 <column alignment="left" valignment="top" leftline="true" width="0">
18909 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
18910 <row topline="true" bottomline="true">
18911 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18912 \begin_inset Text
18913
18914 \begin_layout Standard
18915
18916 \family roman
18917 \series medium
18918 \shape up
18919 \size normal
18920 \emph off
18921 \bar no
18922 \noun off
18923 \color none
18924 Function
18925 \end_layout
18926
18927 \end_inset
18928 </cell>
18929 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18930 \begin_inset Text
18931
18932 \begin_layout Standard
18933 Description
18934 \end_layout
18935
18936 \end_inset
18937 </cell>
18938 </row>
18939 <row topline="true">
18940 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18941 \begin_inset Text
18942
18943 \begin_layout Standard
18944
18945 \family roman
18946 \series medium
18947 \shape up
18948 \size normal
18949 \emph off
18950 \bar no
18951 \noun off
18952 \color none
18953 _fsadd.c
18954 \end_layout
18955
18956 \end_inset
18957 </cell>
18958 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18959 \begin_inset Text
18960
18961 \begin_layout Standard
18962
18963 \family roman
18964 \series medium
18965 \shape up
18966 \size normal
18967 \emph off
18968 \bar no
18969 \noun off
18970 \color none
18971 add floating point numbers
18972 \end_layout
18973
18974 \end_inset
18975 </cell>
18976 </row>
18977 <row topline="true">
18978 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18979 \begin_inset Text
18980
18981 \begin_layout Standard
18982
18983 \family roman
18984 \series medium
18985 \shape up
18986 \size normal
18987 \emph off
18988 \bar no
18989 \noun off
18990 \color none
18991 _fssub.c
18992 \end_layout
18993
18994 \end_inset
18995 </cell>
18996 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18997 \begin_inset Text
18998
18999 \begin_layout Standard
19000
19001 \family roman
19002 \series medium
19003 \shape up
19004 \size normal
19005 \emph off
19006 \bar no
19007 \noun off
19008 \color none
19009 subtract floating point numbers
19010 \end_layout
19011
19012 \end_inset
19013 </cell>
19014 </row>
19015 <row topline="true">
19016 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19017 \begin_inset Text
19018
19019 \begin_layout Standard
19020
19021 \family roman
19022 \series medium
19023 \shape up
19024 \size normal
19025 \emph off
19026 \bar no
19027 \noun off
19028 \color none
19029 _fsdiv.c
19030 \end_layout
19031
19032 \end_inset
19033 </cell>
19034 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19035 \begin_inset Text
19036
19037 \begin_layout Standard
19038
19039 \family roman
19040 \series medium
19041 \shape up
19042 \size normal
19043 \emph off
19044 \bar no
19045 \noun off
19046 \color none
19047 divide floating point numbers
19048 \end_layout
19049
19050 \end_inset
19051 </cell>
19052 </row>
19053 <row topline="true">
19054 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19055 \begin_inset Text
19056
19057 \begin_layout Standard
19058
19059 \family roman
19060 \series medium
19061 \shape up
19062 \size normal
19063 \emph off
19064 \bar no
19065 \noun off
19066 \color none
19067 _fsmul.c
19068 \end_layout
19069
19070 \end_inset
19071 </cell>
19072 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19073 \begin_inset Text
19074
19075 \begin_layout Standard
19076
19077 \family roman
19078 \series medium
19079 \shape up
19080 \size normal
19081 \emph off
19082 \bar no
19083 \noun off
19084 \color none
19085 multiply floating point numbers
19086 \end_layout
19087
19088 \end_inset
19089 </cell>
19090 </row>
19091 <row topline="true">
19092 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19093 \begin_inset Text
19094
19095 \begin_layout Standard
19096
19097 \family roman
19098 \series medium
19099 \shape up
19100 \size normal
19101 \emph off
19102 \bar no
19103 \noun off
19104 \color none
19105 _fs2uchar.c
19106 \end_layout
19107
19108 \end_inset
19109 </cell>
19110 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19111 \begin_inset Text
19112
19113 \begin_layout Standard
19114
19115 \family roman
19116 \series medium
19117 \shape up
19118 \size normal
19119 \emph off
19120 \bar no
19121 \noun off
19122 \color none
19123 convert floating point to unsigned char
19124 \end_layout
19125
19126 \end_inset
19127 </cell>
19128 </row>
19129 <row topline="true">
19130 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19131 \begin_inset Text
19132
19133 \begin_layout Standard
19134
19135 \family roman
19136 \series medium
19137 \shape up
19138 \size normal
19139 \emph off
19140 \bar no
19141 \noun off
19142 \color none
19143 _fs2char.c
19144 \end_layout
19145
19146 \end_inset
19147 </cell>
19148 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19149 \begin_inset Text
19150
19151 \begin_layout Standard
19152
19153 \family roman
19154 \series medium
19155 \shape up
19156 \size normal
19157 \emph off
19158 \bar no
19159 \noun off
19160 \color none
19161 convert floating point to signed char
19162 \end_layout
19163
19164 \end_inset
19165 </cell>
19166 </row>
19167 <row topline="true">
19168 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19169 \begin_inset Text
19170
19171 \begin_layout Standard
19172
19173 \family roman
19174 \series medium
19175 \shape up
19176 \size normal
19177 \emph off
19178 \bar no
19179 \noun off
19180 \color none
19181 _fs2uint.c
19182 \end_layout
19183
19184 \end_inset
19185 </cell>
19186 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19187 \begin_inset Text
19188
19189 \begin_layout Standard
19190
19191 \family roman
19192 \series medium
19193 \shape up
19194 \size normal
19195 \emph off
19196 \bar no
19197 \noun off
19198 \color none
19199 convert floating point to unsigned int
19200 \end_layout
19201
19202 \end_inset
19203 </cell>
19204 </row>
19205 <row topline="true">
19206 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19207 \begin_inset Text
19208
19209 \begin_layout Standard
19210
19211 \family roman
19212 \series medium
19213 \shape up
19214 \size normal
19215 \emph off
19216 \bar no
19217 \noun off
19218 \color none
19219 _fs2int.c
19220 \end_layout
19221
19222 \end_inset
19223 </cell>
19224 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19225 \begin_inset Text
19226
19227 \begin_layout Standard
19228
19229 \family roman
19230 \series medium
19231 \shape up
19232 \size normal
19233 \emph off
19234 \bar no
19235 \noun off
19236 \color none
19237 convert floating point to signed int
19238 \end_layout
19239
19240 \end_inset
19241 </cell>
19242 </row>
19243 <row topline="true">
19244 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19245 \begin_inset Text
19246
19247 \begin_layout Standard
19248
19249 \family roman
19250 \series medium
19251 \shape up
19252 \size normal
19253 \emph off
19254 \bar no
19255 \noun off
19256 \color none
19257 _fs2ulong.
19258 \family default
19259 \series default
19260 \shape default
19261 \size default
19262 \emph default
19263 \bar default
19264 \noun default
19265 c
19266 \end_layout
19267
19268 \end_inset
19269 </cell>
19270 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19271 \begin_inset Text
19272
19273 \begin_layout Standard
19274
19275 \family roman
19276 \series medium
19277 \shape up
19278 \size normal
19279 \emph off
19280 \bar no
19281 \noun off
19282 \color none
19283 convert floating point to unsigned long
19284 \end_layout
19285
19286 \end_inset
19287 </cell>
19288 </row>
19289 <row topline="true">
19290 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19291 \begin_inset Text
19292
19293 \begin_layout Standard
19294
19295 \family roman
19296 \series medium
19297 \shape up
19298 \size normal
19299 \emph off
19300 \bar no
19301 \noun off
19302 \color none
19303 _fs2long.c
19304 \end_layout
19305
19306 \end_inset
19307 </cell>
19308 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19309 \begin_inset Text
19310
19311 \begin_layout Standard
19312
19313 \family roman
19314 \series medium
19315 \shape up
19316 \size normal
19317 \emph off
19318 \bar no
19319 \noun off
19320 \color none
19321 convert floating point to signed long
19322 \end_layout
19323
19324 \end_inset
19325 </cell>
19326 </row>
19327 <row topline="true">
19328 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19329 \begin_inset Text
19330
19331 \begin_layout Standard
19332
19333 \family roman
19334 \series medium
19335 \shape up
19336 \size normal
19337 \emph off
19338 \bar no
19339 \noun off
19340 \color none
19341 _uchar2fs.c
19342 \end_layout
19343
19344 \end_inset
19345 </cell>
19346 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19347 \begin_inset Text
19348
19349 \begin_layout Standard
19350
19351 \family roman
19352 \series medium
19353 \shape up
19354 \size normal
19355 \emph off
19356 \bar no
19357 \noun off
19358 \color none
19359 convert unsigned char to floating point
19360 \end_layout
19361
19362 \end_inset
19363 </cell>
19364 </row>
19365 <row topline="true">
19366 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19367 \begin_inset Text
19368
19369 \begin_layout Standard
19370
19371 \family roman
19372 \series medium
19373 \shape up
19374 \size normal
19375 \emph off
19376 \bar no
19377 \noun off
19378 \color none
19379 _char2fs.c
19380 \end_layout
19381
19382 \end_inset
19383 </cell>
19384 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19385 \begin_inset Text
19386
19387 \begin_layout Standard
19388
19389 \family roman
19390 \series medium
19391 \shape up
19392 \size normal
19393 \emph off
19394 \bar no
19395 \noun off
19396 \color none
19397 convert char to floating point number
19398 \end_layout
19399
19400 \end_inset
19401 </cell>
19402 </row>
19403 <row topline="true">
19404 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19405 \begin_inset Text
19406
19407 \begin_layout Standard
19408
19409 \family roman
19410 \series medium
19411 \shape up
19412 \size normal
19413 \emph off
19414 \bar no
19415 \noun off
19416 \color none
19417 _uint2fs.c
19418 \end_layout
19419
19420 \end_inset
19421 </cell>
19422 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19423 \begin_inset Text
19424
19425 \begin_layout Standard
19426
19427 \family roman
19428 \series medium
19429 \shape up
19430 \size normal
19431 \emph off
19432 \bar no
19433 \noun off
19434 \color none
19435 convert unsigned int to floating point
19436 \end_layout
19437
19438 \end_inset
19439 </cell>
19440 </row>
19441 <row topline="true">
19442 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19443 \begin_inset Text
19444
19445 \begin_layout Standard
19446
19447 \family roman
19448 \series medium
19449 \shape up
19450 \size normal
19451 \emph off
19452 \bar no
19453 \noun off
19454 \color none
19455 _int2fs.c
19456 \end_layout
19457
19458 \end_inset
19459 </cell>
19460 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19461 \begin_inset Text
19462
19463 \begin_layout Standard
19464
19465 \family roman
19466 \series medium
19467 \shape up
19468 \size normal
19469 \emph off
19470 \bar no
19471 \noun off
19472 \color none
19473 convert int to floating point numbers
19474 \end_layout
19475
19476 \end_inset
19477 </cell>
19478 </row>
19479 <row topline="true">
19480 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19481 \begin_inset Text
19482
19483 \begin_layout Standard
19484
19485 \family roman
19486 \series medium
19487 \shape up
19488 \size normal
19489 \emph off
19490 \bar no
19491 \noun off
19492 \color none
19493 _ulong2fs.c
19494 \end_layout
19495
19496 \end_inset
19497 </cell>
19498 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19499 \begin_inset Text
19500
19501 \begin_layout Standard
19502
19503 \family roman
19504 \series medium
19505 \shape up
19506 \size normal
19507 \emph off
19508 \bar no
19509 \noun off
19510 \color none
19511 convert unsigned long to floating point number
19512 \end_layout
19513
19514 \end_inset
19515 </cell>
19516 </row>
19517 <row topline="true" bottomline="true">
19518 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19519 \begin_inset Text
19520
19521 \begin_layout Standard
19522
19523 \family roman
19524 \series medium
19525 \shape up
19526 \size normal
19527 \emph off
19528 \bar no
19529 \noun off
19530 \color none
19531 _long2fs.c
19532 \end_layout
19533
19534 \end_inset
19535 </cell>
19536 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19537 \begin_inset Text
19538
19539 \begin_layout Standard
19540
19541 \family roman
19542 \series medium
19543 \shape up
19544 \size normal
19545 \emph off
19546 \bar no
19547 \noun off
19548 \color none
19549 convert long to floating point number
19550 \end_layout
19551
19552 \end_inset
19553 </cell>
19554 </row>
19555 </lyxtabular>
19556
19557 \end_inset
19558
19559
19560 \newline
19561
19562 \end_layout
19563
19564 \begin_layout Standard
19565 These support routines are developed in ANSI-C so there is room for space
19566  and speed improvement
19567 \begin_inset Foot
19568 status open
19569
19570 \begin_layout Standard
19571 These floating point routines (
19572 \emph on
19573 not
19574 \emph default
19575  sinf(), cosf(), ...) for the mcs51 are implemented in assembler.
19576 \end_layout
19577
19578 \end_inset
19579
19580 .
19581  Note if all these routines are used simultaneously the data space might
19582  overflow.
19583  For serious floating point usage the large model might be needed.
19584  Also notice that you don't have to call this routines directly.
19585  The compiler will use them automatically every time a floating point operation
19586  is required.
19587 \begin_inset VSpace bigskip
19588 \end_inset
19589
19590
19591 \end_layout
19592
19593 \begin_layout Section
19594 Library Routines
19595 \begin_inset LatexCommand \index{Libraries}
19596
19597 \end_inset
19598
19599
19600 \end_layout
19601
19602 \begin_layout Standard
19603
19604 \emph on
19605 <pending: this is messy and incomplete - a little more information is in
19606  sdcc/doc/libdoc.txt
19607 \emph default
19608  >
19609 \end_layout
19610
19611 \begin_layout Subsection
19612 Compiler support routines (_gptrget, _mulint etc.)
19613 \end_layout
19614
19615 \begin_layout Subsection
19616 Stdclib functions (puts, printf, strcat etc.)
19617 \end_layout
19618
19619 \begin_layout Subsubsection
19620 <stdio.h>
19621 \end_layout
19622
19623 \begin_layout Paragraph
19624 getchar(), putchar()
19625 \end_layout
19626
19627 \begin_layout Standard
19628 \begin_inset LatexCommand \index{<stdio.h>}
19629
19630 \end_inset
19631
19632 As usual on embedded systems you have to provide your own
19633 \family typewriter
19634 getchar()
19635 \begin_inset LatexCommand \index{getchar()}
19636
19637 \end_inset
19638
19639
19640 \family default
19641 and
19642 \family typewriter
19643 putchar()
19644 \begin_inset LatexCommand \index{putchar()}
19645
19646 \end_inset
19647
19648
19649 \family default
19650  routines.
19651  SDCC does not know whether the system connects to a serial line with or
19652  without handshake, LCD, keyboard or other device.
19653  And whether a
19654 \family typewriter
19655 lf
19656 \family default
19657  to
19658 \family typewriter
19659 crlf
19660 \family default
19661  conversion within
19662 \family typewriter
19663 putchar()
19664 \family default
19665  is intended.
19666  You'll find examples for serial routines f.e.
19667  in sdcc/device/lib.
19668  For the mcs51 this minimalistic polling
19669 \family typewriter
19670 putchar()
19671 \family default
19672  routine might be a start:
19673 \end_layout
19674
19675 \begin_layout Verse
19676
19677 \family typewriter
19678 void putchar (char c) {
19679 \newline
19680 \InsetSpace ~
19681 \InsetSpace ~
19682 \InsetSpace ~
19683 \InsetSpace ~
19684 while (!TI)\InsetSpace ~
19685 \InsetSpace ~
19686 \InsetSpace ~
19687  /* assumes UART is initialized */
19688 \newline
19689 \InsetSpace ~
19690 \InsetSpace ~
19691 \InsetSpace ~
19692 \InsetSpace ~
19693 \InsetSpace ~
19694 \InsetSpace ~
19695 \InsetSpace ~
19696 \InsetSpace ~
19697 ;
19698 \newline
19699 \InsetSpace ~
19700 \InsetSpace ~
19701 \InsetSpace ~
19702 \InsetSpace ~
19703 TI
19704  = 0;
19705 \newline
19706 \InsetSpace ~
19707 \InsetSpace ~
19708 \InsetSpace ~
19709 \InsetSpace ~
19710 SBUF = c;
19711 \newline
19712 }
19713 \end_layout
19714
19715 \begin_layout Paragraph
19716 printf()
19717 \end_layout
19718
19719 \begin_layout Standard
19720 The default
19721 \family typewriter
19722  printf()
19723 \begin_inset LatexCommand \index{printf()}
19724
19725 \end_inset
19726
19727
19728 \family default
19729  implementation in
19730 \family typewriter
19731  printf_large.c
19732 \family default
19733  does not support float (except on ds390).
19734  To enable this recompile it with the option
19735 \emph on
19736 -
19737 \begin_inset ERT
19738 status collapsed
19739
19740 \begin_layout Standard
19741
19742
19743 \backslash
19744 /
19745 \end_layout
19746
19747 \end_inset
19748
19749 DUSE_FLOATS=1
19750 \begin_inset LatexCommand \index{USE\_FLOATS}
19751
19752 \end_inset
19753
19754
19755 \emph default
19756  on the command line.
19757  Use
19758 \emph on
19759  -
19760 \begin_inset ERT
19761 status collapsed
19762
19763 \begin_layout Standard
19764
19765
19766 \backslash
19767 /
19768 \end_layout
19769
19770 \end_inset
19771
19772 -model-large
19773 \begin_inset LatexCommand \index{-\/-model-large}
19774
19775 \end_inset
19776
19777
19778 \emph default
19779  for the mcs51 port, since this uses a lot of memory.
19780 \end_layout
19781
19782 \begin_layout Standard
19783 If you're short on code memory you might want to use
19784 \family typewriter
19785 printf_small()
19786 \begin_inset LatexCommand \index{printf\_small()}
19787
19788 \end_inset
19789
19790
19791 \family default
19792 \emph on
19793 instead
19794 \emph default
19795  of
19796 \family typewriter
19797  printf().
19798
19799 \family default
19800  For the mcs51 there additionally are assembly versions
19801 \family typewriter
19802 printf_tiny()
19803 \begin_inset LatexCommand \index{printf\_tiny() (mcs51)}
19804
19805 \end_inset
19806
19807
19808 \family default
19809  (subset of printf using less than 270 bytes) and
19810 \family typewriter
19811 printf_fast()
19812 \begin_inset LatexCommand \index{printf\_fast() (mcs51)}
19813
19814 \end_inset
19815
19816
19817 \family default
19818 and
19819 \family typewriter
19820  printf_fast_f()
19821 \begin_inset LatexCommand \index{printf\_fast\_f() (mcs51)}
19822
19823 \end_inset
19824
19825
19826 \family default
19827  (floating-point aware version of printf_fast) which should fit the requirements
19828  of many embedded systems (printf_fast() can be customized by unsetting
19829  #defines to
19830 \emph on
19831 not
19832 \emph default
19833  support long variables and field widths).
19834  Be sure to use only one of these printf options within a project.
19835 \newline
19836
19837 \end_layout
19838
19839 \begin_layout Standard
19840 Feature matrix of different
19841 \emph on
19842 printf
19843 \emph default
19844  options on mcs51.
19845 \end_layout
19846
19847 \begin_layout Standard
19848 \begin_inset Tabular
19849 <lyxtabular version="3" rows="14" columns="7">
19850 <features islongtable="true">
19851 <column alignment="left" valignment="middle" leftline="true" width="14col%">
19852 <column alignment="center" valignment="top" leftline="true" width="0">
19853 <column alignment="center" valignment="top" leftline="true" width="12col%">
19854 <column alignment="center" valignment="top" leftline="true" width="10col%">
19855 <column alignment="center" valignment="top" leftline="true" width="0">
19856 <column alignment="center" valignment="top" leftline="true" rightline="true" width="12col%">
19857 <column alignment="center" valignment="top" rightline="true" width="0">
19858 <row topline="true" bottomline="true" endhead="true">
19859 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19860 \begin_inset Text
19861
19862 \begin_layout Standard
19863
19864 \series bold
19865 \size large
19866 mcs51
19867 \end_layout
19868
19869 \end_inset
19870 </cell>
19871 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19872 \begin_inset Text
19873
19874 \begin_layout Standard
19875 printf
19876 \begin_inset LatexCommand \index{printf}
19877
19878 \end_inset
19879
19880
19881 \end_layout
19882
19883 \end_inset
19884 </cell>
19885 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19886 \begin_inset Text
19887
19888 \begin_layout Standard
19889 printf
19890 \size scriptsize
19891 USE_FLOATS=1
19892 \end_layout
19893
19894 \end_inset
19895 </cell>
19896 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19897 \begin_inset Text
19898
19899 \begin_layout Standard
19900 printf_small
19901 \end_layout
19902
19903 \end_inset
19904 </cell>
19905 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19906 \begin_inset Text
19907
19908 \begin_layout Standard
19909 printf_fast
19910 \end_layout
19911
19912 \end_inset
19913 </cell>
19914 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19915 \begin_inset Text
19916
19917 \begin_layout Standard
19918 printf_fast_f
19919 \end_layout
19920
19921 \end_inset
19922 </cell>
19923 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19924 \begin_inset Text
19925
19926 \begin_layout Standard
19927 printf_tiny
19928 \end_layout
19929
19930 \end_inset
19931 </cell>
19932 </row>
19933 <row topline="true" endhead="true">
19934 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19935 \begin_inset Text
19936
19937 \begin_layout Standard
19938 filename
19939 \end_layout
19940
19941 \end_inset
19942 </cell>
19943 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19944 \begin_inset Text
19945
19946 \begin_layout Standard
19947
19948 \size scriptsize
19949 printf_large.c
19950 \end_layout
19951
19952 \end_inset
19953 </cell>
19954 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19955 \begin_inset Text
19956
19957 \begin_layout Standard
19958
19959 \size scriptsize
19960 printf_large.c
19961 \end_layout
19962
19963 \end_inset
19964 </cell>
19965 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19966 \begin_inset Text
19967
19968 \begin_layout Standard
19969
19970 \size scriptsize
19971 printfl.c
19972 \end_layout
19973
19974 \end_inset
19975 </cell>
19976 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19977 \begin_inset Text
19978
19979 \begin_layout Standard
19980
19981 \size scriptsize
19982 printf_fast.c
19983 \end_layout
19984
19985 \end_inset
19986 </cell>
19987 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19988 \begin_inset Text
19989
19990 \begin_layout Standard
19991
19992 \size scriptsize
19993 printf_fast_f.c
19994 \end_layout
19995
19996 \end_inset
19997 </cell>
19998 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19999 \begin_inset Text
20000
20001 \begin_layout Standard
20002
20003 \size scriptsize
20004 printf_tiny.c
20005 \end_layout
20006
20007 \end_inset
20008 </cell>
20009 </row>
20010 <row topline="true" endhead="true">
20011 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20012 \begin_inset Text
20013
20014 \begin_layout Standard
20015 \begin_inset Quotes sld
20016 \end_inset
20017
20018 Hello World
20019 \begin_inset Quotes srd
20020 \end_inset
20021
20022  size
20023 \end_layout
20024
20025 \begin_layout Standard
20026 small / large
20027 \end_layout
20028
20029 \end_inset
20030 </cell>
20031 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20032 \begin_inset Text
20033
20034 \begin_layout Standard
20035 1.7k / 2.4k
20036 \end_layout
20037
20038 \end_inset
20039 </cell>
20040 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20041 \begin_inset Text
20042
20043 \begin_layout Standard
20044 4.3k / 5.6k
20045 \end_layout
20046
20047 \end_inset
20048 </cell>
20049 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20050 \begin_inset Text
20051
20052 \begin_layout Standard
20053 1.2k / 1.8k
20054 \end_layout
20055
20056 \end_inset
20057 </cell>
20058 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20059 \begin_inset Text
20060
20061 \begin_layout Standard
20062 1.3k / 1.3k
20063 \end_layout
20064
20065 \end_inset
20066 </cell>
20067 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20068 \begin_inset Text
20069
20070 \begin_layout Standard
20071 1.9k / 1.9k
20072 \end_layout
20073
20074 \end_inset
20075 </cell>
20076 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20077 \begin_inset Text
20078
20079 \begin_layout Standard
20080 0.44k / 0.44k
20081 \end_layout
20082
20083 \end_inset
20084 </cell>
20085 </row>
20086 <row topline="true" endhead="true">
20087 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20088 \begin_inset Text
20089
20090 \begin_layout Standard
20091 code size
20092 \end_layout
20093
20094 \begin_layout Standard
20095 small / large
20096 \end_layout
20097
20098 \end_inset
20099 </cell>
20100 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20101 \begin_inset Text
20102
20103 \begin_layout Standard
20104 1.4k / 2.0k
20105 \end_layout
20106
20107 \end_inset
20108 </cell>
20109 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20110 \begin_inset Text
20111
20112 \begin_layout Standard
20113 2.8k / 3.7k
20114 \end_layout
20115
20116 \end_inset
20117 </cell>
20118 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20119 \begin_inset Text
20120
20121 \begin_layout Standard
20122 0.45k / 0.47k (+ _ltoa)
20123 \end_layout
20124
20125 \end_inset
20126 </cell>
20127 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20128 \begin_inset Text
20129
20130 \begin_layout Standard
20131 1.2k / 1.2k
20132 \end_layout
20133
20134 \end_inset
20135 </cell>
20136 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20137 \begin_inset Text
20138
20139 \begin_layout Standard
20140 1.6k / 1.6k
20141 \end_layout
20142
20143 \end_inset
20144 </cell>
20145 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20146 \begin_inset Text
20147
20148 \begin_layout Standard
20149 0.26k / 0.26k
20150 \end_layout
20151
20152 \end_inset
20153 </cell>
20154 </row>
20155 <row topline="true">
20156 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20157 \begin_inset Text
20158
20159 \begin_layout Standard
20160 formats
20161 \end_layout
20162
20163 \end_inset
20164 </cell>
20165 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20166 \begin_inset Text
20167
20168 \begin_layout Standard
20169 cdi
20170 \emph on
20171 o
20172 \emph default
20173 psux
20174 \end_layout
20175
20176 \end_inset
20177 </cell>
20178 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20179 \begin_inset Text
20180
20181 \begin_layout Standard
20182
20183 \family roman
20184 \series medium
20185 \shape up
20186 \size normal
20187 \emph off
20188 \bar no
20189 \noun off
20190 \color none
20191 cd
20192 \family default
20193 \series default
20194 \shape default
20195 \size default
20196 \emph default
20197 \bar default
20198 \noun default
20199 f
20200 \family roman
20201 \series medium
20202 \shape up
20203 \size normal
20204 \emph off
20205 \bar no
20206 \noun off
20207 i
20208 \family default
20209 \series default
20210 \shape default
20211 \size default
20212 \emph on
20213 \bar default
20214 \noun default
20215 o
20216 \family roman
20217 \series medium
20218 \shape up
20219 \size normal
20220 \emph off
20221 \bar no
20222 \noun off
20223 psux
20224 \end_layout
20225
20226 \end_inset
20227 </cell>
20228 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20229 \begin_inset Text
20230
20231 \begin_layout Standard
20232 c
20233 \family roman
20234 \series medium
20235 \shape up
20236 \size normal
20237 \emph off
20238 \bar no
20239 \noun off
20240 \color none
20241 d
20242 \family default
20243 \series default
20244 \shape default
20245 \size default
20246 \emph on
20247 \bar default
20248 \noun default
20249 o
20250 \family roman
20251 \series medium
20252 \shape up
20253 \size normal
20254 \emph off
20255 \bar no
20256 \noun off
20257 s
20258 \family default
20259 \series default
20260 \shape default
20261 \size default
20262 \emph default
20263 \bar default
20264 \noun default
20265 x
20266 \end_layout
20267
20268 \end_inset
20269 </cell>
20270 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20271 \begin_inset Text
20272
20273 \begin_layout Standard
20274 cdsux
20275 \end_layout
20276
20277 \end_inset
20278 </cell>
20279 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20280 \begin_inset Text
20281
20282 \begin_layout Standard
20283 cdfsux
20284 \end_layout
20285
20286 \end_inset
20287 </cell>
20288 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20289 \begin_inset Text
20290
20291 \begin_layout Standard
20292 cdsux
20293 \end_layout
20294
20295 \end_inset
20296 </cell>
20297 </row>
20298 <row topline="true">
20299 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20300 \begin_inset Text
20301
20302 \begin_layout Standard
20303 long (32 bit) support
20304 \end_layout
20305
20306 \end_inset
20307 </cell>
20308 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20309 \begin_inset Text
20310
20311 \begin_layout Standard
20312 x
20313 \end_layout
20314
20315 \end_inset
20316 </cell>
20317 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20318 \begin_inset Text
20319
20320 \begin_layout Standard
20321 x
20322 \end_layout
20323
20324 \end_inset
20325 </cell>
20326 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20327 \begin_inset Text
20328
20329 \begin_layout Standard
20330 x
20331 \end_layout
20332
20333 \end_inset
20334 </cell>
20335 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20336 \begin_inset Text
20337
20338 \begin_layout Standard
20339 x
20340 \end_layout
20341
20342 \end_inset
20343 </cell>
20344 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20345 \begin_inset Text
20346
20347 \begin_layout Standard
20348
20349 \family roman
20350 \series medium
20351 \shape up
20352 \size normal
20353 \emph off
20354 \bar no
20355 \noun off
20356 \color none
20357 x
20358 \end_layout
20359
20360 \end_inset
20361 </cell>
20362 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20363 \begin_inset Text
20364
20365 \begin_layout Standard
20366 -
20367 \end_layout
20368
20369 \end_inset
20370 </cell>
20371 </row>
20372 <row topline="true">
20373 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20374 \begin_inset Text
20375
20376 \begin_layout Standard
20377 byte arguments on stack
20378 \end_layout
20379
20380 \end_inset
20381 </cell>
20382 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20383 \begin_inset Text
20384
20385 \begin_layout Standard
20386 b
20387 \end_layout
20388
20389 \end_inset
20390 </cell>
20391 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20392 \begin_inset Text
20393
20394 \begin_layout Standard
20395 b
20396 \end_layout
20397
20398 \end_inset
20399 </cell>
20400 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20401 \begin_inset Text
20402
20403 \begin_layout Standard
20404 -
20405 \end_layout
20406
20407 \end_inset
20408 </cell>
20409 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20410 \begin_inset Text
20411
20412 \begin_layout Standard
20413 -
20414 \end_layout
20415
20416 \end_inset
20417 </cell>
20418 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20419 \begin_inset Text
20420
20421 \begin_layout Standard
20422 -
20423 \end_layout
20424
20425 \end_inset
20426 </cell>
20427 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20428 \begin_inset Text
20429
20430 \begin_layout Standard
20431 -
20432 \end_layout
20433
20434 \end_inset
20435 </cell>
20436 </row>
20437 <row topline="true">
20438 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20439 \begin_inset Text
20440
20441 \begin_layout Standard
20442 float format
20443 \begin_inset LatexCommand \index{Floating point support}
20444
20445 \end_inset
20446
20447
20448 \end_layout
20449
20450 \end_inset
20451 </cell>
20452 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20453 \begin_inset Text
20454
20455 \begin_layout Standard
20456 -
20457 \end_layout
20458
20459 \end_inset
20460 </cell>
20461 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20462 \begin_inset Text
20463
20464 \begin_layout Standard
20465 %f
20466 \end_layout
20467
20468 \end_inset
20469 </cell>
20470 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20471 \begin_inset Text
20472
20473 \begin_layout Standard
20474 -
20475 \end_layout
20476
20477 \end_inset
20478 </cell>
20479 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20480 \begin_inset Text
20481
20482 \begin_layout Standard
20483 -
20484 \end_layout
20485
20486 \end_inset
20487 </cell>
20488 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20489 \begin_inset Text
20490
20491 \begin_layout Standard
20492 %f
20493 \begin_inset Foot
20494 status collapsed
20495
20496 \begin_layout Standard
20497 Range limited to +/- 4294967040, precision limited to 8 digits past decimal
20498 \end_layout
20499
20500 \end_inset
20501
20502
20503 \end_layout
20504
20505 \end_inset
20506 </cell>
20507 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20508 \begin_inset Text
20509
20510 \begin_layout Standard
20511 -
20512 \end_layout
20513
20514 \end_inset
20515 </cell>
20516 </row>
20517 <row topline="true">
20518 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20519 \begin_inset Text
20520
20521 \begin_layout Standard
20522 float formats %e %g
20523 \end_layout
20524
20525 \end_inset
20526 </cell>
20527 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20528 \begin_inset Text
20529
20530 \begin_layout Standard
20531 -
20532 \end_layout
20533
20534 \end_inset
20535 </cell>
20536 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20537 \begin_inset Text
20538
20539 \begin_layout Standard
20540 -
20541 \end_layout
20542
20543 \end_inset
20544 </cell>
20545 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20546 \begin_inset Text
20547
20548 \begin_layout Standard
20549 -
20550 \end_layout
20551
20552 \end_inset
20553 </cell>
20554 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20555 \begin_inset Text
20556
20557 \begin_layout Standard
20558 -
20559 \end_layout
20560
20561 \end_inset
20562 </cell>
20563 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20564 \begin_inset Text
20565
20566 \begin_layout Standard
20567 -
20568 \end_layout
20569
20570 \end_inset
20571 </cell>
20572 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20573 \begin_inset Text
20574
20575 \begin_layout Standard
20576 -
20577 \end_layout
20578
20579 \end_inset
20580 </cell>
20581 </row>
20582 <row topline="true" bottomline="true">
20583 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20584 \begin_inset Text
20585
20586 \begin_layout Standard
20587 field width
20588 \end_layout
20589
20590 \end_inset
20591 </cell>
20592 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20593 \begin_inset Text
20594
20595 \begin_layout Standard
20596 x
20597 \end_layout
20598
20599 \end_inset
20600 </cell>
20601 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20602 \begin_inset Text
20603
20604 \begin_layout Standard
20605 x
20606 \end_layout
20607
20608 \end_inset
20609 </cell>
20610 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20611 \begin_inset Text
20612
20613 \begin_layout Standard
20614 -
20615 \end_layout
20616
20617 \end_inset
20618 </cell>
20619 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20620 \begin_inset Text
20621
20622 \begin_layout Standard
20623 x
20624 \end_layout
20625
20626 \end_inset
20627 </cell>
20628 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20629 \begin_inset Text
20630
20631 \begin_layout Standard
20632 x
20633 \end_layout
20634
20635 \end_inset
20636 </cell>
20637 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20638 \begin_inset Text
20639
20640 \begin_layout Standard
20641 -
20642 \end_layout
20643
20644 \end_inset
20645 </cell>
20646 </row>
20647 <row bottomline="true">
20648 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20649 \begin_inset Text
20650
20651 \begin_layout Standard
20652 string speed
20653 \begin_inset Foot
20654 status collapsed
20655
20656 \begin_layout Standard
20657 Execution time of printf("%s%c%s%c%c%c", "Hello", ' ', "World", '!', '
20658 \backslash
20659 r', '
20660 \backslash
20661 n'); standard 8051 @ 22.1184 MHz, empty putchar()
20662 \end_layout
20663
20664 \end_inset
20665
20666 ,
20667 \end_layout
20668
20669 \begin_layout Standard
20670 small / large
20671 \end_layout
20672
20673 \end_inset
20674 </cell>
20675 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20676 \begin_inset Text
20677
20678 \begin_layout Standard
20679 1.52 / 2.59 ms
20680 \end_layout
20681
20682 \end_inset
20683 </cell>
20684 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20685 \begin_inset Text
20686
20687 \begin_layout Standard
20688 1.53 / 2.62 ms
20689 \end_layout
20690
20691 \end_inset
20692 </cell>
20693 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20694 \begin_inset Text
20695
20696 \begin_layout Standard
20697 0.92 / 0.93 ms
20698 \end_layout
20699
20700 \end_inset
20701 </cell>
20702 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20703 \begin_inset Text
20704
20705 \begin_layout Standard
20706 0.45 / 0.45 ms
20707 \end_layout
20708
20709 \end_inset
20710 </cell>
20711 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20712 \begin_inset Text
20713
20714 \begin_layout Standard
20715 0.46 / 0.46 ms
20716 \end_layout
20717
20718 \end_inset
20719 </cell>
20720 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20721 \begin_inset Text
20722
20723 \begin_layout Standard
20724 0.45 / 0.45 ms
20725 \end_layout
20726
20727 \end_inset
20728 </cell>
20729 </row>
20730 <row bottomline="true">
20731 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20732 \begin_inset Text
20733
20734 \begin_layout Standard
20735 int speed
20736 \begin_inset Foot
20737 status collapsed
20738
20739 \begin_layout Standard
20740 Execution time of printf("%d", -12345); standard 8051 @ 22.1184 MHz, empty
20741  putchar()
20742 \end_layout
20743
20744 \end_inset
20745
20746 ,
20747 \end_layout
20748
20749 \begin_layout Standard
20750 small / large
20751 \end_layout
20752
20753 \end_inset
20754 </cell>
20755 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20756 \begin_inset Text
20757
20758 \begin_layout Standard
20759 3.01 / 3.61 ms
20760 \end_layout
20761
20762 \end_inset
20763 </cell>
20764 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20765 \begin_inset Text
20766
20767 \begin_layout Standard
20768 3.01 / 3.61 ms
20769 \end_layout
20770
20771 \end_inset
20772 </cell>
20773 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20774 \begin_inset Text
20775
20776 \begin_layout Standard
20777 3.51 / 18.13 ms
20778 \end_layout
20779
20780 \end_inset
20781 </cell>
20782 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20783 \begin_inset Text
20784
20785 \begin_layout Standard
20786 0.22 / 0.22 ms
20787 \end_layout
20788
20789 \end_inset
20790 </cell>
20791 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20792 \begin_inset Text
20793
20794 \begin_layout Standard
20795 0.23 / 0.23 ms
20796 \end_layout
20797
20798 \end_inset
20799 </cell>
20800 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20801 \begin_inset Text
20802
20803 \begin_layout Standard
20804 0.25 / 0.25 ms
20805 \begin_inset Foot
20806 status collapsed
20807
20808 \begin_layout Standard
20809 printf_tiny integer speed is data dependent, worst case is 0.33 ms
20810 \end_layout
20811
20812 \end_inset
20813
20814
20815 \end_layout
20816
20817 \end_inset
20818 </cell>
20819 </row>
20820 <row bottomline="true">
20821 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20822 \begin_inset Text
20823
20824 \begin_layout Standard
20825 long speed
20826 \begin_inset Foot
20827 status collapsed
20828
20829 \begin_layout Standard
20830 Execution time of printf("%ld", -123456789); standard 8051 @ 22.1184 MHz,
20831  empty putchar()
20832 \end_layout
20833
20834 \end_inset
20835
20836 ,
20837 \end_layout
20838
20839 \begin_layout Standard
20840 small / large
20841 \end_layout
20842
20843 \end_inset
20844 </cell>
20845 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20846 \begin_inset Text
20847
20848 \begin_layout Standard
20849 5.37 / 6.31 ms
20850 \end_layout
20851
20852 \end_inset
20853 </cell>
20854 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20855 \begin_inset Text
20856
20857 \begin_layout Standard
20858 5.37 / 6.31 ms
20859 \end_layout
20860
20861 \end_inset
20862 </cell>
20863 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20864 \begin_inset Text
20865
20866 \begin_layout Standard
20867 8.71 / 40.65 ms
20868 \end_layout
20869
20870 \end_inset
20871 </cell>
20872 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20873 \begin_inset Text
20874
20875 \begin_layout Standard
20876 0.40 / 0.40 ms
20877 \end_layout
20878
20879 \end_inset
20880 </cell>
20881 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20882 \begin_inset Text
20883
20884 \begin_layout Standard
20885 0.40 / 0.40 ms
20886 \end_layout
20887
20888 \end_inset
20889 </cell>
20890 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20891 \begin_inset Text
20892
20893 \begin_layout Standard
20894 -
20895 \end_layout
20896
20897 \end_inset
20898 </cell>
20899 </row>
20900 <row bottomline="true">
20901 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20902 \begin_inset Text
20903
20904 \begin_layout Standard
20905 float speed
20906 \begin_inset Foot
20907 status collapsed
20908
20909 \begin_layout Standard
20910 Execution time of printf("%.3f", -12345.678); standard 8051 @ 22.1184 MHz,
20911  empty putchar()
20912 \end_layout
20913
20914 \end_inset
20915
20916 ,
20917 \end_layout
20918
20919 \begin_layout Standard
20920 small / large
20921 \end_layout
20922
20923 \end_inset
20924 </cell>
20925 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20926 \begin_inset Text
20927
20928 \begin_layout Standard
20929 -
20930 \end_layout
20931
20932 \end_inset
20933 </cell>
20934 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20935 \begin_inset Text
20936
20937 \begin_layout Standard
20938 7.49 / 22.47 ms
20939 \end_layout
20940
20941 \end_inset
20942 </cell>
20943 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20944 \begin_inset Text
20945
20946 \begin_layout Standard
20947 -
20948 \end_layout
20949
20950 \end_inset
20951 </cell>
20952 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20953 \begin_inset Text
20954
20955 \begin_layout Standard
20956 -
20957 \end_layout
20958
20959 \end_inset
20960 </cell>
20961 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20962 \begin_inset Text
20963
20964 \begin_layout Standard
20965 1.04 / 1.04 ms
20966 \end_layout
20967
20968 \end_inset
20969 </cell>
20970 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20971 \begin_inset Text
20972
20973 \begin_layout Standard
20974 -
20975 \end_layout
20976
20977 \end_inset
20978 </cell>
20979 </row>
20980 </lyxtabular>
20981
20982 \end_inset
20983
20984
20985 \end_layout
20986
20987 \begin_layout Subsubsection
20988 <malloc.h>
20989 \begin_inset LatexCommand \index{malloc.h}
20990
20991 \end_inset
20992
20993
20994 \end_layout
20995
20996 \begin_layout Standard
20997 As of SDCC 2.6.2 you no longer need to call an initialization routine before
20998  using dynamic memory allocation
20999 \begin_inset LatexCommand \index{dynamic memory allocation (malloc)}
21000
21001 \end_inset
21002
21003  and a default heap
21004 \begin_inset LatexCommand \index{heap (malloc)}
21005
21006 \end_inset
21007
21008  space of 1024 bytes is provided for malloc to allocate memory from.
21009  If you need a different heap size you need to recompile _heap.c with the
21010  required size defined in HEAP_SIZE.
21011  It is recommended to make a copy of this file into your project directory
21012  and compile it there with:
21013 \end_layout
21014
21015 \begin_layout Verse
21016
21017 \family typewriter
21018 sdcc -c _heap.c -D HEAD_SIZE=2048
21019 \end_layout
21020
21021 \begin_layout Standard
21022 And then link it with:
21023 \end_layout
21024
21025 \begin_layout Verse
21026
21027 \family typewriter
21028 sdcc main.rel _heap.rel
21029 \end_layout
21030
21031 \begin_layout Subsection
21032 Math functions (sinf, powf, sqrtf etc.)
21033 \end_layout
21034
21035 \begin_layout Subsubsection
21036 <math.h>
21037 \end_layout
21038
21039 \begin_layout Standard
21040 See definitions in file <math.h>.
21041 \end_layout
21042
21043 \begin_layout Subsection
21044 Other libraries
21045 \end_layout
21046
21047 \begin_layout Standard
21048 Libraries
21049 \begin_inset LatexCommand \index{Libraries}
21050
21051 \end_inset
21052
21053  included in SDCC should have a license at least as liberal as the GNU Lesser
21054  General Public License
21055 \begin_inset LatexCommand \index{GNU Lesser General Public License, LGPL}
21056
21057 \end_inset
21058
21059
21060 \emph on
21061 LGPL
21062 \emph default
21063 .
21064 \end_layout
21065
21066 \begin_layout Standard
21067 \begin_inset Note Note
21068 status collapsed
21069
21070 \begin_layout Standard
21071 license statements for the libraries are missing.
21072  sdcc/device/lib/ser_ir.c
21073 \end_layout
21074
21075 \begin_layout Standard
21076 or _decdptr f.e.
21077  come with a GPL (as opposed to LGPL) License - this will not be liberal
21078  enough for many embedded programmers.
21079 \end_layout
21080
21081 \end_inset
21082
21083
21084 \end_layout
21085
21086 \begin_layout Standard
21087 If you have ported some library or want to share experience about some code
21088  which f.e.
21089  falls into any of these categories Busses (I
21090 \begin_inset Formula $^{\textrm{2}}$
21091 \end_inset
21092
21093 C, CAN, Ethernet, Profibus, Modbus, USB, SPI, JTAG ...), Media (IDE, Memory
21094  cards, eeprom, flash...), En-/Decryption, Remote debugging, Realtime kernel,
21095  Keyboard, LCD, RTC, FPGA, PID then the sdcc-user mailing list
21096 \begin_inset LatexCommand \url{http://sourceforge.net/mail/?group_id=599}
21097
21098 \end_inset
21099
21100 \InsetSpace ~
21101 would certainly like to hear about it.
21102 \end_layout
21103
21104 \begin_layout Standard
21105 Programmers coding for embedded systems are not especially famous for being
21106  enthusiastic, so don't expect a big hurray but as the mailing list is searchabl
21107 e these references are very valuable.
21108  Let's help to create a climate where information is shared.
21109 \begin_inset VSpace bigskip
21110 \end_inset
21111
21112
21113 \end_layout
21114
21115 \begin_layout Section
21116 Memory Models
21117 \end_layout
21118
21119 \begin_layout Subsection
21120 MCS51 Memory Models
21121 \begin_inset LatexCommand \index{Memory model}
21122
21123 \end_inset
21124
21125
21126 \begin_inset LatexCommand \index{MCS51 memory model}
21127
21128 \end_inset
21129
21130
21131 \end_layout
21132
21133 \begin_layout Subsubsection
21134 Small, Medium and Large
21135 \end_layout
21136
21137 \begin_layout Standard
21138 SDCC allows three memory models for MCS51 code,
21139 \shape slanted
21140 small, medium
21141 \shape default
21142  and
21143 \shape slanted
21144 large
21145 \shape default
21146 .
21147  Modules compiled with different memory models should
21148 \emph on
21149 never
21150 \emph default
21151  be combined together or the results would be unpredictable.
21152  The library routines supplied with the compiler are compiled as small,
21153  medium and large.
21154  The compiled library modules are contained in separate directories as small,
21155  medium and large so that you can link to the appropriate set.
21156 \end_layout
21157
21158 \begin_layout Standard
21159 When the medium or large model is used all variables declared without a
21160  storage class will be allocated into the external ram, this includes all
21161  parameters and local variables (for non-reentrant
21162 \begin_inset LatexCommand \index{reentrant}
21163
21164 \end_inset
21165
21166  functions).
21167  When the small model is used variables without storage class are allocated
21168  in the internal ram.
21169 \end_layout
21170
21171 \begin_layout Standard
21172 Judicious usage of the processor specific storage classes
21173 \begin_inset LatexCommand \index{Storage class}
21174
21175 \end_inset
21176
21177  and the 'reentrant' function type will yield much more efficient code,
21178  than using the large model.
21179  Several optimizations are disabled when the program is compiled using the
21180  large model, it is therefore recommended that the small model be used unless
21181  absolutely required.
21182 \end_layout
21183
21184 \begin_layout Subsubsection
21185 External Stack
21186 \begin_inset LatexCommand \label{sub:External-Stack}
21187
21188 \end_inset
21189
21190
21191 \begin_inset LatexCommand \index{stack}
21192
21193 \end_inset
21194
21195
21196 \begin_inset LatexCommand \index{External stack (mcs51)}
21197
21198 \end_inset
21199
21200
21201 \end_layout
21202
21203 \begin_layout Standard
21204 The external stack (-
21205 \begin_inset ERT
21206 status collapsed
21207
21208 \begin_layout Standard
21209
21210
21211 \backslash
21212 /
21213 \end_layout
21214
21215 \end_inset
21216
21217 -xstack option
21218 \begin_inset LatexCommand \index{-\/-xstack}
21219
21220 \end_inset
21221
21222 ) is located in pdata
21223 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
21224
21225 \end_inset
21226
21227  memory (usually at the start of the external ram segment) and uses all
21228  unused space in pdata (max.
21229  256 bytes).
21230  When -
21231 \begin_inset ERT
21232 status collapsed
21233
21234 \begin_layout Standard
21235
21236
21237 \backslash
21238 /
21239 \end_layout
21240
21241 \end_inset
21242
21243 -xstack option is used to compile the program, the parameters and local
21244  variables
21245 \begin_inset LatexCommand \index{local variables}
21246
21247 \end_inset
21248
21249  of all reentrant functions are allocated in this area.
21250  This option is provided for programs with large stack space requirements.
21251  When used with the -
21252 \begin_inset ERT
21253 status collapsed
21254
21255 \begin_layout Standard
21256
21257
21258 \backslash
21259 /
21260 \end_layout
21261
21262 \end_inset
21263
21264 -stack-auto
21265 \begin_inset LatexCommand \index{-\/-stack-auto}
21266
21267 \end_inset
21268
21269  option, all parameters and local variables are allocated on the external
21270  stack (note: support libraries will need to be recompiled with the same
21271  options.
21272  There is a predefined target in the library makefile).
21273 \end_layout
21274
21275 \begin_layout Standard
21276 The compiler outputs the higher order address byte of the external ram segment
21277  into port P2
21278 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
21279
21280 \end_inset
21281
21282  (see also section
21283 \begin_inset LatexCommand \ref{sub:MCS51-variants}
21284
21285 \end_inset
21286
21287 ), therefore when using the External Stack option, this port
21288 \emph on
21289 may not
21290 \emph default
21291  be used by the application program.
21292 \end_layout
21293
21294 \begin_layout Subsection
21295 DS390 Memory Model
21296 \begin_inset LatexCommand \index{Memory model}
21297
21298 \end_inset
21299
21300
21301 \begin_inset LatexCommand \index{DS390 memory model}
21302
21303 \end_inset
21304
21305
21306 \end_layout
21307
21308 \begin_layout Standard
21309 The only model supported is Flat 24
21310 \begin_inset LatexCommand \index{Flat 24 (DS390 memory model)}
21311
21312 \end_inset
21313
21314 .
21315  This generates code for the 24 bit contiguous addressing mode of the Dallas
21316  DS80C390 part.
21317  In this mode, up to four meg of external RAM or code space can be directly
21318  addressed.
21319  See the data sheets at www.dalsemi.com for further information on this part.
21320 \newline
21321
21322 \newline
21323 Note
21324  that the compiler does not generate any code to place the processor into
21325  24 bitmode (although
21326 \emph on
21327 tinibios
21328 \emph default
21329  in the ds390 libraries will do that for you).
21330  If you don't use
21331 \emph on
21332 tinibios
21333 \emph default
21334
21335 \begin_inset LatexCommand \index{Tinibios (DS390)}
21336
21337 \end_inset
21338
21339 , the boot loader or similar code must ensure that the processor is in 24
21340  bit contiguous addressing mode before calling the SDCC startup code.
21341 \newline
21342
21343 \newline
21344 Like
21345  the
21346 \emph on
21347 -
21348 \begin_inset ERT
21349 status collapsed
21350
21351 \begin_layout Standard
21352
21353
21354 \backslash
21355 /
21356 \end_layout
21357
21358 \end_inset
21359
21360 -model-large
21361 \emph default
21362  option, variables will by default be placed into the XDATA segment.
21363 \newline
21364
21365 \newline
21366 Segments
21367  may be placed anywhere in the 4 meg address space using the usual -
21368 \begin_inset ERT
21369 status collapsed
21370
21371 \begin_layout Standard
21372
21373
21374 \backslash
21375 /
21376 \end_layout
21377
21378 \end_inset
21379
21380 -*-loc options.
21381  Note that if any segments are located above 64K, the -r flag must be passed
21382  to the linker to generate the proper segment relocations, and the Intel
21383  HEX output format must be used.
21384  The -r flag can be passed to the linker by using the option
21385 \emph on
21386 -Wl-r
21387 \emph default
21388  on the SDCC command line.
21389  However, currently the linker can not handle code segments > 64k.
21390 \end_layout
21391
21392 \begin_layout Section
21393 Pragmas
21394 \begin_inset LatexCommand \label{sec:Pragmas}
21395
21396 \end_inset
21397
21398
21399 \begin_inset LatexCommand \index{Pragmas}
21400
21401 \end_inset
21402
21403
21404 \end_layout
21405
21406 \begin_layout Standard
21407 Pragmas are used to turn on and/or off certain compiler options.
21408  Some of them are closely related to corresponding command-line options
21409  (see section
21410 \begin_inset LatexCommand \vref{sec:Command-Line-Options}
21411
21412 \end_inset
21413
21414 ).
21415 \newline
21416 Pragmas should be placed before and/or after a function, placing pragmas
21417  inside a function body could have unpredictable results.
21418 \newline
21419
21420 \newline
21421 SDCC supports the
21422  following #pragma directives:
21423 \end_layout
21424
21425 \begin_layout Itemize
21426
21427 \series bold
21428 save
21429 \series default
21430
21431 \begin_inset LatexCommand \index{\#pragma save}
21432
21433 \end_inset
21434
21435  - this will save most current options to the save/restore stack.
21436  See #pragma\InsetSpace ~
21437 restore.
21438 \end_layout
21439
21440 \begin_layout Itemize
21441
21442 \series bold
21443 restore
21444 \series default
21445
21446 \begin_inset LatexCommand \index{\#pragma restore}
21447
21448 \end_inset
21449
21450  - will restore saved options from the last save.
21451  saves & restores can be nested.
21452  SDCC uses a save/restore stack: save pushes current options to the stack,
21453  restore pulls current options from the stack.
21454  See #pragma\InsetSpace ~
21455 save.
21456 \newline
21457
21458 \end_layout
21459
21460 \begin_layout Itemize
21461
21462 \series bold
21463 callee_saves
21464 \series default
21465
21466 \begin_inset LatexCommand \index{\#pragma callee\_saves}
21467
21468 \end_inset
21469
21470
21471 \begin_inset LatexCommand \index{function prologue}
21472
21473 \end_inset
21474
21475  function1[,function2[,function3...]]
21476 \begin_inset LatexCommand \label{ite:callee_saves-function1[,function2[,function3...]]--}
21477
21478 \end_inset
21479
21480 - The compiler by default uses a caller saves convention for register saving
21481  across function calls, however this can cause unnecessary register pushing
21482  and popping
21483 \begin_inset LatexCommand \index{push/pop}
21484
21485 \end_inset
21486
21487  when calling small functions from larger functions.
21488  This option can be used to switch off the register saving convention for
21489  the function names specified.
21490  The compiler will not save registers when calling these functions, extra
21491  code need to be manually inserted at the entry and exit for these functions
21492  to save and restore the registers used by these functions, this can SUBSTANTIAL
21493 LY reduce code and improve run time performance of the generated code.
21494  In the future the compiler (with inter procedural analysis) may be able
21495  to determine the appropriate scheme to use for each function call.
21496  If -
21497 \begin_inset ERT
21498 status collapsed
21499
21500 \begin_layout Standard
21501
21502
21503 \backslash
21504 /
21505 \end_layout
21506
21507 \end_inset
21508
21509 -callee-saves command line option is used (see page
21510 \begin_inset LatexCommand \vpageref{lyx:--callee-saves-function1[,function2][,function3]...}
21511
21512 \end_inset
21513
21514 ), the function names specified in #pragma\InsetSpace ~
21515 callee_saves
21516 \begin_inset LatexCommand \index{\#pragma callee\_saves}
21517
21518 \end_inset
21519
21520  is appended to the list of functions specified in the command line.
21521 \end_layout
21522
21523 \begin_layout Itemize
21524
21525 \series bold
21526 exclude
21527 \series default
21528
21529 \begin_inset LatexCommand \index{\#pragma exclude}
21530
21531 \end_inset
21532
21533  none | {acc[,b[,dpl[,dph]]] - The exclude pragma disables the generation
21534  of pairs of push/pop
21535 \begin_inset LatexCommand \index{push/pop}
21536
21537 \end_inset
21538
21539  instructions in
21540 \emph on
21541 I
21542 \emph default
21543 nterrupt
21544 \begin_inset LatexCommand \index{interrupt}
21545
21546 \end_inset
21547
21548
21549 \emph on
21550 S
21551 \emph default
21552 ervice
21553 \emph on
21554 R
21555 \emph default
21556 outines.
21557  The directive should be placed immediately before the ISR function definition
21558  and it affects ALL ISR functions following it.
21559  To enable the normal register saving for ISR functions use #pragma\InsetSpace ~
21560 exclude\InsetSpace ~
21561 none
21562 \begin_inset LatexCommand \index{\#pragma exclude}
21563
21564 \end_inset
21565
21566 .
21567  See also the related keyword _naked
21568 \begin_inset LatexCommand \index{\_naked}
21569
21570 \end_inset
21571
21572
21573 \begin_inset LatexCommand \index{\_\_naked}
21574
21575 \end_inset
21576
21577 .
21578 \end_layout
21579
21580 \begin_layout Itemize
21581
21582 \series bold
21583 less_pedantic
21584 \series default
21585
21586 \begin_inset LatexCommand \index{pedantic}
21587
21588 \end_inset
21589
21590
21591 \begin_inset LatexCommand \index{\#pragma less\_pedantic}
21592
21593 \end_inset
21594
21595
21596 \begin_inset LatexCommand \label{ite:less_pedantic}
21597
21598 \end_inset
21599
21600 - the compiler will not warn you anymore for obvious mistakes, you're on
21601  your own now ;-( .
21602  See also the command line option -
21603 \begin_inset ERT
21604 status collapsed
21605
21606 \begin_layout Standard
21607
21608
21609 \backslash
21610 /
21611 \end_layout
21612
21613 \end_inset
21614
21615 -less-pedantic
21616 \begin_inset LatexCommand \vpageref{lyx:--less-pedantic}
21617
21618 \end_inset
21619
21620 .
21621 \newline
21622 More specifically, the following warnings will be disabled:
21623 \shape italic
21624 comparison is always [true/false] due to limited range of data type
21625 \shape default
21626  (94);
21627 \shape italic
21628 overflow in implicit constant conversion
21629 \shape default
21630  (158); [the (in)famous]
21631 \shape italic
21632 conditional flow changed by optimizer: so said EVELYN the modified DOG
21633 \shape default
21634  (110);
21635 \shape italic
21636 function '[function name]' must return value
21637 \shape default
21638  (59).
21639 \newline
21640 Furthermore, warnings of less importance (of PEDANTIC and INFO warning
21641  level) are disabled, too, namely:
21642 \shape italic
21643 constant value '[
21644 \begin_inset Note Note
21645 status collapsed
21646
21647 \begin_layout Standard
21648 dunno what comes here - this warning appears to be unused altogether
21649 \end_layout
21650
21651 \end_inset
21652
21653 ]', out of range
21654 \shape default
21655  (81);
21656 \shape italic
21657 [left/right] shifting more than size of object changed to zero
21658 \shape default
21659  (116);
21660 \shape italic
21661 unreachable code
21662 \shape default
21663  (126);
21664 \shape italic
21665 integer overflow in expression
21666 \shape default
21667  (165);
21668 \shape italic
21669 unmatched #pragma save and #pragma restore
21670 \shape default
21671  (170);
21672 \shape italic
21673 comparison of 'signed char' with 'unsigned char' requires promotion to int
21674 \shape default
21675  (185);
21676 \shape italic
21677 ISO C90 does not support flexible array members
21678 \shape default
21679  (187);
21680 \shape italic
21681 extended stack by [number] bytes for compiler temp(s) :in function '[function\InsetSpace ~
21682 nam
21683 e]':\InsetSpace ~
21684 [
21685 \begin_inset Note Note
21686 status collapsed
21687
21688 \begin_layout Standard
21689 appears to be always blank - what was supposed to be here?
21690 \end_layout
21691
21692 \end_inset
21693
21694 ]
21695 \shape default
21696  (114);
21697 \shape italic
21698 function '[function name]', # edges [number] , # nodes [number] , cyclomatic
21699  complexity [number]
21700 \shape default
21701  (121).
21702 \end_layout
21703
21704 \begin_layout Itemize
21705
21706 \series bold
21707 disable_warning
21708 \series default
21709  <nnnn>
21710 \begin_inset LatexCommand \index{\#pragma disable\_warning}
21711
21712 \end_inset
21713
21714  - the compiler will not warn you anymore about warning number <nnnn>.
21715 \end_layout
21716
21717 \begin_layout Itemize
21718
21719 \series bold
21720 nogcse
21721 \series default
21722
21723 \begin_inset LatexCommand \index{\#pragma nogcse}
21724
21725 \end_inset
21726
21727  - will stop global common subexpression elimination.
21728 \end_layout
21729
21730 \begin_layout Itemize
21731
21732 \series bold
21733 noinduction
21734 \series default
21735
21736 \begin_inset LatexCommand \index{\#pragma noinduction}
21737
21738 \end_inset
21739
21740  - will stop loop induction optimizations.
21741 \end_layout
21742
21743 \begin_layout Itemize
21744
21745 \series bold
21746 noinvariant
21747 \series default
21748
21749 \begin_inset LatexCommand \index{\#pragma noinvariant}
21750
21751 \end_inset
21752
21753  - will not do loop invariant optimizations.
21754  For more details see Loop Invariants in section
21755 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
21756
21757 \end_inset
21758
21759 .
21760 \end_layout
21761
21762 \begin_layout Itemize
21763
21764 \series bold
21765 noiv
21766 \series default
21767
21768 \begin_inset LatexCommand \index{\#pragma noiv}
21769
21770 \end_inset
21771
21772  - Do not generate interrupt
21773 \begin_inset LatexCommand \index{interrupt}
21774
21775 \end_inset
21776
21777  vector table
21778 \begin_inset LatexCommand \index{interrupt vector table}
21779
21780 \end_inset
21781
21782  entries for all ISR functions defined after the pragma.
21783  This is useful in cases where the interrupt vector table must be defined
21784  manually, or when there is a secondary, manually defined interrupt vector
21785  table (e.g.
21786  for the autovector feature of the Cypress EZ-USB FX2).
21787  More elegantly this can be achieved by obmitting the optional interrupt
21788  number after the interrupt keyword, see section
21789 \begin_inset LatexCommand \ref{sub:Interrupt-Service-Routines}
21790
21791 \end_inset
21792
21793 \InsetSpace ~
21794 about interrupts.
21795 \end_layout
21796
21797 \begin_layout Itemize
21798
21799 \series bold
21800 nojtbound
21801 \series default
21802
21803 \begin_inset LatexCommand \index{\#pragma nojtbound}
21804
21805 \end_inset
21806
21807  - will not generate code for boundary value checking, when switch statements
21808  are turned into jump-tables (dangerous).
21809  For more details see section
21810 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
21811
21812 \end_inset
21813
21814 .
21815 \end_layout
21816
21817 \begin_layout Itemize
21818
21819 \series bold
21820 noloopreverse
21821 \series default
21822
21823 \begin_inset LatexCommand \index{\#pragma noloopreverse}
21824
21825 \end_inset
21826
21827  - Will not do loop reversal optimization
21828 \end_layout
21829
21830 \begin_layout Itemize
21831
21832 \series bold
21833 nooverlay
21834 \series default
21835
21836 \begin_inset LatexCommand \index{\#pragma nooverlay}
21837
21838 \end_inset
21839
21840  - the compiler will not overlay the parameters and local variables of a
21841  function.
21842 \end_layout
21843
21844 \begin_layout Itemize
21845
21846 \series bold
21847 stackauto
21848 \series default
21849
21850 \begin_inset LatexCommand \index{\#pragma stackauto}
21851
21852 \end_inset
21853
21854 - See option -
21855 \begin_inset ERT
21856 status collapsed
21857
21858 \begin_layout Standard
21859
21860
21861 \backslash
21862 /
21863 \end_layout
21864
21865 \end_inset
21866
21867 -stack-auto
21868 \begin_inset LatexCommand \index{-\/-stack-auto}
21869
21870 \end_inset
21871
21872  and section
21873 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
21874
21875 \end_inset
21876
21877  Parameters and Local Variables.
21878 \end_layout
21879
21880 \begin_layout Itemize
21881
21882 \series bold
21883 opt_code_speed
21884 \series default
21885
21886 \begin_inset LatexCommand \index{\#pragma opt\_code\_speed}
21887
21888 \end_inset
21889
21890 - The compiler will optimize code generation towards fast code, possibly
21891  at the expense of code size.
21892  Currently this has little effect.
21893 \end_layout
21894
21895 \begin_layout Itemize
21896
21897 \series bold
21898 opt_code_size
21899 \series default
21900
21901 \begin_inset LatexCommand \index{\#pragma opt\_code\_size}
21902
21903 \end_inset
21904
21905 - The compiler will optimize code generation towards compact code, possibly
21906  at the expense of code speed.
21907  Currently this has little effect.
21908 \end_layout
21909
21910 \begin_layout Itemize
21911
21912 \series bold
21913 opt_code_balanced
21914 \series default
21915
21916 \begin_inset LatexCommand \index{\#pragma opt\_code\_balanced}
21917
21918 \end_inset
21919
21920 - The compiler will attempt to generate code that is both compact and fast,
21921  as long as meeting one goal is not a detriment to the other (this is the
21922  default).
21923 \end_layout
21924
21925 \begin_layout Itemize
21926
21927 \series bold
21928 std_sdcc89
21929 \series default
21930
21931 \begin_inset LatexCommand \index{\#pragma std\_sdcc89}
21932
21933 \end_inset
21934
21935 - Generally follow the C89 standard, but allow SDCC features that conflict
21936  with the standard (default).
21937 \end_layout
21938
21939 \begin_layout Itemize
21940
21941 \series bold
21942 std_c89
21943 \series default
21944
21945 \begin_inset LatexCommand \index{\#pragma std\_c89}
21946
21947 \end_inset
21948
21949 - Follow the C89 standard and disable SDCC features that conflict with the
21950  standard.
21951 \end_layout
21952
21953 \begin_layout Itemize
21954
21955 \series bold
21956 std_sdcc99
21957 \series default
21958
21959 \begin_inset LatexCommand \index{\#pragma std\_sdcc99}
21960
21961 \end_inset
21962
21963 - Generally follow the C99 standard, but allow SDCC features that conflict
21964  with the standard (incomplete support).
21965 \end_layout
21966
21967 \begin_layout Itemize
21968
21969 \series bold
21970 std_c99
21971 \series default
21972
21973 \begin_inset LatexCommand \index{\#pragma std\_c99}
21974
21975 \end_inset
21976
21977 - Follow the C99 standard and disable SDCC features that conflict with the
21978  standard (incomplete support).
21979 \end_layout
21980
21981 \begin_layout Itemize
21982
21983 \series bold
21984 codeseg
21985 \series default
21986  <name>
21987 \begin_inset LatexCommand \index{\#pragma codeseg}
21988
21989 \end_inset
21990
21991 - Use this name (max.
21992  8 characters) for the code segment.
21993  See option -
21994 \begin_inset ERT
21995 status collapsed
21996
21997 \begin_layout Standard
21998
21999
22000 \backslash
22001 /
22002 \end_layout
22003
22004 \end_inset
22005
22006 -codeseg.
22007 \end_layout
22008
22009 \begin_layout Itemize
22010
22011 \series bold
22012 constseg
22013 \series default
22014  <name>
22015 \begin_inset LatexCommand \index{\#pragma constseg}
22016
22017 \end_inset
22018
22019 - Use this name (max.
22020  8 characters) for the const segment.
22021  See option -
22022 \begin_inset ERT
22023 status collapsed
22024
22025 \begin_layout Standard
22026
22027
22028 \backslash
22029 /
22030 \end_layout
22031
22032 \end_inset
22033
22034 -constseg.
22035 \end_layout
22036
22037 \begin_layout Standard
22038 The preprocessor SDCPP
22039 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
22040
22041 \end_inset
22042
22043  supports the following #pragma directives:
22044 \end_layout
22045
22046 \begin_layout Itemize
22047
22048 \series bold
22049 pedantic_parse_number
22050 \series default
22051
22052 \begin_inset LatexCommand \index{pedantic}
22053
22054 \end_inset
22055
22056
22057 \begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
22058
22059 \end_inset
22060
22061  (+ | -)
22062 \begin_inset LatexCommand \label{ite:pedantic_parse_number}
22063
22064 \end_inset
22065
22066 - Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed
22067  properly and the macro LO_B(3) gets expanded.
22068  Default is off.
22069  See also the -
22070 \begin_inset ERT
22071 status collapsed
22072
22073 \begin_layout Standard
22074
22075
22076 \backslash
22077 /
22078 \end_layout
22079
22080 \end_inset
22081
22082 -pedantic-parse-number command line option
22083 \begin_inset LatexCommand \vpageref{lyx:-pedantic-parse-number}
22084
22085 \end_inset
22086
22087 .
22088 \newline
22089 Below is an example on how to use this pragma.
22090
22091 \emph on
22092  Note: this functionality is not in conformance with standard!
22093 \end_layout
22094
22095 \begin_layout Verse
22096
22097 \family typewriter
22098 #pragma pedantic_parse_number +
22099 \begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
22100
22101 \end_inset
22102
22103
22104 \newline
22105
22106 \newline
22107 #define LO_B(x) ((x) & 0xff)
22108 \newline
22109
22110 \newline
22111 unsigned char foo(void)
22112 \newline
22113 {
22114 \newline
22115 \InsetSpace ~
22116 \InsetSpace ~
22117 \InsetSpace ~
22118 unsigned char c=0xfe-LO_B(3)
22119 ;
22120 \newline
22121
22122 \newline
22123 \InsetSpace ~
22124 \InsetSpace ~
22125 \InsetSpace ~
22126 return c;
22127 \newline
22128 }
22129 \newline
22130
22131 \end_layout
22132
22133 \begin_layout Itemize
22134
22135 \series bold
22136 preproc_asm
22137 \series default
22138
22139 \begin_inset LatexCommand \index{\#pragma preproc\_asm}
22140
22141 \end_inset
22142
22143  (+ | -) - switch _asm _endasm block preprocessing on / off.
22144  Default is on.
22145  You use this prama to define multilines of assembly code.
22146  This will prevent the preprocessor from changing the formating required
22147  by assembly code.
22148  Below is an example on how to use this pragma.
22149 \end_layout
22150
22151 \begin_layout Verse
22152
22153 \family typewriter
22154 #pragma preproc_asm -
22155 \begin_inset LatexCommand \index{\#pragma preproc\_asm}
22156
22157 \end_inset
22158
22159
22160 \newline
22161 #define MYDELAY _asm
22162 \newline
22163 \InsetSpace ~
22164 \InsetSpace ~
22165 \InsetSpace ~
22166 nop ;my assembly comment...
22167 \newline
22168 \InsetSpace ~
22169 \InsetSpace ~
22170 \InsetSpace ~
22171 nop
22172 \newline
22173 \InsetSpace ~
22174 \InsetSpace ~
22175 \InsetSpace ~
22176 nop
22177 \newline
22178 _endasm
22179 \newline
22180 #pragma preproc_asm
22181  +
22182 \newline
22183
22184 \newline
22185 void foo (void)
22186 \newline
22187 {
22188 \newline
22189 \InsetSpace ~
22190 \InsetSpace ~
22191 \InsetSpace ~
22192  ...
22193 \newline
22194 \InsetSpace ~
22195 \InsetSpace ~
22196 \InsetSpace ~
22197  MYDELAY;
22198 \newline
22199 \InsetSpace ~
22200 \InsetSpace ~
22201 \InsetSpace ~
22202  ...
22203 \newline
22204 }
22205 \newline
22206
22207 \end_layout
22208
22209 \begin_layout Itemize
22210
22211 \series bold
22212 sdcc_hash
22213 \series default
22214
22215 \begin_inset LatexCommand \index{\#pragma sdcc\_hash}
22216
22217 \end_inset
22218
22219  (+ | -) - Allow "naked" hash in macro definition, for example:
22220 \newline
22221
22222 \family typewriter
22223 #define DIR_LO(x) #(x & 0xff)
22224 \family default
22225
22226 \newline
22227 Default is off.
22228  Below is an example on how to use this pragma.
22229 \end_layout
22230
22231 \begin_layout Verse
22232
22233 \family typewriter
22234 #pragma preproc_asm +
22235 \newline
22236 #pragma sdcc_hash +
22237 \begin_inset LatexCommand \index{\#pragma sdcc\_hash}
22238
22239 \end_inset
22240
22241
22242 \newline
22243
22244 \newline
22245 #define ROMCALL(x)
22246 \backslash
22247
22248 \newline
22249 \InsetSpace ~
22250 \InsetSpace ~
22251 \InsetSpace ~
22252 mov R6_B3, #(x & 0xff)
22253 \backslash
22254
22255 \newline
22256 \InsetSpace ~
22257 \InsetSpace ~
22258 \InsetSpace ~
22259 mov R7_B3, #((x >> 8) & 0xff)
22260 \backslash
22261
22262 \newline
22263 \InsetSpace ~
22264 \InsetSpace ~
22265 \InsetSpace ~
22266 lcall __romcall
22267 \newline
22268
22269 \newline
22270 ...
22271 \newline
22272 _asm
22273 \newline
22274 ROMCALL(72)
22275 \newline
22276 _endasm;
22277 \newline
22278 ...
22279 \newline
22280
22281 \end_layout
22282
22283 \begin_layout Standard
22284 Some of the pragmas are intended to be used to turn-on or off certain optimizati
22285 ons which might cause the compiler to generate extra stack and/or data space
22286  to store compiler generated temporary variables.
22287  This usually happens in large functions.
22288  Pragma directives should be used as shown in the following example, they
22289  are used to control options and optimizations for a given function.
22290 \end_layout
22291
22292 \begin_layout Verse
22293
22294 \family typewriter
22295 #pragma save
22296 \begin_inset LatexCommand \index{\#pragma save}
22297
22298 \end_inset
22299
22300  \InsetSpace ~
22301 \InsetSpace ~
22302 \InsetSpace ~
22303 \InsetSpace ~
22304 \InsetSpace ~
22305 \InsetSpace ~
22306 \InsetSpace ~
22307 /* save the current settings */
22308 \newline
22309 #pragma nogcse
22310 \begin_inset LatexCommand \index{\#pragma nogcse}
22311
22312 \end_inset
22313
22314  \InsetSpace ~
22315 \InsetSpace ~
22316 \InsetSpace ~
22317 \InsetSpace ~
22318 \InsetSpace ~
22319 /* turnoff global subexpression elimination */
22320 \newline
22321 #pragma noinduction
22322 \begin_inset LatexCommand \index{\#pragma noinduction}
22323
22324 \end_inset
22325
22326  /* turn off induction optimizations */
22327 \newline
22328 int foo ()
22329 \newline
22330 {
22331 \newline
22332 \InsetSpace ~
22333  \InsetSpace ~
22334  ...
22335 \newline
22336 \InsetSpace ~
22337  \InsetSpace ~
22338  /* large code */
22339 \newline
22340 \InsetSpace ~
22341  \InsetSpace ~
22342
22343  ...
22344 \newline
22345 }
22346 \newline
22347 #pragma restore
22348 \begin_inset LatexCommand \index{\#pragma restore}
22349
22350 \end_inset
22351
22352  /* turn the optimizations back on */
22353 \end_layout
22354
22355 \begin_layout Standard
22356 The compiler will generate a warning message when extra space is allocated.
22357  It is strongly recommended that the save and restore pragmas be used when
22358  changing options for a function.
22359 \newline
22360
22361 \newline
22362
22363 \newline
22364
22365 \end_layout
22366
22367 \begin_layout Section
22368 Defines Created by the Compiler
22369 \end_layout
22370
22371 \begin_layout Standard
22372 The compiler creates the following #defines
22373 \begin_inset LatexCommand \index{\#defines}
22374
22375 \end_inset
22376
22377
22378 \begin_inset LatexCommand \index{Defines created by the compiler}
22379
22380 \end_inset
22381
22382 :
22383 \newline
22384
22385 \end_layout
22386
22387 \begin_layout Standard
22388 \begin_inset Tabular
22389 <lyxtabular version="3" rows="11" columns="2">
22390 <features>
22391 <column alignment="left" valignment="top" leftline="true" width="3in">
22392 <column alignment="left" valignment="top" leftline="true" rightline="true" width="3in">
22393 <row topline="true" bottomline="true">
22394 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22395 \begin_inset Text
22396
22397 \begin_layout Standard
22398
22399 \series bold
22400 #define
22401 \end_layout
22402
22403 \end_inset
22404 </cell>
22405 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22406 \begin_inset Text
22407
22408 \begin_layout Standard
22409
22410 \series bold
22411 Description
22412 \end_layout
22413
22414 \end_inset
22415 </cell>
22416 </row>
22417 <row topline="true">
22418 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22419 \begin_inset Text
22420
22421 \begin_layout Standard
22422 SDCC
22423 \begin_inset LatexCommand \index{SDCC}
22424
22425 \end_inset
22426
22427
22428 \end_layout
22429
22430 \end_inset
22431 </cell>
22432 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22433 \begin_inset Text
22434
22435 \begin_layout Standard
22436 Always defined.
22437  Since version 2.5.6 the version number as an int (ex.
22438  256)
22439 \end_layout
22440
22441 \end_inset
22442 </cell>
22443 </row>
22444 <row topline="true">
22445 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22446 \begin_inset Text
22447
22448 \begin_layout Standard
22449 SDCC_mcs51
22450 \begin_inset LatexCommand \index{SDCC\_mcs51}
22451
22452 \end_inset
22453
22454  or SDCC_ds390
22455 \begin_inset LatexCommand \index{SDCC\_ds390}
22456
22457 \end_inset
22458
22459  or SDCC_z80
22460 \begin_inset LatexCommand \index{SDCC\_z80}
22461
22462 \end_inset
22463
22464 , etc.
22465 \end_layout
22466
22467 \end_inset
22468 </cell>
22469 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22470 \begin_inset Text
22471
22472 \begin_layout Standard
22473 depending on the model used (e.g.: -mds390)
22474 \end_layout
22475
22476 \end_inset
22477 </cell>
22478 </row>
22479 <row topline="true">
22480 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22481 \begin_inset Text
22482
22483 \begin_layout Standard
22484 __mcs51
22485 \begin_inset LatexCommand \index{\_\_mcs51}
22486
22487 \end_inset
22488
22489 , __ds390
22490 \begin_inset LatexCommand \index{\_\_ds390}
22491
22492 \end_inset
22493
22494 , __hc08
22495 \begin_inset LatexCommand \index{\_\_hc08}
22496
22497 \end_inset
22498
22499 , __z80
22500 \begin_inset LatexCommand \index{\_\_z80}
22501
22502 \end_inset
22503
22504 , etc
22505 \end_layout
22506
22507 \end_inset
22508 </cell>
22509 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22510 \begin_inset Text
22511
22512 \begin_layout Standard
22513 depending on the model used (e.g.
22514  -mz80)
22515 \end_layout
22516
22517 \end_inset
22518 </cell>
22519 </row>
22520 <row topline="true">
22521 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22522 \begin_inset Text
22523
22524 \begin_layout Standard
22525 SDCC_STACK_AUTO
22526 \begin_inset LatexCommand \index{SDCC\_STACK\_AUTO}
22527
22528 \end_inset
22529
22530
22531 \end_layout
22532
22533 \end_inset
22534 </cell>
22535 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22536 \begin_inset Text
22537
22538 \begin_layout Standard
22539 when
22540 \emph on
22541 -
22542 \begin_inset ERT
22543 status collapsed
22544
22545 \begin_layout Standard
22546
22547
22548 \backslash
22549 /
22550 \end_layout
22551
22552 \end_inset
22553
22554 -stack-auto
22555 \emph default
22556  option is used
22557 \end_layout
22558
22559 \end_inset
22560 </cell>
22561 </row>
22562 <row topline="true">
22563 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22564 \begin_inset Text
22565
22566 \begin_layout Standard
22567 SDCC_MODEL_SMALL
22568 \begin_inset LatexCommand \index{SDCC\_MODEL\_SMALL}
22569
22570 \end_inset
22571
22572
22573 \end_layout
22574
22575 \end_inset
22576 </cell>
22577 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22578 \begin_inset Text
22579
22580 \begin_layout Standard
22581 when
22582 \emph on
22583 -
22584 \begin_inset ERT
22585 status collapsed
22586
22587 \begin_layout Standard
22588
22589
22590 \backslash
22591 /
22592 \end_layout
22593
22594 \end_inset
22595
22596 -model-small
22597 \emph default
22598  is used
22599 \end_layout
22600
22601 \end_inset
22602 </cell>
22603 </row>
22604 <row topline="true">
22605 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22606 \begin_inset Text
22607
22608 \begin_layout Standard
22609 SDCC_MODEL_MEDIUM
22610 \begin_inset LatexCommand \index{SDCC\_MODEL\_MEDIUM}
22611
22612 \end_inset
22613
22614
22615 \end_layout
22616
22617 \end_inset
22618 </cell>
22619 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22620 \begin_inset Text
22621
22622 \begin_layout Standard
22623 when
22624 \emph on
22625 -
22626 \begin_inset ERT
22627 status collapsed
22628
22629 \begin_layout Standard
22630
22631
22632 \backslash
22633 /
22634 \end_layout
22635
22636 \end_inset
22637
22638 -model-medium
22639 \emph default
22640  is used
22641 \end_layout
22642
22643 \end_inset
22644 </cell>
22645 </row>
22646 <row topline="true">
22647 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22648 \begin_inset Text
22649
22650 \begin_layout Standard
22651 SDCC_MODEL_LARGE
22652 \begin_inset LatexCommand \index{SDCC\_MODEL\_LARGE}
22653
22654 \end_inset
22655
22656
22657 \end_layout
22658
22659 \end_inset
22660 </cell>
22661 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22662 \begin_inset Text
22663
22664 \begin_layout Standard
22665 when
22666 \emph on
22667 -
22668 \begin_inset ERT
22669 status collapsed
22670
22671 \begin_layout Standard
22672
22673
22674 \backslash
22675 /
22676 \end_layout
22677
22678 \end_inset
22679
22680 -model-large
22681 \emph default
22682  is used
22683 \end_layout
22684
22685 \end_inset
22686 </cell>
22687 </row>
22688 <row topline="true">
22689 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22690 \begin_inset Text
22691
22692 \begin_layout Standard
22693 SDCC_USE_XSTACK
22694 \begin_inset LatexCommand \index{SDCC\_USE\_XSTACK}
22695
22696 \end_inset
22697
22698
22699 \end_layout
22700
22701 \end_inset
22702 </cell>
22703 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22704 \begin_inset Text
22705
22706 \begin_layout Standard
22707 when
22708 \emph on
22709 -
22710 \begin_inset ERT
22711 status collapsed
22712
22713 \begin_layout Standard
22714
22715
22716 \backslash
22717 /
22718 \end_layout
22719
22720 \end_inset
22721
22722 -xstack
22723 \emph default
22724  option is used
22725 \end_layout
22726
22727 \end_inset
22728 </cell>
22729 </row>
22730 <row topline="true">
22731 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22732 \begin_inset Text
22733
22734 \begin_layout Standard
22735 SDCC_STACK_TENBIT
22736 \begin_inset LatexCommand \index{SDCC\_STACK\_TENBIT}
22737
22738 \end_inset
22739
22740
22741 \end_layout
22742
22743 \end_inset
22744 </cell>
22745 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22746 \begin_inset Text
22747
22748 \begin_layout Standard
22749 when
22750 \emph on
22751 -mds390
22752 \emph default
22753  is used
22754 \end_layout
22755
22756 \end_inset
22757 </cell>
22758 </row>
22759 <row topline="true" bottomline="true">
22760 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22761 \begin_inset Text
22762
22763 \begin_layout Standard
22764 SDCC_MODEL_FLAT24
22765 \begin_inset LatexCommand \index{SDCC\_MODEL\_FLAT24}
22766
22767 \end_inset
22768
22769
22770 \end_layout
22771
22772 \end_inset
22773 </cell>
22774 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22775 \begin_inset Text
22776
22777 \begin_layout Standard
22778 when
22779 \emph on
22780 -mds390
22781 \emph default
22782  is used
22783 \end_layout
22784
22785 \end_inset
22786 </cell>
22787 </row>
22788 </lyxtabular>
22789
22790 \end_inset
22791
22792
22793 \end_layout
22794
22795 \begin_layout Chapter
22796 Notes on supported Processors
22797 \end_layout
22798
22799 \begin_layout Section
22800 MCS51 variants
22801 \begin_inset LatexCommand \label{sub:MCS51-variants}
22802
22803 \end_inset
22804
22805
22806 \begin_inset LatexCommand \index{MCS51 variants}
22807
22808 \end_inset
22809
22810
22811 \end_layout
22812
22813 \begin_layout Standard
22814 MCS51 processors are available from many vendors and come in many different
22815  flavours.
22816  While they might differ considerably in respect to Special Function Registers
22817  the core MCS51 is usually not modified or is kept compatible.
22818 \end_layout
22819
22820 \begin_layout Subsection
22821 pdata access by SFR
22822 \end_layout
22823
22824 \begin_layout Standard
22825 With the upcome of devices with internal xdata and flash memory devices
22826  using port P2
22827 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
22828
22829 \end_inset
22830
22831  as dedicated I/O port is becoming more popular.
22832  Switching the high byte for pdata
22833 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
22834
22835 \end_inset
22836
22837  access which was formerly done by port P2 is then achieved by a Special
22838  Function Register
22839 \begin_inset LatexCommand \index{sfr}
22840
22841 \end_inset
22842
22843 .
22844  In well-established MCS51 tradition the address of this
22845 \emph on
22846 sfr
22847 \emph default
22848  is where the chip designers decided to put it.
22849  Needless to say that they didn't agree on a common name either.
22850  So that the startup code can correctly initialize xdata variables, you
22851  should define an sfr with the name _XPAGE
22852 \family typewriter
22853
22854 \begin_inset LatexCommand \index{\_XPAGE (mcs51)}
22855
22856 \end_inset
22857
22858
22859 \family default
22860  at the appropriate location if the default, port P2, is not used for this.
22861  Some examples are:
22862 \end_layout
22863
22864 \begin_layout Verse
22865
22866 \family typewriter
22867 __sfr __at (0x85) _XPAGE; /* Ramtron VRS51 family a.k.a.
22868  MPAGE */
22869 \end_layout
22870
22871 \begin_layout Verse
22872
22873 \family typewriter
22874 __sfr __at (0x92) _XPAGE; /* Cypress EZ-USB family, Texas Instruments (Chipcon)
22875  a.k.a.
22876  MPAGE */
22877 \end_layout
22878
22879 \begin_layout Verse
22880
22881 \family typewriter
22882 __sfr __at (0x91) _XPAGE; /* Infineon (Siemens) C500 family a.k.a.
22883  XPAGE */
22884 \end_layout
22885
22886 \begin_layout Verse
22887
22888 \family typewriter
22889 __sfr __at (0xaf) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
22890  EMI0CN */
22891 \end_layout
22892
22893 \begin_layout Verse
22894
22895 \family typewriter
22896 __sfr __at (0xaa) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
22897  EMI0CN */
22898 \end_layout
22899
22900 \begin_layout Standard
22901 For more exotic implementations further customizations may be needed.
22902  See section
22903 \begin_inset LatexCommand \ref{sub:Startup-Code}
22904
22905 \end_inset
22906
22907  for other possibilities.
22908 \end_layout
22909
22910 \begin_layout Subsection
22911 Other Features available by SFR
22912 \end_layout
22913
22914 \begin_layout Standard
22915 Some MCS51 variants offer features like Double DPTR
22916 \begin_inset LatexCommand \index{DPTR}
22917
22918 \end_inset
22919
22920 , multiple DPTR, decrementing DPTR, 16x16 Multiply.
22921  These are currently not used for the MCS51 port.
22922  If you absolutely need them you can fall back to inline assembly or submit
22923  a patch to SDCC.
22924 \begin_inset VSpace bigskip
22925 \end_inset
22926
22927
22928 \end_layout
22929
22930 \begin_layout Section
22931 DS400 port
22932 \end_layout
22933
22934 \begin_layout Standard
22935 The DS80C400
22936 \begin_inset LatexCommand \index{DS80C400}
22937
22938 \end_inset
22939
22940
22941 \begin_inset LatexCommand \index{DS400}
22942
22943 \end_inset
22944
22945  microcontroller has a rich set of peripherals.
22946  In its built-in ROM library it includes functions to access some of the
22947  features, among them is a TCP stack with IP4 and IP6 support.
22948  Library headers (currently in beta status) and other files are provided
22949  at
22950 \size footnotesize
22951
22952 \begin_inset LatexCommand \url{ftp://ftp.dalsemi.com/pub/tini/ds80c400/c_libraries/sdcc/index.html}
22953
22954 \end_inset
22955
22956 .
22957 \begin_inset VSpace bigskip
22958 \end_inset
22959
22960
22961 \end_layout
22962
22963 \begin_layout Section
22964 The Z80 and gbz80 port
22965 \end_layout
22966
22967 \begin_layout Standard
22968 SDCC can target both the Zilog Z80
22969 \begin_inset LatexCommand \index{Z80}
22970
22971 \end_inset
22972
22973  and the Nintendo Gameboy's Z80-like gbz80
22974 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
22975
22976 \end_inset
22977
22978 .
22979  The Z80 port is passed through the same
22980 \emph on
22981 regressions tests
22982 \begin_inset LatexCommand \index{Regression test}
22983
22984 \end_inset
22985
22986
22987 \emph default
22988  (see section
22989 \begin_inset LatexCommand \ref{sec:Quality-control}
22990
22991 \end_inset
22992
22993 ) as the MCS51 and DS390 ports, so floating point support, support for long
22994  variables and bitfield support is fine.
22995  See mailing lists and forums about interrupt routines.
22996 \end_layout
22997
22998 \begin_layout Standard
22999 As always, the code is the authoritative reference - see z80/ralloc.c and
23000  z80/gen.c.
23001  The stack
23002 \begin_inset LatexCommand \index{Z80!stack}
23003
23004 \end_inset
23005
23006  frame is similar to that generated by the IAR Z80 compiler.
23007  IX is used as the base pointer, HL and IY are used as a temporary registers,
23008  and BC and DE are available for holding variables.
23009  Return values
23010 \begin_inset LatexCommand \index{Z80!return value}
23011
23012 \end_inset
23013
23014  for the Z80 port are stored in L (one byte), HL (two bytes), or DEHL (four
23015  bytes).
23016  The gbz80 port use the same set of registers for the return values, but
23017  in a different order of significance: E (one byte), DE (two bytes), or
23018  HLDE (four bytes).
23019 \begin_inset VSpace bigskip
23020 \end_inset
23021
23022
23023 \end_layout
23024
23025 \begin_layout Section
23026 The HC08 port
23027 \end_layout
23028
23029 \begin_layout Standard
23030 The port to the Freescale/Motorola HC08
23031 \begin_inset LatexCommand \index{HC08}
23032
23033 \end_inset
23034
23035  family has been added in October 2003, and is still undergoing some basic
23036  development.
23037  The code generator is complete, but the register allocation is still quite
23038  unoptimized.
23039  Some of the SDCC's standard C library functions have embedded non-HC08
23040  inline assembly and so are not yet usable.
23041 \end_layout
23042
23043 \begin_layout Standard
23044 The HC08 port passes the regression test suite (see section
23045 \begin_inset LatexCommand \ref{sec:Quality-control}
23046
23047 \end_inset
23048
23049 ).
23050 \begin_inset VSpace bigskip
23051 \end_inset
23052
23053
23054 \newpage
23055
23056 \end_layout
23057
23058 \begin_layout Section
23059 The PIC14
23060 \begin_inset LatexCommand \index{PIC14}
23061
23062 \end_inset
23063
23064  port
23065 \end_layout
23066
23067 \begin_layout Standard
23068 The PIC14 port adds support for Microchip
23069 \begin_inset LatexCommand \index{Microchip}
23070
23071 \end_inset
23072
23073
23074 \begin_inset Formula $^{\text{TM}}$
23075 \end_inset
23076
23077  PIC
23078 \begin_inset LatexCommand \index{PIC14}
23079
23080 \end_inset
23081
23082
23083 \begin_inset Formula $^{\text{TM}}$
23084 \end_inset
23085
23086  MCUs with 14 bit wide instructions.
23087  This port is not yet mature and still lacks many features.
23088  However, it can work for simple code.
23089 \end_layout
23090
23091 \begin_layout Standard
23092 Currently supported devices include:
23093 \end_layout
23094
23095 \begin_layout Standard
23096 12F: 629, 635, 675, 683
23097 \end_layout
23098
23099 \begin_layout Standard
23100 16C: 432, 433
23101 \end_layout
23102
23103 \begin_layout Standard
23104 16C: 554, 557, 558
23105 \end_layout
23106
23107 \begin_layout Standard
23108 16C: 62, 620, 620a, 621, 621a, 622, 622a, 63a, 65b
23109 \end_layout
23110
23111 \begin_layout Standard
23112 16C: 71, 710, 711, 715, 717, 72, 73b, 745, 74b, 765, 770, 771, 773, 774,
23113  781, 782
23114 \end_layout
23115
23116 \begin_layout Standard
23117 16C: 925, 926
23118 \end_layout
23119
23120 \begin_layout Standard
23121 16F: 627, 627a, 628, 628a, 630, 636, 639, 648a, 676, 684, 685, 687, 688,
23122  689, 690
23123 \end_layout
23124
23125 \begin_layout Standard
23126 16F: 716, 72, 73, 737, 74, 76, 767, 77, 777, 785
23127 \end_layout
23128
23129 \begin_layout Standard
23130 16F: 818, 819, 84, 84a, 87, 870, 871, 872, 873, 873a, 874, 874a, 876, 876a,
23131  877, 877a, 88
23132 \end_layout
23133
23134 \begin_layout Standard
23135 16F: 913, 914, 916, 917
23136 \end_layout
23137
23138 \begin_layout Standard
23139 An up-to-date list of currently supported devices can be obtained via
23140 \family typewriter
23141 sdcc -mpic14 -phelp foo.c
23142 \family default
23143  (foo.c must exist...).
23144 \end_layout
23145
23146 \begin_layout Subsection
23147 PIC Code Pages
23148 \begin_inset LatexCommand \index{code page (pic14)}
23149
23150 \end_inset
23151
23152  and Memory Banks
23153 \begin_inset LatexCommand \index{Memory bank (pic14)}
23154
23155 \end_inset
23156
23157
23158 \end_layout
23159
23160 \begin_layout Standard
23161 The linker organizes allocation for the code page and RAM banks.
23162  It does not have intimate knowledge of the code flow.
23163  It will put all the code section of a single .asm file into a single code
23164  page.
23165  In order to make use of multiple code pages, separate asm files must be
23166  used.
23167  The compiler assigns all
23168 \emph on
23169 static
23170 \emph default
23171  functions of a single .c file into the same code page.
23172 \newline
23173
23174 \newline
23175 To get the best results,
23176  follow these guidelines:
23177 \end_layout
23178
23179 \begin_layout Enumerate
23180 Make local functions static, as non static functions require code page selection
23181  overhead.
23182 \newline
23183 Due to the way sdcc handles functions, place called functions prior
23184  to calling functions in the file wherever possible: Otherwise sdcc will
23185  insert unneccessary pagesel directives around the call, believing that
23186  the called function is externally defined.
23187 \end_layout
23188
23189 \begin_layout Enumerate
23190 For devices that have multiple code pages it is more efficient to use the
23191  same number of files as pages: Use up to 4 separate .c files for the 16F877,
23192  but only 2 files for the 16F874.
23193  This way the linker can put the code for each file into different code
23194  pages and there will be less page selection overhead.
23195 \end_layout
23196
23197 \begin_layout Enumerate
23198 And as for any 8 bit micro (especially for PIC14 as they have a very simple
23199  instruction set), use `unsigned char' wherever possible instead of `int'.
23200 \end_layout
23201
23202 \begin_layout Subsection
23203 Adding New Devices to the Port
23204 \end_layout
23205
23206 \begin_layout Standard
23207 Adding support for a new 14
23208 \begin_inset ERT
23209 status open
23210
23211 \begin_layout Standard
23212
23213
23214 \backslash
23215 ,
23216 \end_layout
23217
23218 \end_inset
23219
23220 bit PIC MCU requires the following steps:
23221 \end_layout
23222
23223 \begin_layout Enumerate
23224 Create a new device description.
23225 \newline
23226 Each device is described in two files: pic16f*.h
23227  and pic16f*.c.
23228  These files primarily define SFRs, structs to access their bits, and symbolic
23229  configuration options.
23230  Both files can be generated from gputils' .inc files using the perl script
23231 \family typewriter
23232 support/scripts/inc2h.pl
23233 \family default
23234 .
23235  This file also contains further instructions on how to proceed.
23236 \end_layout
23237
23238 \begin_layout Enumerate
23239 Copy the .h file into SDCC's include path and either add the .c file to your
23240  project or copy it to
23241 \family typewriter
23242 device/lib/pic/libdev
23243 \family default
23244 .
23245  Afterwards, rebuild and install the libraries.
23246 \end_layout
23247
23248 \begin_layout Enumerate
23249 Edit pic14devices.txt in SDCC's include path (
23250 \family typewriter
23251 device/include/pic/
23252 \family default
23253  in the source tree or
23254 \family typewriter
23255 /usr/local/share/sdcc/include/pic
23256 \family default
23257  after installation).
23258 \newline
23259 You need to add a device specification here to make
23260  the memory layout (code banks, RAM, aliased memory regions, ...) known to
23261  the compiler.
23262  Probably you can copy and modify an existing entry.
23263  The file format is documented at the top of the file.
23264 \end_layout
23265
23266 \begin_layout Subsection
23267 Interrupt Code
23268 \end_layout
23269
23270 \begin_layout Standard
23271 For the interrupt function, use the keyword `__interrupt'
23272 \begin_inset LatexCommand \index{PIC14!interrupt}
23273
23274 \end_inset
23275
23276  with level number of 0 (PIC14 only has 1 interrupt so this number is only
23277  there to avoid a syntax error - it ought to be fixed).
23278  E.g.:
23279 \end_layout
23280
23281 \begin_layout Verse
23282
23283 \family typewriter
23284 void Intr(void) __interrupt 0
23285 \newline
23286 {
23287 \newline
23288 \InsetSpace ~
23289 \InsetSpace ~
23290 T0IF = 0; /* Clear timer interrupt */
23291 \newline
23292 }
23293 \end_layout
23294
23295 \begin_layout Subsection
23296 Linking and Assembling
23297 \end_layout
23298
23299 \begin_layout Standard
23300 For assembling you can use either GPUTILS'
23301 \begin_inset LatexCommand \index{gputils (pic tools)}
23302
23303 \end_inset
23304
23305  gpasm.exe or MPLAB's mpasmwin.exe.
23306  GPUTILS are available from
23307 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
23308
23309 \end_inset
23310
23311 .
23312  For linking you can use either GPUTILS' gplink or MPLAB's mplink.exe.
23313  If you use MPLAB and an interrupt function then the linker script file
23314  vectors section will need to be enlarged to link with mplink.
23315 \newline
23316
23317 \newline
23318 Here is a
23319 \family typewriter
23320 Makefile
23321 \family default
23322  using GPUTILS:
23323 \end_layout
23324
23325 \begin_layout Verse
23326
23327 \family typewriter
23328 .c.o:
23329 \newline
23330 \InsetSpace ~
23331 \InsetSpace ~
23332 \InsetSpace ~
23333 \InsetSpace ~
23334 \InsetSpace ~
23335 \InsetSpace ~
23336 \InsetSpace ~
23337 \InsetSpace ~
23338 sdcc -V -mpic14 -p16f877 -c $<
23339 \newline
23340
23341 \newline
23342 $(PRJ).hex: $(OBJS)
23343 \newline
23344 \InsetSpace ~
23345 \InsetSpace ~
23346 \InsetSpace ~
23347 \InsetSpace ~
23348 \InsetSpace ~
23349 \InsetSpace ~
23350 \InsetSpace ~
23351 \InsetSpace ~
23352 gplink -m -s $(PRJ).lkr
23353  -o $(PRJ).hex $(OBJS) libsdcc.lib
23354 \end_layout
23355
23356 \begin_layout Standard
23357 Here is a
23358 \family typewriter
23359 Makefile
23360 \family default
23361  using MPLAB:
23362 \end_layout
23363
23364 \begin_layout Verse
23365
23366 \family typewriter
23367 .c.o:
23368 \newline
23369 \InsetSpace ~
23370 \InsetSpace ~
23371 \InsetSpace ~
23372 \InsetSpace ~
23373 \InsetSpace ~
23374 \InsetSpace ~
23375 \InsetSpace ~
23376 \InsetSpace ~
23377 sdcc -S -V -mpic14 -p16f877 $<
23378 \newline
23379 \InsetSpace ~
23380 \InsetSpace ~
23381 \InsetSpace ~
23382 \InsetSpace ~
23383 \InsetSpace ~
23384 \InsetSpace ~
23385 \InsetSpace ~
23386 \InsetSpace ~
23387 mpasmwin /q /o $*.asm
23388 \newline
23389
23390 \newline
23391 $(PRJ).hex: $(OBJS)
23392 \newline
23393 \InsetSpace ~
23394 \InsetSpace ~
23395 \InsetSpace ~
23396 \InsetSpace ~
23397 \InsetSpace ~
23398 \InsetSpace ~
23399 \InsetSpace ~
23400 \InsetSpace ~
23401 mplink
23402  /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS) libsdcc.lib
23403 \end_layout
23404
23405 \begin_layout Standard
23406 Please note that indentations within a
23407 \family typewriter
23408  Makefile
23409 \family default
23410  have to be done with a tabulator character.
23411 \end_layout
23412
23413 \begin_layout Subsection
23414 Command-Line Options
23415 \end_layout
23416
23417 \begin_layout Standard
23418 Besides the switches common to all SDCC backends, the PIC14 port accepts
23419  the following options (for an updated list see sdcc -
23420 \begin_inset ERT
23421 status collapsed
23422
23423 \begin_layout Standard
23424
23425
23426 \backslash
23427 /
23428 \end_layout
23429
23430 \end_inset
23431
23432 -help):
23433 \end_layout
23434
23435 \begin_layout Description
23436 -
23437 \begin_inset ERT
23438 status collapsed
23439
23440 \begin_layout Standard
23441
23442
23443 \backslash
23444 /
23445 \end_layout
23446
23447 \end_inset
23448
23449 -debug-xtra
23450 \begin_inset LatexCommand \index{PIC14!Options!-\/-debug-extra}
23451
23452 \end_inset
23453
23454  emit debug info in assembly output
23455 \end_layout
23456
23457 \begin_layout Description
23458 -
23459 \begin_inset ERT
23460 status collapsed
23461
23462 \begin_layout Standard
23463
23464
23465 \backslash
23466 /
23467 \end_layout
23468
23469 \end_inset
23470
23471 -no-pcode-opt
23472 \begin_inset LatexCommand \index{PIC14!Options!-\/-no-pcode-opt}
23473
23474 \end_inset
23475
23476  disable (slightly faulty) optimization on pCode
23477 \end_layout
23478
23479 \begin_layout Description
23480 -
23481 \begin_inset ERT
23482 status collapsed
23483
23484 \begin_layout Standard
23485
23486
23487 \backslash
23488 /
23489 \end_layout
23490
23491 \end_inset
23492
23493 -stack-loc
23494 \begin_inset LatexCommand \index{PIC14!Options!-\/-stack-loc}
23495
23496 \end_inset
23497
23498  sets the lowest address of the argument passing stack (defaults to a suitably
23499  large shared databank to reduce BANKSEL overhead)
23500 \end_layout
23501
23502 \begin_layout Description
23503 -
23504 \begin_inset ERT
23505 status collapsed
23506
23507 \begin_layout Standard
23508
23509
23510 \backslash
23511 /
23512 \end_layout
23513
23514 \end_inset
23515
23516 -stack-size
23517 \begin_inset LatexCommand \index{PIC14!Options!-\/-stack-size}
23518
23519 \end_inset
23520
23521  sets the size if the argument passing stack (default: 16, minimum: 4)
23522 \end_layout
23523
23524 \begin_layout Subsection
23525 Environment Variables
23526 \end_layout
23527
23528 \begin_layout Standard
23529 The PIC14 port recognizes the following environment variables:
23530 \end_layout
23531
23532 \begin_layout Description
23533 SDCC_PIC14_SPLIT_LOCALS If set and not empty, sdcc will allocate each temporary
23534  register (the ones called r0xNNNN) in a section of its own.
23535  By default (if this variable is unset), sdcc tries to cluster registers
23536  in sections in order to reduce the BANKSEL overhead when accessing them.
23537 \end_layout
23538
23539 \begin_layout Subsection
23540 The Library
23541 \end_layout
23542
23543 \begin_layout Standard
23544 The PIC14 library currently only contains support routines required by the
23545  compiler to implement multiplication, division, and floating point support.
23546  No libc-like replacement is available at the moment, though many of the
23547  common sdcc library sources (in
23548 \family typewriter
23549 device/lib
23550 \family default
23551 ) should also compile with the PIC14 port.
23552 \end_layout
23553
23554 \begin_layout Subsubsection
23555 error: missing definition for symbol ``__gptrget1''
23556 \end_layout
23557
23558 \begin_layout Standard
23559 The PIC14 port uses library routines to provide more complex operations
23560  like multiplication, division/modulus and (generic) pointer dereferencing.
23561  In order to add these routines to your project, you must link with PIC14's
23562 \family typewriter
23563 libsdcc.lib
23564 \family default
23565 .
23566  For single source file projects this is done automatically, more complex
23567  projects must add
23568 \family typewriter
23569 libsdcc.lib
23570 \family default
23571  to the linker's arguments.
23572  Make sure you also add an include path for the library (using the -I switch
23573  to the linker)!
23574 \end_layout
23575
23576 \begin_layout Subsubsection
23577 Processor mismatch in file ``XXX''.
23578 \end_layout
23579
23580 \begin_layout Standard
23581 This warning can usually be ignored due to the very good compatibility amongst
23582  14
23583 \begin_inset ERT
23584 status open
23585
23586 \begin_layout Standard
23587
23588
23589 \backslash
23590 ,
23591 \end_layout
23592
23593 \end_inset
23594
23595 bit PIC
23596 \begin_inset LatexCommand \index{PIC14}
23597
23598 \end_inset
23599
23600  devices.
23601 \end_layout
23602
23603 \begin_layout Standard
23604 You might also consider recompiling the library for your specific device
23605  by changing the ARCH=p16f877 (default target) entry in
23606 \family typewriter
23607 device/lib/pic/Makefile.in
23608 \family default
23609  and
23610 \family typewriter
23611 device/lib/pic/Makefile
23612 \family default
23613  to reflect your device.
23614  This might even improve performance for smaller devices as unneccesary
23615  BANKSELs might be removed.
23616 \end_layout
23617
23618 \begin_layout Subsection
23619 Known Bugs
23620 \end_layout
23621
23622 \begin_layout Subsubsection
23623 Function arguments
23624 \end_layout
23625
23626 \begin_layout Standard
23627 Functions with variable argument lists (like printf) are not yet supported.
23628  Similarly, taking the argument of the first argument passed into a function
23629  does not work: It is currently passed in WREG and has no address...
23630 \end_layout
23631
23632 \begin_layout Subsubsection
23633 Regression tests fail
23634 \end_layout
23635
23636 \begin_layout Standard
23637 Though the small subset of regression tests in src/regression passes, SDCC
23638  regression test suite does not, indicating that there are still major bugs
23639  in the port.
23640  However, many smaller projects have successfully used SDCC in the past...
23641 \end_layout
23642
23643 \begin_layout Standard
23644
23645 \size footnotesize
23646
23647 \newpage
23648
23649 \end_layout
23650
23651 \begin_layout Section
23652 The PIC16
23653 \begin_inset LatexCommand \index{PIC16}
23654
23655 \end_inset
23656
23657  port
23658 \end_layout
23659
23660 \begin_layout Standard
23661 The PIC16 port adds support for Microchip
23662 \begin_inset LatexCommand \index{Microchip}
23663
23664 \end_inset
23665
23666
23667 \begin_inset Formula $^{\text{TM}}$
23668 \end_inset
23669
23670  PIC
23671 \begin_inset LatexCommand \index{PIC}
23672
23673 \end_inset
23674
23675
23676 \begin_inset Formula $^{\text{TM}}$
23677 \end_inset
23678
23679  MCUs with 16 bit wide instructions.
23680  Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx
23681 ; devices supported by the port include:
23682 \end_layout
23683
23684 \begin_layout Standard
23685 18F: 242, 248, 252, 258, 442, 448, 452, 458
23686 \end_layout
23687
23688 \begin_layout Standard
23689 18F: 1220, 1320
23690 \end_layout
23691
23692 \begin_layout Standard
23693 18F: 2220, 2221, 2320, 2321, 2331, 2431, 2455, 24j10, 2525, 2550, 25j10,
23694  2620
23695 \end_layout
23696
23697 \begin_layout Standard
23698 18F: 4220, 4221, 4320, 4321, 4331, 4431, 4455, 44j10, 4520, 4525, 4550,
23699  45j10, 4620
23700 \end_layout
23701
23702 \begin_layout Standard
23703 18F: 6520, 6620, 6680, 6720
23704 \end_layout
23705
23706 \begin_layout Standard
23707 18F: 8520, 8620, 8680, 8720
23708 \end_layout
23709
23710 \begin_layout Subsection
23711 Global Options
23712 \end_layout
23713
23714 \begin_layout Standard
23715 PIC16 port supports the standard command line arguments as supposed, with
23716  the exception of certain cases that will be mentioned in the following
23717  list:
23718 \end_layout
23719
23720 \begin_layout Description
23721 -
23722 \begin_inset ERT
23723 status collapsed
23724
23725 \begin_layout Standard
23726
23727
23728 \backslash
23729 /
23730 \end_layout
23731
23732 \end_inset
23733
23734 -callee-saves
23735 \begin_inset LatexCommand \index{PIC16!Options!-\/-callee-saves}
23736
23737 \end_inset
23738
23739  See -
23740 \begin_inset ERT
23741 status collapsed
23742
23743 \begin_layout Standard
23744
23745
23746 \backslash
23747 /
23748 \end_layout
23749
23750 \end_inset
23751
23752 -all-callee-saves
23753 \end_layout
23754
23755 \begin_layout Description
23756 -
23757 \begin_inset ERT
23758 status collapsed
23759
23760 \begin_layout Standard
23761
23762
23763 \backslash
23764 /
23765 \end_layout
23766
23767 \end_inset
23768
23769 -fommit-frame-pointer
23770 \begin_inset LatexCommand \index{PIC16!Options!-\/-fommit-frame-pointer}
23771
23772 \end_inset
23773
23774  Frame pointer will be omitted when the function uses no local variables.
23775 \end_layout
23776
23777 \begin_layout Subsection
23778 Port Specific Options
23779 \begin_inset LatexCommand \index{Options PIC16}
23780
23781 \end_inset
23782
23783
23784 \end_layout
23785
23786 \begin_layout Standard
23787 The port specific options appear after the global options in the sdcc -
23788 \begin_inset ERT
23789 status collapsed
23790
23791 \begin_layout Standard
23792
23793
23794 \backslash
23795 /
23796 \end_layout
23797
23798 \end_inset
23799
23800 -help output.
23801 \end_layout
23802
23803 \begin_layout Subsubsection
23804 Code Generation Options
23805 \end_layout
23806
23807 \begin_layout Standard
23808 These options influence the generated assembler code.
23809 \end_layout
23810
23811 \begin_layout Description
23812 -
23813 \begin_inset ERT
23814 status collapsed
23815
23816 \begin_layout Standard
23817
23818
23819 \backslash
23820 /
23821 \end_layout
23822
23823 \end_inset
23824
23825 -pstack-model=[model] Used in conjuction with the command above.
23826  Defines the stack model to be used, valid stack models are:
23827 \end_layout
23828
23829 \begin_deeper
23830 \begin_layout List
23831 \labelwidthstring 00.00.0000
23832
23833 \emph on
23834 small
23835 \emph default
23836  Selects small stack model.
23837  8 bit stack and frame pointers.
23838  Supports 256 bytes stack size.
23839 \end_layout
23840
23841 \begin_layout List
23842 \labelwidthstring 00.00.0000
23843
23844 \emph on
23845 large
23846 \emph default
23847  Selects large stack model.
23848  16 bit stack and frame pointers.
23849  Supports 65536 bytes stack size.
23850 \end_layout
23851
23852 \end_deeper
23853 \begin_layout Description
23854 -
23855 \begin_inset ERT
23856 status collapsed
23857
23858 \begin_layout Standard
23859
23860
23861 \backslash
23862 /
23863 \end_layout
23864
23865 \end_inset
23866
23867 -pno-banksel Do not generate BANKSEL assembler directives.
23868 \end_layout
23869
23870 \begin_layout Description
23871 -
23872 \begin_inset ERT
23873 status collapsed
23874
23875 \begin_layout Standard
23876
23877
23878 \backslash
23879 /
23880 \end_layout
23881
23882 \end_inset
23883
23884 -extended Enable extended instruction set/literal offset addressing mode.
23885  Use with care!
23886 \end_layout
23887
23888 \begin_layout Subsubsection
23889 Optimization Options
23890 \end_layout
23891
23892 \begin_layout Description
23893 -
23894 \begin_inset ERT
23895 status collapsed
23896
23897 \begin_layout Standard
23898
23899
23900 \backslash
23901 /
23902 \end_layout
23903
23904 \end_inset
23905
23906 -obanksel=n Set optimization level for inserting BANKSELs.
23907 \newline
23908
23909 \end_layout
23910
23911 \begin_deeper
23912 \begin_layout List
23913 \labelwidthstring 00.00.0000
23914 0 no optimization
23915 \end_layout
23916
23917 \begin_layout List
23918 \labelwidthstring 00.00.0000
23919 1 checks previous used register and if it is the same then does not emit
23920  BANKSEL, accounts only for labels.
23921 \end_layout
23922
23923 \begin_layout List
23924 \labelwidthstring 00.00.0000
23925 2 tries to check the location of (even different) symbols and removes BANKSELs
23926  if they are in the same bank.
23927 \newline
23928
23929 \emph on
23930 Important: There might be problems if the linker script has data sections
23931  across bank borders!
23932 \end_layout
23933
23934 \end_deeper
23935 \begin_layout Description
23936 -
23937 \begin_inset ERT
23938 status collapsed
23939
23940 \begin_layout Standard
23941
23942
23943 \backslash
23944 /
23945 \end_layout
23946
23947 \end_inset
23948
23949 -denable-peeps Force the usage of peepholes.
23950  Use with care.
23951 \end_layout
23952
23953 \begin_layout Description
23954 -
23955 \begin_inset ERT
23956 status collapsed
23957
23958 \begin_layout Standard
23959
23960
23961 \backslash
23962 /
23963 \end_layout
23964
23965 \end_inset
23966
23967 -optimize-goto Try to use (conditional) BRA instead of GOTO.
23968 \end_layout
23969
23970 \begin_layout Description
23971 -
23972 \begin_inset ERT
23973 status collapsed
23974
23975 \begin_layout Standard
23976
23977
23978 \backslash
23979 /
23980 \end_layout
23981
23982 \end_inset
23983
23984 -optimize-cmp Try to optimize some compares.
23985 \end_layout
23986
23987 \begin_layout Description
23988 -
23989 \begin_inset ERT
23990 status collapsed
23991
23992 \begin_layout Standard
23993
23994
23995 \backslash
23996 /
23997 \end_layout
23998
23999 \end_inset
24000
24001 -optimize-df Analyze the dataflow of the generated code and improve it.
24002 \end_layout
24003
24004 \begin_layout Subsubsection
24005 Assembling Options
24006 \end_layout
24007
24008 \begin_layout Description
24009 -
24010 \begin_inset ERT
24011 status collapsed
24012
24013 \begin_layout Standard
24014
24015
24016 \backslash
24017 /
24018 \end_layout
24019
24020 \end_inset
24021
24022 -asm= Sets the full path and name of an external assembler to call.
24023 \end_layout
24024
24025 \begin_layout Description
24026 -
24027 \begin_inset ERT
24028 status collapsed
24029
24030 \begin_layout Standard
24031
24032
24033 \backslash
24034 /
24035 \end_layout
24036
24037 \end_inset
24038
24039 -mplab-comp MPLAB
24040 \begin_inset LatexCommand \index{PIC16!MPLAB}
24041
24042 \end_inset
24043
24044  compatibility option.
24045  Currently only suppresses special gpasm directives.
24046 \end_layout
24047
24048 \begin_layout Subsubsection
24049 Linking Options
24050 \end_layout
24051
24052 \begin_layout Description
24053 -
24054 \begin_inset ERT
24055 status collapsed
24056
24057 \begin_layout Standard
24058
24059
24060 \backslash
24061 /
24062 \end_layout
24063
24064 \end_inset
24065
24066 -link= Sets the full path and name of an external linker to call.
24067 \end_layout
24068
24069 \begin_layout Description
24070 -
24071 \begin_inset ERT
24072 status collapsed
24073
24074 \begin_layout Standard
24075
24076
24077 \backslash
24078 /
24079 \end_layout
24080
24081 \end_inset
24082
24083 -preplace-udata-with=[kword] Replaces the default udata keyword for allocating
24084  unitialized data variables with [kword].
24085  Valid keywords are: "udata_acs", "udata_shr", "udata_ovr".
24086 \end_layout
24087
24088 \begin_layout Description
24089 -
24090 \begin_inset ERT
24091 status collapsed
24092
24093 \begin_layout Standard
24094
24095
24096 \backslash
24097 /
24098 \end_layout
24099
24100 \end_inset
24101
24102 -ivt-loc=n Place the interrupt vector table at address
24103 \emph on
24104 n
24105 \emph default
24106 .
24107  Useful for bootloaders.
24108 \end_layout
24109
24110 \begin_layout Description
24111 -
24112 \begin_inset ERT
24113 status collapsed
24114
24115 \begin_layout Standard
24116
24117
24118 \backslash
24119 /
24120 \end_layout
24121
24122 \end_inset
24123
24124 -nodefaultlibs Do not link default libraries when linking.
24125 \end_layout
24126
24127 \begin_layout Description
24128 -
24129 \begin_inset ERT
24130 status collapsed
24131
24132 \begin_layout Standard
24133
24134
24135 \backslash
24136 /
24137 \end_layout
24138
24139 \end_inset
24140
24141 -use-crt= Use a custom run-time module instead of the defaults.
24142 \end_layout
24143
24144 \begin_layout Description
24145 -
24146 \begin_inset ERT
24147 status collapsed
24148
24149 \begin_layout Standard
24150
24151
24152 \backslash
24153 /
24154 \end_layout
24155
24156 \end_inset
24157
24158 -no-crt Don't link the default run-time modules
24159 \end_layout
24160
24161 \begin_layout Subsubsection
24162 Debugging Options
24163 \end_layout
24164
24165 \begin_layout Standard
24166 Debugging options enable extra debugging information in the output files.
24167 \end_layout
24168
24169 \begin_layout Description
24170 -
24171 \begin_inset ERT
24172 status collapsed
24173
24174 \begin_layout Standard
24175
24176
24177 \backslash
24178 /
24179 \end_layout
24180
24181 \end_inset
24182
24183 -debug-xtra Similar to -
24184 \begin_inset ERT
24185 status collapsed
24186
24187 \begin_layout Standard
24188
24189
24190 \backslash
24191 /
24192 \end_layout
24193
24194 \end_inset
24195
24196 -debug
24197 \begin_inset LatexCommand \index{-\/-debug}
24198
24199 \end_inset
24200
24201 , but dumps more information.
24202 \end_layout
24203
24204 \begin_layout Description
24205 -
24206 \begin_inset ERT
24207 status collapsed
24208
24209 \begin_layout Standard
24210
24211
24212 \backslash
24213 /
24214 \end_layout
24215
24216 \end_inset
24217
24218 -debug-ralloc Force register allocator to dump <source>.d file with debugging
24219  information.
24220  <source> is the name of the file being compiled.
24221 \end_layout
24222
24223 \begin_layout Description
24224 -
24225 \begin_inset ERT
24226 status collapsed
24227
24228 \begin_layout Standard
24229
24230
24231 \backslash
24232 /
24233 \end_layout
24234
24235 \end_inset
24236
24237 -pcode-verbose Enable pcode debugging information in translation.
24238 \end_layout
24239
24240 \begin_layout Description
24241 -
24242 \begin_inset ERT
24243 status collapsed
24244
24245 \begin_layout Standard
24246
24247
24248 \backslash
24249 /
24250 \end_layout
24251
24252 \end_inset
24253
24254 -calltree Dump call tree in .calltree file.
24255 \end_layout
24256
24257 \begin_layout Description
24258 -
24259 \begin_inset ERT
24260 status collapsed
24261
24262 \begin_layout Standard
24263
24264
24265 \backslash
24266 /
24267 \end_layout
24268
24269 \end_inset
24270
24271 -gstack Trace push/pops for stack pointer overflow.
24272 \end_layout
24273
24274 \begin_layout Subsection
24275 Enviroment Variables
24276 \end_layout
24277
24278 \begin_layout Standard
24279 There is a number of enviromental variables that can be used when running
24280  SDCC to enable certain optimizations or force a specific program behaviour.
24281  these variables are primarily for debugging purposes so they can be enabled/dis
24282 abled at will.
24283 \end_layout
24284
24285 \begin_layout Standard
24286 Currently there is only two such variables available:
24287 \end_layout
24288
24289 \begin_layout Description
24290 OPTIMIZE_BITFIELD_POINTER_GET When this variable exists, reading of structure
24291  bitfields is optimized by directly loading FSR0 with the address of the
24292  bitfield structure.
24293  Normally SDCC will cast the bitfield structure to a bitfield pointer and
24294  then load FSR0.
24295  This step saves data ram and code space for functions that make heavy use
24296  of bitfields.
24297  (i.e., 80 bytes of code space are saved when compiling malloc.c with this
24298  option).
24299 \end_layout
24300
24301 \begin_layout Description
24302 NO_REG_OPT Do not perform pCode registers optimization.
24303  This should be used for debugging purposes.
24304  If bugs in the pcode optimizer are found, users can benefit from temporarily
24305  disabling the optimizer until the bug is fixed.
24306 \end_layout
24307
24308 \begin_layout Subsection
24309 Preprocessor Macros
24310 \end_layout
24311
24312 \begin_layout Standard
24313 PIC16
24314 \begin_inset LatexCommand \index{PIC16}
24315
24316 \end_inset
24317
24318  port defines the following preprocessor macros while translating a source.
24319 \end_layout
24320
24321 \begin_layout Standard
24322 \align center
24323 \begin_inset Tabular
24324 <lyxtabular version="3" rows="6" columns="2">
24325 <features>
24326 <column alignment="center" valignment="top" leftline="true" width="0">
24327 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24328 <row topline="true" bottomline="true">
24329 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24330 \begin_inset Text
24331
24332 \begin_layout Standard
24333 Macro
24334 \end_layout
24335
24336 \end_inset
24337 </cell>
24338 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24339 \begin_inset Text
24340
24341 \begin_layout Standard
24342 Description
24343 \end_layout
24344
24345 \end_inset
24346 </cell>
24347 </row>
24348 <row topline="true">
24349 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24350 \begin_inset Text
24351
24352 \begin_layout Standard
24353 SDCC_pic16
24354 \end_layout
24355
24356 \end_inset
24357 </cell>
24358 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24359 \begin_inset Text
24360
24361 \begin_layout Standard
24362 Port identification
24363 \end_layout
24364
24365 \end_inset
24366 </cell>
24367 </row>
24368 <row topline="true">
24369 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24370 \begin_inset Text
24371
24372 \begin_layout Standard
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 _pic16
24387 \end_layout
24388
24389 \end_inset
24390 </cell>
24391 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24392 \begin_inset Text
24393
24394 \begin_layout Standard
24395 Port identification (same as above)
24396 \end_layout
24397
24398 \end_inset
24399 </cell>
24400 </row>
24401 <row topline="true">
24402 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24403 \begin_inset Text
24404
24405 \begin_layout Standard
24406 pic18fxxxx
24407 \end_layout
24408
24409 \end_inset
24410 </cell>
24411 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24412 \begin_inset Text
24413
24414 \begin_layout Standard
24415 MCU Identification.
24416 \emph on
24417 xxxx
24418 \emph default
24419  is the microcontrol identification number, i.e.
24420  452, 6620, etc
24421 \end_layout
24422
24423 \end_inset
24424 </cell>
24425 </row>
24426 <row topline="true">
24427 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24428 \begin_inset Text
24429
24430 \begin_layout Standard
24431 _
24432 \begin_inset ERT
24433 status collapsed
24434
24435 \begin_layout Standard
24436
24437
24438 \backslash
24439 /
24440 \end_layout
24441
24442 \end_inset
24443
24444 _18Fxxxx
24445 \end_layout
24446
24447 \end_inset
24448 </cell>
24449 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24450 \begin_inset Text
24451
24452 \begin_layout Standard
24453 MCU Identification (same as above)
24454 \end_layout
24455
24456 \end_inset
24457 </cell>
24458 </row>
24459 <row topline="true" bottomline="true">
24460 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24461 \begin_inset Text
24462
24463 \begin_layout Standard
24464 STACK_MODEL_nnn
24465 \end_layout
24466
24467 \end_inset
24468 </cell>
24469 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24470 \begin_inset Text
24471
24472 \begin_layout Standard
24473 nnn = SMALL or LARGE respectively according to the stack model used
24474 \end_layout
24475
24476 \end_inset
24477 </cell>
24478 </row>
24479 </lyxtabular>
24480
24481 \end_inset
24482
24483
24484 \end_layout
24485
24486 \begin_layout Standard
24487 In addition the following macros are defined when calling assembler:
24488 \end_layout
24489
24490 \begin_layout Standard
24491 \align center
24492 \begin_inset Tabular
24493 <lyxtabular version="3" rows="4" columns="2">
24494 <features>
24495 <column alignment="center" valignment="top" leftline="true" width="0">
24496 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24497 <row topline="true" bottomline="true">
24498 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24499 \begin_inset Text
24500
24501 \begin_layout Standard
24502 Macro
24503 \end_layout
24504
24505 \end_inset
24506 </cell>
24507 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24508 \begin_inset Text
24509
24510 \begin_layout Standard
24511 Description
24512 \end_layout
24513
24514 \end_inset
24515 </cell>
24516 </row>
24517 <row topline="true">
24518 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24519 \begin_inset Text
24520
24521 \begin_layout Standard
24522 __18Fxxxx
24523 \end_layout
24524
24525 \end_inset
24526 </cell>
24527 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24528 \begin_inset Text
24529
24530 \begin_layout Standard
24531 MCU Identification.
24532 \emph on
24533 xxxx
24534 \emph default
24535  is the microcontrol identification number, i.e.
24536  452, 6620, etc
24537 \end_layout
24538
24539 \end_inset
24540 </cell>
24541 </row>
24542 <row topline="true">
24543 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24544 \begin_inset Text
24545
24546 \begin_layout Standard
24547 SDCC_MODEL_nnn
24548 \end_layout
24549
24550 \end_inset
24551 </cell>
24552 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24553 \begin_inset Text
24554
24555 \begin_layout Standard
24556 nnn = SMALL or LARGE respectively according to the memory model used for
24557  SDCC
24558 \end_layout
24559
24560 \end_inset
24561 </cell>
24562 </row>
24563 <row topline="true" bottomline="true">
24564 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24565 \begin_inset Text
24566
24567 \begin_layout Standard
24568 STACK_MODEL_nnn
24569 \end_layout
24570
24571 \end_inset
24572 </cell>
24573 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24574 \begin_inset Text
24575
24576 \begin_layout Standard
24577 nnn = SMALL or LARGE respectively according to the stack model used
24578 \end_layout
24579
24580 \end_inset
24581 </cell>
24582 </row>
24583 </lyxtabular>
24584
24585 \end_inset
24586
24587
24588 \end_layout
24589
24590 \begin_layout Subsection
24591 Directories
24592 \end_layout
24593
24594 \begin_layout Standard
24595 PIC16
24596 \begin_inset LatexCommand \index{PIC16}
24597
24598 \end_inset
24599
24600  port uses the following directories for searching header files and libraries.
24601 \end_layout
24602
24603 \begin_layout Standard
24604 \align center
24605 \begin_inset Tabular
24606 <lyxtabular version="3" rows="3" columns="4">
24607 <features>
24608 <column alignment="center" valignment="top" leftline="true" width="0">
24609 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24610 <column alignment="center" valignment="top" width="0">
24611 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24612 <row topline="true" bottomline="true">
24613 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24614 \begin_inset Text
24615
24616 \begin_layout Standard
24617 Directory
24618 \end_layout
24619
24620 \end_inset
24621 </cell>
24622 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24623 \begin_inset Text
24624
24625 \begin_layout Standard
24626 Description
24627 \end_layout
24628
24629 \end_inset
24630 </cell>
24631 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24632 \begin_inset Text
24633
24634 \begin_layout Standard
24635 Target
24636 \end_layout
24637
24638 \end_inset
24639 </cell>
24640 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24641 \begin_inset Text
24642
24643 \begin_layout Standard
24644 Command prefix
24645 \end_layout
24646
24647 \end_inset
24648 </cell>
24649 </row>
24650 <row topline="true">
24651 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24652 \begin_inset Text
24653
24654 \begin_layout Standard
24655 PREFIX/sdcc/include/pic16
24656 \end_layout
24657
24658 \end_inset
24659 </cell>
24660 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24661 \begin_inset Text
24662
24663 \begin_layout Standard
24664 PIC16 specific headers
24665 \end_layout
24666
24667 \end_inset
24668 </cell>
24669 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24670 \begin_inset Text
24671
24672 \begin_layout Standard
24673 Compiler
24674 \end_layout
24675
24676 \end_inset
24677 </cell>
24678 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24679 \begin_inset Text
24680
24681 \begin_layout Standard
24682 -I
24683 \end_layout
24684
24685 \end_inset
24686 </cell>
24687 </row>
24688 <row topline="true" bottomline="true">
24689 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24690 \begin_inset Text
24691
24692 \begin_layout Standard
24693 PREFIX/sdcc/lib/pic16
24694 \end_layout
24695
24696 \end_inset
24697 </cell>
24698 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24699 \begin_inset Text
24700
24701 \begin_layout Standard
24702 PIC16 specific libraries
24703 \end_layout
24704
24705 \end_inset
24706 </cell>
24707 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24708 \begin_inset Text
24709
24710 \begin_layout Standard
24711 Linker
24712 \end_layout
24713
24714 \end_inset
24715 </cell>
24716 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24717 \begin_inset Text
24718
24719 \begin_layout Standard
24720 -L
24721 \end_layout
24722
24723 \end_inset
24724 </cell>
24725 </row>
24726 </lyxtabular>
24727
24728 \end_inset
24729
24730
24731 \end_layout
24732
24733 \begin_layout Subsection
24734 Pragmas
24735 \begin_inset LatexCommand \label{sub:PIC16_Pragmas}
24736
24737 \end_inset
24738
24739
24740 \end_layout
24741
24742 \begin_layout Standard
24743 The PIC16
24744 \begin_inset LatexCommand \index{PIC16}
24745
24746 \end_inset
24747
24748  port currently supports the following pragmas:
24749 \end_layout
24750
24751 \begin_layout Description
24752 stack
24753 \begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma stack}
24754
24755 \end_inset
24756
24757  This forces the code generator to initialize the stack & frame pointers
24758  at a specific address.
24759  This is an ad hoc solution for cases where no STACK directive is available
24760  in the linker script or gplink is not instructed to create a stack section.
24761 \newline
24762 The
24763  stack pragma should be used only once in a project.
24764  Multiple pragmas may result in indeterminate behaviour of the program.
24765 \begin_inset Foot
24766 status open
24767
24768 \begin_layout Standard
24769 The old format (ie.
24770  #pragma stack 0x5ff) is deprecated and will cause the stack pointer to
24771  cross page boundaries (or even exceed the available data RAM) and crash
24772  the program.
24773  Make sure that stack does not cross page boundaries when using the SMALL
24774  stack model.
24775 \end_layout
24776
24777 \end_inset
24778
24779
24780 \newline
24781 The format is as follows:
24782 \newline
24783
24784 \end_layout
24785
24786 \begin_layout LyX-Code
24787 #pragma stack bottom_address [stack_size]
24788 \newline
24789
24790 \end_layout
24791
24792 \begin_layout Standard
24793
24794 \emph on
24795 bottom_address
24796 \emph default
24797  is the lower bound of the stack section.
24798  The stack pointer initially will point at address (bottom_address+stack_size-1).
24799 \end_layout
24800
24801 \begin_layout LyX-Code
24802 Example:
24803 \end_layout
24804
24805 \begin_layout LyX-Code
24806
24807 \end_layout
24808
24809 \begin_layout LyX-Code
24810 /* initializes stack of 100 bytes at RAM address 0x200 */
24811 \end_layout
24812
24813 \begin_layout LyX-Code
24814 #pragma stack 0x200 100
24815 \end_layout
24816
24817 \begin_layout Standard
24818 If the stack_size field is omitted then a stack is created with the default
24819  size of 64.
24820  This size might be enough for most programs, but its not enough for operations
24821  with deep function nesting or excessive stack usage.
24822 \end_layout
24823
24824 \begin_layout Description
24825 code
24826 \begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma code}
24827
24828 \end_inset
24829
24830  Force a function to a static FLASH address.
24831 \end_layout
24832
24833 \begin_layout LyX-Code
24834 Example:
24835 \end_layout
24836
24837 \begin_layout LyX-Code
24838
24839 \end_layout
24840
24841 \begin_layout LyX-Code
24842 /* place function test_func at 0x4000 */
24843 \end_layout
24844
24845 \begin_layout LyX-Code
24846 #pragma code test_func 0x4000
24847 \end_layout
24848
24849 \begin_layout LyX-Code
24850
24851 \end_layout
24852
24853 \begin_layout Description
24854 library instructs the linker to use a library module.
24855 \newline
24856 Usage:
24857 \end_layout
24858
24859 \begin_layout LyX-Code
24860 #pragma library module_name
24861 \end_layout
24862
24863 \begin_layout Standard
24864
24865 \emph on
24866 module_name
24867 \emph default
24868  can be any library or object file (including its path).
24869  Note that there are four reserved keywords which have special meaning.
24870  These are:
24871 \end_layout
24872
24873 \begin_layout Standard
24874 \align center
24875 \begin_inset Tabular
24876 <lyxtabular version="3" rows="6" columns="3">
24877 <features>
24878 <column alignment="center" valignment="top" leftline="true" width="0">
24879 <column alignment="block" valignment="top" leftline="true" width="20page%">
24880 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
24881 <row topline="true" bottomline="true">
24882 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24883 \begin_inset Text
24884
24885 \begin_layout Standard
24886 Keyword
24887 \end_layout
24888
24889 \end_inset
24890 </cell>
24891 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24892 \begin_inset Text
24893
24894 \begin_layout Standard
24895 Description
24896 \end_layout
24897
24898 \end_inset
24899 </cell>
24900 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24901 \begin_inset Text
24902
24903 \begin_layout Standard
24904 Module to link
24905 \end_layout
24906
24907 \end_inset
24908 </cell>
24909 </row>
24910 <row topline="true">
24911 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24912 \begin_inset Text
24913
24914 \begin_layout Standard
24915
24916 \series bold
24917 ignore
24918 \end_layout
24919
24920 \end_inset
24921 </cell>
24922 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24923 \begin_inset Text
24924
24925 \begin_layout Standard
24926 ignore all library pragmas
24927 \end_layout
24928
24929 \end_inset
24930 </cell>
24931 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24932 \begin_inset Text
24933
24934 \begin_layout Standard
24935
24936 \emph on
24937 (none)
24938 \end_layout
24939
24940 \end_inset
24941 </cell>
24942 </row>
24943 <row topline="true">
24944 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24945 \begin_inset Text
24946
24947 \begin_layout Standard
24948
24949 \series bold
24950 c
24951 \end_layout
24952
24953 \end_inset
24954 </cell>
24955 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24956 \begin_inset Text
24957
24958 \begin_layout Standard
24959 link the C library
24960 \end_layout
24961
24962 \end_inset
24963 </cell>
24964 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24965 \begin_inset Text
24966
24967 \begin_layout Standard
24968
24969 \emph on
24970 libc18f
24971 \emph default
24972 .lib
24973 \end_layout
24974
24975 \end_inset
24976 </cell>
24977 </row>
24978 <row topline="true">
24979 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24980 \begin_inset Text
24981
24982 \begin_layout Standard
24983
24984 \series bold
24985 math
24986 \end_layout
24987
24988 \end_inset
24989 </cell>
24990 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24991 \begin_inset Text
24992
24993 \begin_layout Standard
24994 link the Math libarary
24995 \end_layout
24996
24997 \end_inset
24998 </cell>
24999 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25000 \begin_inset Text
25001
25002 \begin_layout Standard
25003
25004 \emph on
25005 libm18f
25006 \emph default
25007 .lib
25008 \end_layout
25009
25010 \end_inset
25011 </cell>
25012 </row>
25013 <row topline="true">
25014 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25015 \begin_inset Text
25016
25017 \begin_layout Standard
25018
25019 \series bold
25020 io
25021 \end_layout
25022
25023 \end_inset
25024 </cell>
25025 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25026 \begin_inset Text
25027
25028 \begin_layout Standard
25029 link the I/O library
25030 \end_layout
25031
25032 \end_inset
25033 </cell>
25034 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25035 \begin_inset Text
25036
25037 \begin_layout Standard
25038
25039 \emph on
25040 libio18f*
25041 \emph default
25042 .lib
25043 \end_layout
25044
25045 \end_inset
25046 </cell>
25047 </row>
25048 <row topline="true" bottomline="true">
25049 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25050 \begin_inset Text
25051
25052 \begin_layout Standard
25053
25054 \series bold
25055 debug
25056 \end_layout
25057
25058 \end_inset
25059 </cell>
25060 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25061 \begin_inset Text
25062
25063 \begin_layout Standard
25064 link the debug library
25065 \end_layout
25066
25067 \end_inset
25068 </cell>
25069 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25070 \begin_inset Text
25071
25072 \begin_layout Standard
25073
25074 \emph on
25075 libdebug
25076 \emph default
25077 .lib
25078 \end_layout
25079
25080 \end_inset
25081 </cell>
25082 </row>
25083 </lyxtabular>
25084
25085 \end_inset
25086
25087
25088 \newline
25089 * is the device number, i.e.
25090  452 for PIC18F452 MCU.
25091 \end_layout
25092
25093 \begin_layout Standard
25094 This feature allows for linking with specific libraries withoug having to
25095  explicit name them in the command line.
25096  Note that the
25097 \noun on
25098 ignore
25099 \noun default
25100  keyword will reject all modules specified by the library pragma.
25101 \end_layout
25102
25103 \begin_layout Description
25104 udata The pragma udata instructs the compiler to emit code so that linker
25105  will place a variable at a specific memory bank.
25106 \end_layout
25107
25108 \begin_layout LyX-Code
25109 Example:
25110 \end_layout
25111
25112 \begin_layout LyX-Code
25113
25114 \end_layout
25115
25116 \begin_layout LyX-Code
25117 /* places variable foo at bank2 */
25118 \end_layout
25119
25120 \begin_layout LyX-Code
25121 #pragma udata bank2 foo
25122 \end_layout
25123
25124 \begin_layout LyX-Code
25125 char foo;
25126 \end_layout
25127
25128 \begin_layout Standard
25129 In order for this pragma to work extra SECTION directives should be added
25130  in the .lkr script.
25131  In the following example a sample .lkr file is shown:
25132 \end_layout
25133
25134 \begin_layout LyX-Code
25135
25136 \end_layout
25137
25138 \begin_layout LyX-Code
25139 // Sample linker script for the PIC18F452 processor
25140 \end_layout
25141
25142 \begin_layout LyX-Code
25143 LIBPATH .
25144 \end_layout
25145
25146 \begin_layout LyX-Code
25147 CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
25148 \end_layout
25149
25150 \begin_layout LyX-Code
25151 CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
25152 \end_layout
25153
25154 \begin_layout LyX-Code
25155 CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
25156 \end_layout
25157
25158 \begin_layout LyX-Code
25159 CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
25160 \end_layout
25161
25162 \begin_layout LyX-Code
25163 CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
25164 \end_layout
25165
25166 \begin_layout LyX-Code
25167 CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
25168 \end_layout
25169
25170 \begin_layout LyX-Code
25171 ACCESSBANK NAME=accessram  START=0x0            END=0x7F
25172 \end_layout
25173
25174 \begin_layout LyX-Code
25175
25176 \end_layout
25177
25178 \begin_layout LyX-Code
25179 DATABANK   NAME=gpr0       START=0x80           END=0xFF
25180 \end_layout
25181
25182 \begin_layout LyX-Code
25183 DATABANK   NAME=gpr1       START=0x100          END=0x1FF
25184 \end_layout
25185
25186 \begin_layout LyX-Code
25187 DATABANK   NAME=gpr2       START=0x200          END=0x2FF
25188 \end_layout
25189
25190 \begin_layout LyX-Code
25191 DATABANK   NAME=gpr3       START=0x300          END=0x3FF
25192 \end_layout
25193
25194 \begin_layout LyX-Code
25195 DATABANK   NAME=gpr4       START=0x400          END=0x4FF
25196 \end_layout
25197
25198 \begin_layout LyX-Code
25199 DATABANK   NAME=gpr5       START=0x500          END=0x5FF
25200 \end_layout
25201
25202 \begin_layout LyX-Code
25203 ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED
25204 \end_layout
25205
25206 \begin_layout LyX-Code
25207
25208 \end_layout
25209
25210 \begin_layout LyX-Code
25211 SECTION    NAME=CONFIG     ROM=config
25212 \end_layout
25213
25214 \begin_layout LyX-Code
25215
25216 \end_layout
25217
25218 \begin_layout LyX-Code
25219 SECTION    NAME=bank0      RAM=gpr0       # these SECTION directives
25220 \end_layout
25221
25222 \begin_layout LyX-Code
25223 SECTION    NAME=bank1      RAM=gpr1       # should be added to link
25224 \end_layout
25225
25226 \begin_layout LyX-Code
25227 SECTION    NAME=bank2      RAM=gpr2       # section name 'bank?' with
25228 \end_layout
25229
25230 \begin_layout LyX-Code
25231 SECTION    NAME=bank3      RAM=gpr3       # a specific DATABANK name
25232 \end_layout
25233
25234 \begin_layout LyX-Code
25235 SECTION    NAME=bank4      RAM=gpr4
25236 \end_layout
25237
25238 \begin_layout LyX-Code
25239 SECTION    NAME=bank5      RAM=gpr5
25240 \end_layout
25241
25242 \begin_layout Standard
25243 The linker will recognise the section name set in the pragma statement and
25244  will position the variable at the memory bank set with the RAM field at
25245  the SECTION line in the linker script file.
25246 \end_layout
25247
25248 \begin_layout Subsection
25249 Header Files
25250 \begin_inset LatexCommand \label{sub:PIC16_Header-Files}
25251
25252 \end_inset
25253
25254
25255 \end_layout
25256
25257 \begin_layout Standard
25258 There is one main header file
25259 \begin_inset LatexCommand \index{PIC16!Header files}
25260
25261 \end_inset
25262
25263  that can be included to the source files using the pic16
25264 \begin_inset LatexCommand \index{PIC16}
25265
25266 \end_inset
25267
25268  port.
25269  That file is the
25270 \series bold
25271 pic18fregs.h
25272 \series default
25273 .
25274  This header file contains the definitions for the processor special registers,
25275  so it is necessary if the source accesses them.
25276  It can be included by adding the following line in the beginning of the
25277  file:
25278 \end_layout
25279
25280 \begin_layout LyX-Code
25281 #include <pic18fregs.h>
25282 \end_layout
25283
25284 \begin_layout Standard
25285 The specific microcontroller is selected within the pic18fregs.h automatically,
25286  so the same source can be used with a variety of devices.
25287 \end_layout
25288
25289 \begin_layout Subsection
25290 Libraries
25291 \end_layout
25292
25293 \begin_layout Standard
25294 The libraries
25295 \begin_inset LatexCommand \index{PIC16!Libraries}
25296
25297 \end_inset
25298
25299  that PIC16
25300 \begin_inset LatexCommand \index{PIC16}
25301
25302 \end_inset
25303
25304  port depends on are the microcontroller device libraries which contain
25305  the symbol definitions for the microcontroller special function registers.
25306  These libraries have the format pic18fxxxx.lib, where
25307 \emph on
25308 xxxx
25309 \emph default
25310  is the microcontroller identification number.
25311  The specific library is selected automatically by the compiler at link
25312  stage according to the selected device.
25313 \end_layout
25314
25315 \begin_layout Standard
25316 Libraries are created with gplib which is part of the gputils package
25317 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
25318
25319 \end_inset
25320
25321 .
25322 \end_layout
25323
25324 \begin_layout Subsubsection*
25325 Building the libraries
25326 \end_layout
25327
25328 \begin_layout Standard
25329 Before using SDCC/pic16 there are some libraries that need to be compiled.
25330  This process is not done automatically by SDCC since not all users use
25331  SDCC for pic16 projects.
25332  So each user should compile the libraries separately.
25333 \end_layout
25334
25335 \begin_layout Standard
25336 The steps to compile the pic16 libraries under Linux and Mac OS X are:
25337 \end_layout
25338
25339 \begin_layout LyX-Code
25340 cd device/lib/pic16
25341 \end_layout
25342
25343 \begin_layout LyX-Code
25344 ./configure
25345 \end_layout
25346
25347 \begin_layout LyX-Code
25348 make
25349 \end_layout
25350
25351 \begin_layout LyX-Code
25352 cd ..
25353 \end_layout
25354
25355 \begin_layout LyX-Code
25356 make model-pic16
25357 \end_layout
25358
25359 \begin_layout LyX-Code
25360 su -c 'make install'     # install the libraries, you need the root password
25361 \end_layout
25362
25363 \begin_layout Standard
25364 If you need to install the headers too, do:
25365 \end_layout
25366
25367 \begin_layout LyX-Code
25368 cd device/include
25369 \end_layout
25370
25371 \begin_layout LyX-Code
25372 su -c 'make install'     # install the headers, you need the root password
25373 \end_layout
25374
25375 \begin_layout Standard
25376 There exist a special target to build the I/O libraries.
25377  This target is not automatically build because it will build the I/O library
25378  for
25379 \emph on
25380 every
25381 \emph default
25382  supported device.
25383  This way building will take quite a lot of time.
25384  Users are advised to edit the
25385 \series bold
25386 device/lib/pic16/pics.build
25387 \series default
25388  file and then execute:
25389 \end_layout
25390
25391 \begin_layout LyX-Code
25392 make lib-io
25393 \end_layout
25394
25395 \begin_layout Subsection
25396 Adding New Devices to the Port
25397 \end_layout
25398
25399 \begin_layout Standard
25400 Adding support for a new 16
25401 \begin_inset ERT
25402 status open
25403
25404 \begin_layout Standard
25405
25406
25407 \backslash
25408 ,
25409 \end_layout
25410
25411 \end_inset
25412
25413 bit PIC MCU requires the following steps:
25414 \end_layout
25415
25416 \begin_layout Enumerate
25417 Create picDEVICE.c and picDEVICE.h from pDEVICE.inc using
25418 \newline
25419
25420 \family typewriter
25421 perl /path/to/sdcc/support/scripts/inc2h-pic16.pl /path/to/gputils/header/pDEVICE.
25422 inc
25423 \end_layout
25424
25425 \begin_layout Enumerate
25426
25427 \family typewriter
25428 mv picDEVICE.h /path/to/sdcc/device/include/pic16
25429 \end_layout
25430
25431 \begin_layout Enumerate
25432
25433 \family typewriter
25434 mv picDEVICE.c /path/to/sdcc/device/lib/pic16/libdev
25435 \end_layout
25436
25437 \begin_layout Enumerate
25438 Add DEVICE to
25439 \family typewriter
25440 /path/to/sdcc/device/lib/pic16/pics.all
25441 \family default
25442  (and
25443 \family typewriter
25444 .build
25445 \family default
25446 ).
25447 \newline
25448 Note: No 18f prefix here!
25449 \end_layout
25450
25451 \begin_layout Enumerate
25452 Adjust
25453 \family typewriter
25454 /path/to/sdcc/device/lib/pic16/libio/*.ignore
25455 \family default
25456
25457 \newline
25458 Add your DEVICE if it does not compile in
25459 \family typewriter
25460 adc
25461 \family default
25462 ,
25463 \family typewriter
25464 i2c
25465 \family default
25466 , or
25467 \family typewriter
25468 usart
25469 \family default
25470 .
25471 \end_layout
25472
25473 \begin_layout Enumerate
25474 Edit
25475 \family typewriter
25476 /path/to/sdcc/device/include/pic16/pic18fregs.h
25477 \family default
25478 .
25479  The file format is self-explanatory, just add
25480 \newline
25481
25482 \family typewriter
25483 #elif defined(picDEVICE)
25484 \newline
25485 # include <picDEVICE.h>
25486 \family default
25487
25488 \newline
25489 at the right place (keep it sorted).
25490 \end_layout
25491
25492 \begin_layout Enumerate
25493 Edit
25494 \family typewriter
25495 /path/to/sdcc/src/pic16/devices.inc
25496 \family default
25497 .
25498  Copy and modify an existing entry and insert it at the correct place (keep
25499  the file sorted).
25500  The file is hardly documented, look at the entries for the 18f2221...
25501 \end_layout
25502
25503 \begin_layout Enumerate
25504 Recompile SDCC, including the pic16 libraries.
25505 \end_layout
25506
25507 \begin_layout Subsection
25508 Memory Models
25509 \end_layout
25510
25511 \begin_layout Standard
25512 The following memory models are supported by the PIC16 port:
25513 \end_layout
25514
25515 \begin_layout Itemize
25516 small model
25517 \end_layout
25518
25519 \begin_layout Itemize
25520 large model
25521 \end_layout
25522
25523 \begin_layout Standard
25524 Memory model affects the default size of pointers within the source.
25525  The sizes are shown in the next table:
25526 \end_layout
25527
25528 \begin_layout Standard
25529 \align center
25530 \begin_inset Tabular
25531 <lyxtabular version="3" rows="3" columns="3">
25532 <features>
25533 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25534 <column alignment="center" valignment="top" leftline="true" width="0">
25535 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25536 <row topline="true" bottomline="true">
25537 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25538 \begin_inset Text
25539
25540 \begin_layout Standard
25541 Pointer sizes according to memory model
25542 \end_layout
25543
25544 \end_inset
25545 </cell>
25546 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25547 \begin_inset Text
25548
25549 \begin_layout Standard
25550 small model
25551 \end_layout
25552
25553 \end_inset
25554 </cell>
25555 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25556 \begin_inset Text
25557
25558 \begin_layout Standard
25559 large model
25560 \end_layout
25561
25562 \end_inset
25563 </cell>
25564 </row>
25565 <row topline="true" bottomline="true">
25566 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25567 \begin_inset Text
25568
25569 \begin_layout Standard
25570 code pointers
25571 \end_layout
25572
25573 \end_inset
25574 </cell>
25575 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25576 \begin_inset Text
25577
25578 \begin_layout Standard
25579 16-bits
25580 \end_layout
25581
25582 \end_inset
25583 </cell>
25584 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25585 \begin_inset Text
25586
25587 \begin_layout Standard
25588 24-bits
25589 \end_layout
25590
25591 \end_inset
25592 </cell>
25593 </row>
25594 <row topline="true" bottomline="true">
25595 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25596 \begin_inset Text
25597
25598 \begin_layout Standard
25599 data pointers
25600 \end_layout
25601
25602 \end_inset
25603 </cell>
25604 <cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
25605 \begin_inset Text
25606
25607 \begin_layout Standard
25608 16-bits
25609 \end_layout
25610
25611 \end_inset
25612 </cell>
25613 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25614 \begin_inset Text
25615
25616 \begin_layout Standard
25617 16-bits
25618 \end_layout
25619
25620 \end_inset
25621 </cell>
25622 </row>
25623 </lyxtabular>
25624
25625 \end_inset
25626
25627
25628 \end_layout
25629
25630 \begin_layout Standard
25631 It is advisable that all sources within a project are compiled with the
25632  same memory model.
25633  If one wants to override the default memory model, this can be done by
25634  declaring a pointer as
25635 \series bold
25636 far
25637 \series default
25638  or
25639 \series bold
25640 near
25641 \series default
25642 .
25643  Far selects large memory model's pointers, while near selects small memory
25644  model's pointers.
25645 \end_layout
25646
25647 \begin_layout Standard
25648 The standard device libraries (see
25649 \begin_inset LatexCommand \ref{sub:PIC16_Header-Files}
25650
25651 \end_inset
25652
25653 ) contain no reference to pointers, so they can be used with both memory
25654  models.
25655 \end_layout
25656
25657 \begin_layout Subsection
25658 Stack
25659 \end_layout
25660
25661 \begin_layout Standard
25662 The stack
25663 \begin_inset LatexCommand \index{PIC16!stack}
25664
25665 \end_inset
25666
25667  implementation for the PIC16 port uses two indirect registers, FSR1 and
25668  FSR2.
25669 \end_layout
25670
25671 \begin_layout Description
25672 FSR1 is assigned as stack pointer
25673 \end_layout
25674
25675 \begin_layout Description
25676 FSR2 is assigned as frame pointer
25677 \end_layout
25678
25679 \begin_layout Standard
25680 The following stack models are supported by the PIC16 port
25681 \end_layout
25682
25683 \begin_layout Itemize
25684
25685 \noun on
25686 small
25687 \noun default
25688  model
25689 \end_layout
25690
25691 \begin_layout Itemize
25692
25693 \noun on
25694 large
25695 \noun default
25696  model
25697 \end_layout
25698
25699 \begin_layout Standard
25700
25701 \noun on
25702 Small
25703 \noun default
25704  model means that only the FSRxL byte is used to access stack and frame,
25705  while
25706 \emph on
25707 \noun on
25708 large
25709 \emph default
25710 \noun default
25711  uses both FSRxL and FSRxH registers.
25712  The following table shows the stack/frame pointers sizes according to stack
25713  model and the maximum space they can address:
25714 \end_layout
25715
25716 \begin_layout Standard
25717 \align center
25718 \begin_inset Tabular
25719 <lyxtabular version="3" rows="3" columns="3">
25720 <features>
25721 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25722 <column alignment="center" valignment="top" leftline="true" width="0">
25723 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25724 <row topline="true" bottomline="true">
25725 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25726 \begin_inset Text
25727
25728 \begin_layout Standard
25729 Stack & Frame pointer sizes according to stack model
25730 \end_layout
25731
25732 \end_inset
25733 </cell>
25734 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25735 \begin_inset Text
25736
25737 \begin_layout Standard
25738 small
25739 \end_layout
25740
25741 \end_inset
25742 </cell>
25743 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25744 \begin_inset Text
25745
25746 \begin_layout Standard
25747 large
25748 \end_layout
25749
25750 \end_inset
25751 </cell>
25752 </row>
25753 <row topline="true">
25754 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25755 \begin_inset Text
25756
25757 \begin_layout Standard
25758 Stack pointer FSR1
25759 \end_layout
25760
25761 \end_inset
25762 </cell>
25763 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25764 \begin_inset Text
25765
25766 \begin_layout Standard
25767 8-bits
25768 \end_layout
25769
25770 \end_inset
25771 </cell>
25772 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25773 \begin_inset Text
25774
25775 \begin_layout Standard
25776 16-bits
25777 \end_layout
25778
25779 \end_inset
25780 </cell>
25781 </row>
25782 <row topline="true" bottomline="true">
25783 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25784 \begin_inset Text
25785
25786 \begin_layout Standard
25787 Frame pointer FSR2
25788 \end_layout
25789
25790 \end_inset
25791 </cell>
25792 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25793 \begin_inset Text
25794
25795 \begin_layout Standard
25796 8-bits
25797 \end_layout
25798
25799 \end_inset
25800 </cell>
25801 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25802 \begin_inset Text
25803
25804 \begin_layout Standard
25805 16-bits
25806 \end_layout
25807
25808 \end_inset
25809 </cell>
25810 </row>
25811 </lyxtabular>
25812
25813 \end_inset
25814
25815
25816 \end_layout
25817
25818 \begin_layout Standard
25819
25820 \noun on
25821 Large
25822 \noun default
25823 stack model is currently not working properly throughout the code generator.
25824  So its use is not advised.
25825  Also there are some other points that need special care:
25826 \newline
25827
25828 \end_layout
25829
25830 \begin_layout Enumerate
25831 Do not create stack sections with size more than one physical bank (that
25832  is 256 bytes)
25833 \end_layout
25834
25835 \begin_layout Enumerate
25836 Stack sections should no cross physical bank limits (i.e.
25837  #pragma stack 0x50 0x100)
25838 \end_layout
25839
25840 \begin_layout Standard
25841 These limitations are caused by the fact that only FSRxL is modified when
25842  using SMALL stack model, so no more than 256 bytes of stack can be used.
25843  This problem will disappear after LARGE model is fully implemented.
25844 \end_layout
25845
25846 \begin_layout Subsection
25847 Functions
25848 \end_layout
25849
25850 \begin_layout Standard
25851 In addition to the standard SDCC function keywords, PIC16
25852 \begin_inset LatexCommand \index{PIC16}
25853
25854 \end_inset
25855
25856  port makes available two more:
25857 \end_layout
25858
25859 \begin_layout Description
25860 wparam
25861 \begin_inset LatexCommand \index{PIC16!wparam}
25862
25863 \end_inset
25864
25865  Use the WREG to pass one byte of the first function argument.
25866  This improves speed but you may not use this for functions with arguments
25867  that are called via function pointers, otherwise the first byte of the
25868  first parameter will get lost.
25869  Usage:
25870 \end_layout
25871
25872 \begin_layout LyX-Code
25873 void func_wparam(int a) wparam
25874 \end_layout
25875
25876 \begin_layout LyX-Code
25877 {
25878 \end_layout
25879
25880 \begin_layout LyX-Code
25881     /* WREG hold the lower part of a */
25882 \end_layout
25883
25884 \begin_layout LyX-Code
25885     /* the high part of a is stored in FSR2+2 (or +3 for large stack model)
25886  */
25887 \end_layout
25888
25889 \begin_layout LyX-Code
25890 ...
25891 \end_layout
25892
25893 \begin_layout LyX-Code
25894 }
25895 \end_layout
25896
25897 \begin_layout Description
25898 shadowregs
25899 \begin_inset LatexCommand \index{PIC16!shadowregs}
25900
25901 \end_inset
25902
25903  When entering/exiting an ISR, it is possible to take advantage of the PIC18F
25904  hardware shadow registers which hold the values of WREG, STATUS and BSR
25905  registers.
25906  This can be done by adding the keyword
25907 \emph on
25908 shadowregs
25909 \emph default
25910  before the
25911 \emph on
25912 interrupt
25913 \emph default
25914  keyword in the function's header.
25915 \end_layout
25916
25917 \begin_layout LyX-Code
25918 void isr_shadow(void) shadowregs interrupt 1
25919 \end_layout
25920
25921 \begin_layout LyX-Code
25922 {
25923 \end_layout
25924
25925 \begin_layout LyX-Code
25926 ...
25927 \end_layout
25928
25929 \begin_layout LyX-Code
25930 }
25931 \end_layout
25932
25933 \begin_layout Standard
25934
25935 \emph on
25936 shadowregs
25937 \emph default
25938  instructs the code generator not to store/restore WREG, STATUS, BSR when
25939  entering/exiting the ISR.
25940 \end_layout
25941
25942 \begin_layout Subsection
25943 Function return values
25944 \end_layout
25945
25946 \begin_layout Standard
25947 Return values from functions are placed to the appropriate registers following
25948  a modified Microchip policy optimized for SDCC.
25949  The following table shows these registers:
25950 \end_layout
25951
25952 \begin_layout Standard
25953 \align center
25954 \begin_inset Tabular
25955 <lyxtabular version="3" rows="6" columns="2">
25956 <features>
25957 <column alignment="center" valignment="top" leftline="true" width="0">
25958 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25959 <row topline="true" bottomline="true">
25960 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25961 \begin_inset Text
25962
25963 \begin_layout Standard
25964 size
25965 \end_layout
25966
25967 \end_inset
25968 </cell>
25969 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25970 \begin_inset Text
25971
25972 \begin_layout Standard
25973 destination register
25974 \end_layout
25975
25976 \end_inset
25977 </cell>
25978 </row>
25979 <row topline="true">
25980 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25981 \begin_inset Text
25982
25983 \begin_layout Standard
25984 8 bits
25985 \end_layout
25986
25987 \end_inset
25988 </cell>
25989 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25990 \begin_inset Text
25991
25992 \begin_layout Standard
25993 WREG
25994 \end_layout
25995
25996 \end_inset
25997 </cell>
25998 </row>
25999 <row topline="true">
26000 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26001 \begin_inset Text
26002
26003 \begin_layout Standard
26004 16 bits
26005 \end_layout
26006
26007 \end_inset
26008 </cell>
26009 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26010 \begin_inset Text
26011
26012 \begin_layout Standard
26013 PRODL:WREG
26014 \end_layout
26015
26016 \end_inset
26017 </cell>
26018 </row>
26019 <row topline="true">
26020 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26021 \begin_inset Text
26022
26023 \begin_layout Standard
26024 24 bits
26025 \end_layout
26026
26027 \end_inset
26028 </cell>
26029 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26030 \begin_inset Text
26031
26032 \begin_layout Standard
26033 PRODH:PRODL:WREG
26034 \end_layout
26035
26036 \end_inset
26037 </cell>
26038 </row>
26039 <row topline="true">
26040 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26041 \begin_inset Text
26042
26043 \begin_layout Standard
26044 32 bits
26045 \end_layout
26046
26047 \end_inset
26048 </cell>
26049 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26050 \begin_inset Text
26051
26052 \begin_layout Standard
26053 FSR0L:PRODH:PRODL:WREG
26054 \end_layout
26055
26056 \end_inset
26057 </cell>
26058 </row>
26059 <row topline="true" bottomline="true">
26060 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26061 \begin_inset Text
26062
26063 \begin_layout Standard
26064 >32 bits
26065 \end_layout
26066
26067 \end_inset
26068 </cell>
26069 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26070 \begin_inset Text
26071
26072 \begin_layout Standard
26073 on stack, FSR0 points to the beginning
26074 \end_layout
26075
26076 \end_inset
26077 </cell>
26078 </row>
26079 </lyxtabular>
26080
26081 \end_inset
26082
26083
26084 \end_layout
26085
26086 \begin_layout Subsection
26087 Interrupts
26088 \end_layout
26089
26090 \begin_layout Standard
26091 An interrupt
26092 \begin_inset LatexCommand \index{PIC16!interrupt}
26093
26094 \end_inset
26095
26096  service routine (ISR) is declared using the
26097 \emph on
26098 interrupt
26099 \emph default
26100  keyword.
26101 \end_layout
26102
26103 \begin_layout LyX-Code
26104 void isr(void) interrupt
26105 \emph on
26106 n
26107 \end_layout
26108
26109 \begin_layout LyX-Code
26110 {
26111 \end_layout
26112
26113 \begin_layout LyX-Code
26114 ...
26115 \end_layout
26116
26117 \begin_layout LyX-Code
26118 }
26119 \end_layout
26120
26121 \begin_layout Standard
26122
26123 \emph on
26124 n
26125 \emph default
26126  is the interrupt number, which for PIC18F devices can be:
26127 \end_layout
26128
26129 \begin_layout Standard
26130 \align center
26131 \begin_inset Tabular
26132 <lyxtabular version="3" rows="4" columns="3">
26133 <features>
26134 <column alignment="center" valignment="top" leftline="true" width="0">
26135 <column alignment="center" valignment="top" leftline="true" width="0">
26136 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26137 <row topline="true" bottomline="true">
26138 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26139 \begin_inset Text
26140
26141 \begin_layout Standard
26142
26143 \emph on
26144 n
26145 \end_layout
26146
26147 \end_inset
26148 </cell>
26149 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26150 \begin_inset Text
26151
26152 \begin_layout Standard
26153 Interrupt Vector
26154 \end_layout
26155
26156 \end_inset
26157 </cell>
26158 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26159 \begin_inset Text
26160
26161 \begin_layout Standard
26162 Interrupt Vector Address
26163 \end_layout
26164
26165 \end_inset
26166 </cell>
26167 </row>
26168 <row topline="true">
26169 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26170 \begin_inset Text
26171
26172 \begin_layout Standard
26173 0
26174 \end_layout
26175
26176 \end_inset
26177 </cell>
26178 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26179 \begin_inset Text
26180
26181 \begin_layout Standard
26182 RESET vector
26183 \end_layout
26184
26185 \end_inset
26186 </cell>
26187 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26188 \begin_inset Text
26189
26190 \begin_layout Standard
26191 0x000000
26192 \end_layout
26193
26194 \end_inset
26195 </cell>
26196 </row>
26197 <row topline="true">
26198 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26199 \begin_inset Text
26200
26201 \begin_layout Standard
26202
26203 \family roman
26204 \series medium
26205 \shape up
26206 \size normal
26207 \emph off
26208 \bar no
26209 \noun off
26210 \color none
26211 1
26212 \end_layout
26213
26214 \end_inset
26215 </cell>
26216 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26217 \begin_inset Text
26218
26219 \begin_layout Standard
26220
26221 \family roman
26222 \series medium
26223 \shape up
26224 \size normal
26225 \emph off
26226 \bar no
26227 \noun off
26228 \color none
26229 HIGH priority interrupts
26230 \end_layout
26231
26232 \end_inset
26233 </cell>
26234 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26235 \begin_inset Text
26236
26237 \begin_layout Standard
26238 0x000008
26239 \end_layout
26240
26241 \end_inset
26242 </cell>
26243 </row>
26244 <row topline="true" bottomline="true">
26245 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26246 \begin_inset Text
26247
26248 \begin_layout Standard
26249 2
26250 \end_layout
26251
26252 \end_inset
26253 </cell>
26254 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26255 \begin_inset Text
26256
26257 \begin_layout Standard
26258 LOW priority interrupts
26259 \end_layout
26260
26261 \end_inset
26262 </cell>
26263 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26264 \begin_inset Text
26265
26266 \begin_layout Standard
26267 0x000018
26268 \end_layout
26269
26270 \end_inset
26271 </cell>
26272 </row>
26273 </lyxtabular>
26274
26275 \end_inset
26276
26277
26278 \end_layout
26279
26280 \begin_layout Standard
26281 When generating assembly code for ISR the code generator places a
26282 \noun on
26283 goto
26284 \noun default
26285 instruction at the
26286 \emph on
26287 Interrupt Vector Address
26288 \emph default
26289  which points at the genetated ISR.
26290  This single GOTO instruction is part of an automatically generated
26291 \emph on
26292 interrupt entry point
26293 \emph default
26294  function.
26295  The actuall ISR code is placed as normally would in the code space.
26296  Upon interrupt request, the GOTO instruction is executed which jumps to
26297  the ISR code.
26298  When declaring interrupt functions as _naked this GOTO instruction is
26299 \series bold
26300 not
26301 \series default
26302  generated.
26303  The whole interrupt functions is therefore placed at the Interrupt Vector
26304  Address of the specific interrupt.
26305  This is not a problem for the LOW priority interrupts, but it is a problem
26306  for the RESET and the HIGH priority interrupts because code may be written
26307  at the next interrupt's vector address and cause undeterminate program
26308  behaviour if that interrupt is raised.
26309 \begin_inset Foot
26310 status open
26311
26312 \begin_layout Standard
26313 This is not a problem when
26314 \end_layout
26315
26316 \begin_layout Enumerate
26317 this is a HIGH interrupt ISR and LOW interrupts are
26318 \emph on
26319 disabled
26320 \emph default
26321  or not used.
26322 \end_layout
26323
26324 \begin_layout Enumerate
26325 when the ISR is small enough not to reach the next interrupt's vector address.
26326 \end_layout
26327
26328 \end_inset
26329
26330
26331 \end_layout
26332
26333 \begin_layout Standard
26334
26335 \emph on
26336 n
26337 \emph default
26338  may be omitted.
26339  This way a function is generated similar to an ISR, but it is not assigned
26340  to any interrupt.
26341 \end_layout
26342
26343 \begin_layout Standard
26344 When entering an interrupt, currently the PIC16
26345 \begin_inset LatexCommand \index{PIC16}
26346
26347 \end_inset
26348
26349  port automatically saves the following registers:
26350 \end_layout
26351
26352 \begin_layout Itemize
26353 WREG
26354 \end_layout
26355
26356 \begin_layout Itemize
26357 STATUS
26358 \end_layout
26359
26360 \begin_layout Itemize
26361 BSR
26362 \end_layout
26363
26364 \begin_layout Itemize
26365 PROD (PRODL and PRODH)
26366 \end_layout
26367
26368 \begin_layout Itemize
26369 FSR0 (FSR0L and FSR0H)
26370 \end_layout
26371
26372 \begin_layout Standard
26373 These registers are restored upon return from the interrupt routine.
26374 \begin_inset Foot
26375 status open
26376
26377 \begin_layout Standard
26378 NOTE that when the _naked attribute is specified for an interrupt routine,
26379  then NO registers are stored or restored.
26380 \end_layout
26381
26382 \end_inset
26383
26384
26385 \end_layout
26386
26387 \begin_layout Subsection
26388 Generic Pointers
26389 \end_layout
26390
26391 \begin_layout Standard
26392 Generic pointers are implemented in PIC16 port as 3-byte (24-bit) types.
26393  There are 3 types of generic pointers currently implemented data, code
26394  and eeprom pointers.
26395  They are differentiated by the value of the 7th and 6th bits of the upper
26396  byte:
26397 \end_layout
26398
26399 \begin_layout Standard
26400 \align center
26401 \begin_inset Tabular
26402 <lyxtabular version="3" rows="5" columns="5">
26403 <features>
26404 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26405 <column alignment="center" valignment="top" width="0">
26406 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26407 <column alignment="center" valignment="top" width="0">
26408 <column alignment="left" valignment="top" rightline="true" width="0">
26409 <row topline="true" bottomline="true">
26410 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26411 \begin_inset Text
26412
26413 \begin_layout Standard
26414 pointer type
26415 \end_layout
26416
26417 \end_inset
26418 </cell>
26419 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26420 \begin_inset Text
26421
26422 \begin_layout Standard
26423 7th bit
26424 \end_layout
26425
26426 \end_inset
26427 </cell>
26428 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26429 \begin_inset Text
26430
26431 \begin_layout Standard
26432 6th bit
26433 \end_layout
26434
26435 \end_inset
26436 </cell>
26437 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26438 \begin_inset Text
26439
26440 \begin_layout Standard
26441 rest of the pointer
26442 \end_layout
26443
26444 \end_inset
26445 </cell>
26446 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26447 \begin_inset Text
26448
26449 \begin_layout Standard
26450 description
26451 \end_layout
26452
26453 \end_inset
26454 </cell>
26455 </row>
26456 <row topline="true" bottomline="true">
26457 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26458 \begin_inset Text
26459
26460 \begin_layout Standard
26461 data
26462 \end_layout
26463
26464 \end_inset
26465 </cell>
26466 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26467 \begin_inset Text
26468
26469 \begin_layout Standard
26470 1
26471 \end_layout
26472
26473 \end_inset
26474 </cell>
26475 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26476 \begin_inset Text
26477
26478 \begin_layout Standard
26479 0
26480 \end_layout
26481
26482 \end_inset
26483 </cell>
26484 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26485 \begin_inset Text
26486
26487 \begin_layout Standard
26488
26489 \family typewriter
26490 \shape slanted
26491 \emph on
26492 uuuuuu uuuuxxxx xxxxxxxx
26493 \end_layout
26494
26495 \end_inset
26496 </cell>
26497 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26498 \begin_inset Text
26499
26500 \begin_layout Standard
26501 a 12-bit data pointer in data RAM memory
26502 \end_layout
26503
26504 \end_inset
26505 </cell>
26506 </row>
26507 <row bottomline="true">
26508 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26509 \begin_inset Text
26510
26511 \begin_layout Standard
26512 code
26513 \end_layout
26514
26515 \end_inset
26516 </cell>
26517 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26518 \begin_inset Text
26519
26520 \begin_layout Standard
26521 0
26522 \end_layout
26523
26524 \end_inset
26525 </cell>
26526 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26527 \begin_inset Text
26528
26529 \begin_layout Standard
26530 0
26531 \end_layout
26532
26533 \end_inset
26534 </cell>
26535 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26536 \begin_inset Text
26537
26538 \begin_layout Standard
26539
26540 \family typewriter
26541 \shape slanted
26542 \emph on
26543 uxxxxx xxxxxxxx xxxxxxxx
26544 \end_layout
26545
26546 \end_inset
26547 </cell>
26548 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26549 \begin_inset Text
26550
26551 \begin_layout Standard
26552 a 21-bit code pointer in FLASH memory
26553 \end_layout
26554
26555 \end_inset
26556 </cell>
26557 </row>
26558 <row bottomline="true">
26559 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26560 \begin_inset Text
26561
26562 \begin_layout Standard
26563 eeprom
26564 \end_layout
26565
26566 \end_inset
26567 </cell>
26568 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26569 \begin_inset Text
26570
26571 \begin_layout Standard
26572 0
26573 \end_layout
26574
26575 \end_inset
26576 </cell>
26577 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26578 \begin_inset Text
26579
26580 \begin_layout Standard
26581 1
26582 \end_layout
26583
26584 \end_inset
26585 </cell>
26586 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26587 \begin_inset Text
26588
26589 \begin_layout Standard
26590
26591 \family typewriter
26592 \shape slanted
26593 \emph on
26594 uuuuuu uuuuuuxx xxxxxxxx
26595 \end_layout
26596
26597 \end_inset
26598 </cell>
26599 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26600 \begin_inset Text
26601
26602 \begin_layout Standard
26603 a 10-bit eeprom pointer in EEPROM memory
26604 \end_layout
26605
26606 \end_inset
26607 </cell>
26608 </row>
26609 <row bottomline="true">
26610 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26611 \begin_inset Text
26612
26613 \begin_layout Standard
26614 (unimplemented)
26615 \end_layout
26616
26617 \end_inset
26618 </cell>
26619 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26620 \begin_inset Text
26621
26622 \begin_layout Standard
26623 1
26624 \end_layout
26625
26626 \end_inset
26627 </cell>
26628 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26629 \begin_inset Text
26630
26631 \begin_layout Standard
26632 1
26633 \end_layout
26634
26635 \end_inset
26636 </cell>
26637 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26638 \begin_inset Text
26639
26640 \begin_layout Standard
26641
26642 \family typewriter
26643 \shape slanted
26644 \emph on
26645 xxxxxx xxxxxxxx xxxxxxxx
26646 \end_layout
26647
26648 \end_inset
26649 </cell>
26650 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26651 \begin_inset Text
26652
26653 \begin_layout Standard
26654 unimplemented pointer type
26655 \end_layout
26656
26657 \end_inset
26658 </cell>
26659 </row>
26660 </lyxtabular>
26661
26662 \end_inset
26663
26664
26665 \end_layout
26666
26667 \begin_layout Standard
26668 Generic pointer are read and written with a set of library functions which
26669  read/write 1, 2, 3, 4 bytes.
26670 \end_layout
26671
26672 \begin_layout Subsection
26673 PIC16 C Libraries
26674 \end_layout
26675
26676 \begin_layout Subsubsection
26677 Standard I/O Streams
26678 \end_layout
26679
26680 \begin_layout Standard
26681 In the
26682 \emph on
26683 stdio.h
26684 \emph default
26685  the type FILE is defined as:
26686 \end_layout
26687
26688 \begin_layout LyX-Code
26689 typedef char * FILE;
26690 \end_layout
26691
26692 \begin_layout Standard
26693 This type is the stream type implemented I/O in the PIC18F devices.
26694  Also the standard input and output streams are declared in stdio.h:
26695 \end_layout
26696
26697 \begin_layout LyX-Code
26698 extern FILE * stdin;
26699 \end_layout
26700
26701 \begin_layout LyX-Code
26702 extern FILE * stdout;
26703 \end_layout
26704
26705 \begin_layout Standard
26706 The FILE type is actually a generic pointer which defines one more type
26707  of generic pointers, the
26708 \emph on
26709 stream
26710 \emph default
26711 pointer.
26712  This new type has the format:
26713 \end_layout
26714
26715 \begin_layout Standard
26716 \align center
26717 \begin_inset Tabular
26718 <lyxtabular version="3" rows="2" columns="7">
26719 <features>
26720 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26721 <column alignment="center" valignment="top" width="0">
26722 <column alignment="center" valignment="top" leftline="true" width="0">
26723 <column alignment="center" valignment="top" leftline="true" width="0">
26724 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26725 <column alignment="center" valignment="top" width="0">
26726 <column alignment="left" valignment="top" rightline="true" width="0">
26727 <row topline="true" bottomline="true">
26728 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26729 \begin_inset Text
26730
26731 \begin_layout Standard
26732 pointer type
26733 \end_layout
26734
26735 \end_inset
26736 </cell>
26737 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26738 \begin_inset Text
26739
26740 \begin_layout Standard
26741 <7:6>
26742 \end_layout
26743
26744 \end_inset
26745 </cell>
26746 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26747 \begin_inset Text
26748
26749 \begin_layout Standard
26750 <5>
26751 \end_layout
26752
26753 \end_inset
26754 </cell>
26755 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26756 \begin_inset Text
26757
26758 \begin_layout Standard
26759 <4>
26760 \end_layout
26761
26762 \end_inset
26763 </cell>
26764 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26765 \begin_inset Text
26766
26767 \begin_layout Standard
26768 <3:0>
26769 \end_layout
26770
26771 \end_inset
26772 </cell>
26773 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26774 \begin_inset Text
26775
26776 \begin_layout Standard
26777 rest of the pointer
26778 \end_layout
26779
26780 \end_inset
26781 </cell>
26782 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26783 \begin_inset Text
26784
26785 \begin_layout Standard
26786 descrption
26787 \end_layout
26788
26789 \end_inset
26790 </cell>
26791 </row>
26792 <row topline="true" bottomline="true">
26793 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26794 \begin_inset Text
26795
26796 \begin_layout Standard
26797 stream
26798 \end_layout
26799
26800 \end_inset
26801 </cell>
26802 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26803 \begin_inset Text
26804
26805 \begin_layout Standard
26806 00
26807 \end_layout
26808
26809 \end_inset
26810 </cell>
26811 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26812 \begin_inset Text
26813
26814 \begin_layout Standard
26815 1
26816 \end_layout
26817
26818 \end_inset
26819 </cell>
26820 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26821 \begin_inset Text
26822
26823 \begin_layout Standard
26824 0
26825 \end_layout
26826
26827 \end_inset
26828 </cell>
26829 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26830 \begin_inset Text
26831
26832 \begin_layout Standard
26833 nnnn
26834 \end_layout
26835
26836 \end_inset
26837 </cell>
26838 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26839 \begin_inset Text
26840
26841 \begin_layout Standard
26842
26843 \family typewriter
26844 \shape slanted
26845 \emph on
26846 uuuuuuuu uuuuuuuu
26847 \end_layout
26848
26849 \end_inset
26850 </cell>
26851 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26852 \begin_inset Text
26853
26854 \begin_layout Standard
26855 upper byte high nubble is 0x2n, the rest are zeroes
26856 \end_layout
26857
26858 \end_inset
26859 </cell>
26860 </row>
26861 </lyxtabular>
26862
26863 \end_inset
26864
26865
26866 \end_layout
26867
26868 \begin_layout Standard
26869 Currently implemented there are 3 types of streams defined:
26870 \end_layout
26871
26872 \begin_layout Standard
26873 \align center
26874 \begin_inset Tabular
26875 <lyxtabular version="3" rows="4" columns="4">
26876 <features>
26877 <column alignment="center" valignment="top" leftline="true" width="0">
26878 <column alignment="center" valignment="top" leftline="true" width="0">
26879 <column alignment="center" valignment="top" leftline="true" width="0">
26880 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26881 <row topline="true" bottomline="true">
26882 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26883 \begin_inset Text
26884
26885 \begin_layout Standard
26886 stream type
26887 \end_layout
26888
26889 \end_inset
26890 </cell>
26891 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26892 \begin_inset Text
26893
26894 \begin_layout Standard
26895 value
26896 \end_layout
26897
26898 \end_inset
26899 </cell>
26900 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26901 \begin_inset Text
26902
26903 \begin_layout Standard
26904 module
26905 \end_layout
26906
26907 \end_inset
26908 </cell>
26909 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26910 \begin_inset Text
26911
26912 \begin_layout Standard
26913 description
26914 \end_layout
26915
26916 \end_inset
26917 </cell>
26918 </row>
26919 <row topline="true">
26920 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26921 \begin_inset Text
26922
26923 \begin_layout Standard
26924 STREAM_USART
26925 \end_layout
26926
26927 \end_inset
26928 </cell>
26929 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26930 \begin_inset Text
26931
26932 \begin_layout Standard
26933
26934 \family typewriter
26935 0x200000UL
26936 \end_layout
26937
26938 \end_inset
26939 </cell>
26940 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26941 \begin_inset Text
26942
26943 \begin_layout Standard
26944 USART
26945 \end_layout
26946
26947 \end_inset
26948 </cell>
26949 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26950 \begin_inset Text
26951
26952 \begin_layout Standard
26953 Writes/Reads characters via the USART peripheral
26954 \end_layout
26955
26956 \end_inset
26957 </cell>
26958 </row>
26959 <row topline="true">
26960 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26961 \begin_inset Text
26962
26963 \begin_layout Standard
26964 STREAM_MSSP
26965 \end_layout
26966
26967 \end_inset
26968 </cell>
26969 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26970 \begin_inset Text
26971
26972 \begin_layout Standard
26973
26974 \family typewriter
26975 0x210000UL
26976 \end_layout
26977
26978 \end_inset
26979 </cell>
26980 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26981 \begin_inset Text
26982
26983 \begin_layout Standard
26984 MSSP
26985 \end_layout
26986
26987 \end_inset
26988 </cell>
26989 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26990 \begin_inset Text
26991
26992 \begin_layout Standard
26993 Writes/Reads characters via the MSSP peripheral
26994 \end_layout
26995
26996 \end_inset
26997 </cell>
26998 </row>
26999 <row topline="true" bottomline="true">
27000 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27001 \begin_inset Text
27002
27003 \begin_layout Standard
27004 STREAM_USER
27005 \end_layout
27006
27007 \end_inset
27008 </cell>
27009 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27010 \begin_inset Text
27011
27012 \begin_layout Standard
27013
27014 \family typewriter
27015 0x2f0000UL
27016 \end_layout
27017
27018 \end_inset
27019 </cell>
27020 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27021 \begin_inset Text
27022
27023 \begin_layout Standard
27024 (none)
27025 \end_layout
27026
27027 \end_inset
27028 </cell>
27029 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27030 \begin_inset Text
27031
27032 \begin_layout Standard
27033 Writes/Reads characters via used defined functions
27034 \end_layout
27035
27036 \end_inset
27037 </cell>
27038 </row>
27039 </lyxtabular>
27040
27041 \end_inset
27042
27043
27044 \end_layout
27045
27046 \begin_layout Standard
27047 The stream identifiers are declared as macros in the stdio.h header.
27048 \end_layout
27049
27050 \begin_layout Standard
27051 In the libc library there exist the functions that are used to write to
27052  each of the above streams.
27053  These are
27054 \end_layout
27055
27056 \begin_layout Description
27057 _
27058 \begin_inset ERT
27059 status collapsed
27060
27061 \begin_layout Standard
27062
27063
27064 \backslash
27065 /
27066 \end_layout
27067
27068 \end_inset
27069
27070 _stream_usart_putchar writes a character at the USART stream
27071 \end_layout
27072
27073 \begin_layout Description
27074 _
27075 \begin_inset ERT
27076 status collapsed
27077
27078 \begin_layout Standard
27079
27080
27081 \backslash
27082 /
27083 \end_layout
27084
27085 \end_inset
27086
27087 _stream_mssp_putchar writes a character at the MSSP stream
27088 \end_layout
27089
27090 \begin_layout Description
27091 putchar dummy function.
27092  This writes a character to a user specified manner.
27093 \end_layout
27094
27095 \begin_layout Standard
27096 In order to increase performance
27097 \emph on
27098 putchar
27099 \emph default
27100 is declared in stdio.h as having its parameter in WREG (it has the wparam
27101  keyword).
27102  In stdio.h exists the macro PUTCHAR(arg) that defines the putchar function
27103  in a user-friendly way.
27104 \emph on
27105 arg
27106 \emph default
27107  is the name of the variable that holds the character to print.
27108  An example follows:
27109 \end_layout
27110
27111 \begin_layout LyX-Code
27112 #include <pic18fregs.h>
27113 \newline
27114 #include <stdio.h>
27115 \newline
27116
27117 \newline
27118 PUTCHAR( c )
27119 \end_layout
27120
27121 \begin_layout LyX-Code
27122 {
27123 \end_layout
27124
27125 \begin_layout LyX-Code
27126     PORTA = c;    /* dump character c to PORTA */
27127 \end_layout
27128
27129 \begin_layout LyX-Code
27130 }
27131 \newline
27132
27133 \newline
27134 void main(void)
27135 \end_layout
27136
27137 \begin_layout LyX-Code
27138 {
27139 \end_layout
27140
27141 \begin_layout LyX-Code
27142     stdout = STREAM_USER;    /* this is not necessary, since stdout points
27143 \end_layout
27144
27145 \begin_layout LyX-Code
27146                               * by default to STREAM_USER */
27147 \end_layout
27148
27149 \begin_layout LyX-Code
27150     printf (
27151 \begin_inset Quotes sld
27152 \end_inset
27153
27154 This is a printf test
27155 \backslash
27156 n
27157 \begin_inset Quotes srd
27158 \end_inset
27159
27160 );
27161 \end_layout
27162
27163 \begin_layout LyX-Code
27164 }
27165 \end_layout
27166
27167 \begin_layout LyX-Code
27168
27169 \end_layout
27170
27171 \begin_layout Subsubsection
27172 Printing functions
27173 \end_layout
27174
27175 \begin_layout Standard
27176 PIC16 contains an implementation of the printf-family of functions.
27177  There exist the following functions:
27178 \end_layout
27179
27180 \begin_layout LyX-Code
27181 extern unsigned int sprintf(char *buf, char *fmt, ...);
27182 \end_layout
27183
27184 \begin_layout LyX-Code
27185 extern unsigned int vsprintf(char *buf, char *fmt, va_list ap);
27186 \end_layout
27187
27188 \begin_layout LyX-Code
27189
27190 \end_layout
27191
27192 \begin_layout LyX-Code
27193 extern unsigned int printf(char *fmt, ...);
27194 \end_layout
27195
27196 \begin_layout LyX-Code
27197 extern unsigned int vprintf(char *fmt, va_lista ap);
27198 \end_layout
27199
27200 \begin_layout LyX-Code
27201
27202 \end_layout
27203
27204 \begin_layout LyX-Code
27205 extern unsigned int fprintf(FILE *fp, char *fmt, ...);
27206 \end_layout
27207
27208 \begin_layout LyX-Code
27209 extern unsigned int vfprintf(FILE *fp, char *fmt, va_list ap);
27210 \end_layout
27211
27212 \begin_layout Standard
27213 For sprintf and vsprintf
27214 \emph on
27215 buf
27216 \emph default
27217 should normally be a data pointer where the resulting string will be placed.
27218  No range checking is done so the user should allocate the necessery buffer.
27219  For fprintf and vfprintf
27220 \emph on
27221 fp
27222 \emph default
27223  should be a stream pointer (i.e.
27224  stdout, STREAM_MSSP, etc...).
27225 \end_layout
27226
27227 \begin_layout Subsubsection
27228 Signals
27229 \end_layout
27230
27231 \begin_layout Standard
27232 The PIC18F family of microcontrollers supports a number of interrupt sources.
27233  A list of these interrupts is shown in the following table:
27234 \end_layout
27235
27236 \begin_layout Standard
27237 \align center
27238 \begin_inset Tabular
27239 <lyxtabular version="3" rows="11" columns="4">
27240 <features>
27241 <column alignment="left" valignment="top" leftline="true" width="0">
27242 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27243 <column alignment="left" valignment="top" leftline="true" width="0">
27244 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27245 <row topline="true" bottomline="true">
27246 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27247 \begin_inset Text
27248
27249 \begin_layout Standard
27250 signal name
27251 \end_layout
27252
27253 \end_inset
27254 </cell>
27255 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27256 \begin_inset Text
27257
27258 \begin_layout Standard
27259 description
27260 \end_layout
27261
27262 \end_inset
27263 </cell>
27264 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27265 \begin_inset Text
27266
27267 \begin_layout Standard
27268 signal name
27269 \end_layout
27270
27271 \end_inset
27272 </cell>
27273 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27274 \begin_inset Text
27275
27276 \begin_layout Standard
27277 descritpion
27278 \end_layout
27279
27280 \end_inset
27281 </cell>
27282 </row>
27283 <row topline="true">
27284 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27285 \begin_inset Text
27286
27287 \begin_layout Standard
27288 SIG_RB
27289 \end_layout
27290
27291 \end_inset
27292 </cell>
27293 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27294 \begin_inset Text
27295
27296 \begin_layout Standard
27297 PORTB change interrupt
27298 \end_layout
27299
27300 \end_inset
27301 </cell>
27302 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27303 \begin_inset Text
27304
27305 \begin_layout Standard
27306 SIG_EE
27307 \end_layout
27308
27309 \end_inset
27310 </cell>
27311 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27312 \begin_inset Text
27313
27314 \begin_layout Standard
27315 EEPROM/FLASH write complete interrupt
27316 \end_layout
27317
27318 \end_inset
27319 </cell>
27320 </row>
27321 <row topline="true">
27322 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27323 \begin_inset Text
27324
27325 \begin_layout Standard
27326 SIG_INT0
27327 \end_layout
27328
27329 \end_inset
27330 </cell>
27331 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27332 \begin_inset Text
27333
27334 \begin_layout Standard
27335 INT0 external interrupt
27336 \end_layout
27337
27338 \end_inset
27339 </cell>
27340 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27341 \begin_inset Text
27342
27343 \begin_layout Standard
27344 SIG_BCOL
27345 \end_layout
27346
27347 \end_inset
27348 </cell>
27349 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27350 \begin_inset Text
27351
27352 \begin_layout Standard
27353 Bus collision interrupt
27354 \end_layout
27355
27356 \end_inset
27357 </cell>
27358 </row>
27359 <row topline="true">
27360 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27361 \begin_inset Text
27362
27363 \begin_layout Standard
27364 SIG_INT1
27365 \end_layout
27366
27367 \end_inset
27368 </cell>
27369 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27370 \begin_inset Text
27371
27372 \begin_layout Standard
27373 INT1 external interrupt
27374 \end_layout
27375
27376 \end_inset
27377 </cell>
27378 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27379 \begin_inset Text
27380
27381 \begin_layout Standard
27382 SIG_LVD
27383 \end_layout
27384
27385 \end_inset
27386 </cell>
27387 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27388 \begin_inset Text
27389
27390 \begin_layout Standard
27391 Low voltage detect interrupt
27392 \end_layout
27393
27394 \end_inset
27395 </cell>
27396 </row>
27397 <row topline="true">
27398 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27399 \begin_inset Text
27400
27401 \begin_layout Standard
27402 SIG_INT2
27403 \end_layout
27404
27405 \end_inset
27406 </cell>
27407 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27408 \begin_inset Text
27409
27410 \begin_layout Standard
27411 INT2 external interrupt
27412 \end_layout
27413
27414 \end_inset
27415 </cell>
27416 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27417 \begin_inset Text
27418
27419 \begin_layout Standard
27420 SIG_PSP
27421 \end_layout
27422
27423 \end_inset
27424 </cell>
27425 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27426 \begin_inset Text
27427
27428 \begin_layout Standard
27429 Parallel slave port interrupt
27430 \end_layout
27431
27432 \end_inset
27433 </cell>
27434 </row>
27435 <row topline="true">
27436 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27437 \begin_inset Text
27438
27439 \begin_layout Standard
27440 SIG_CCP1
27441 \end_layout
27442
27443 \end_inset
27444 </cell>
27445 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27446 \begin_inset Text
27447
27448 \begin_layout Standard
27449 CCP1 module interrupt
27450 \end_layout
27451
27452 \end_inset
27453 </cell>
27454 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27455 \begin_inset Text
27456
27457 \begin_layout Standard
27458 SIG_AD
27459 \end_layout
27460
27461 \end_inset
27462 </cell>
27463 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27464 \begin_inset Text
27465
27466 \begin_layout Standard
27467 AD convertion complete interrupt
27468 \end_layout
27469
27470 \end_inset
27471 </cell>
27472 </row>
27473 <row topline="true">
27474 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27475 \begin_inset Text
27476
27477 \begin_layout Standard
27478 SIG_CCP2
27479 \end_layout
27480
27481 \end_inset
27482 </cell>
27483 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27484 \begin_inset Text
27485
27486 \begin_layout Standard
27487 CCP2 module interrupt
27488 \end_layout
27489
27490 \end_inset
27491 </cell>
27492 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27493 \begin_inset Text
27494
27495 \begin_layout Standard
27496 SIG_RC
27497 \end_layout
27498
27499 \end_inset
27500 </cell>
27501 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27502 \begin_inset Text
27503
27504 \begin_layout Standard
27505 USART receive interrupt
27506 \end_layout
27507
27508 \end_inset
27509 </cell>
27510 </row>
27511 <row topline="true">
27512 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27513 \begin_inset Text
27514
27515 \begin_layout Standard
27516 SIG_TMR0
27517 \end_layout
27518
27519 \end_inset
27520 </cell>
27521 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27522 \begin_inset Text
27523
27524 \begin_layout Standard
27525 TMR0 overflow interrupt
27526 \end_layout
27527
27528 \end_inset
27529 </cell>
27530 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27531 \begin_inset Text
27532
27533 \begin_layout Standard
27534 SIG_TX
27535 \end_layout
27536
27537 \end_inset
27538 </cell>
27539 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27540 \begin_inset Text
27541
27542 \begin_layout Standard
27543 USART transmit interrupt
27544 \end_layout
27545
27546 \end_inset
27547 </cell>
27548 </row>
27549 <row topline="true">
27550 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27551 \begin_inset Text
27552
27553 \begin_layout Standard
27554 SIG_TMR1
27555 \end_layout
27556
27557 \end_inset
27558 </cell>
27559 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27560 \begin_inset Text
27561
27562 \begin_layout Standard
27563 TMR1 overflow interrupt
27564 \end_layout
27565
27566 \end_inset
27567 </cell>
27568 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27569 \begin_inset Text
27570
27571 \begin_layout Standard
27572 SIG_MSSP
27573 \end_layout
27574
27575 \end_inset
27576 </cell>
27577 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27578 \begin_inset Text
27579
27580 \begin_layout Standard
27581 SSP receive/transmit interrupt
27582 \end_layout
27583
27584 \end_inset
27585 </cell>
27586 </row>
27587 <row topline="true">
27588 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27589 \begin_inset Text
27590
27591 \begin_layout Standard
27592 SIG_TMR2
27593 \end_layout
27594
27595 \end_inset
27596 </cell>
27597 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27598 \begin_inset Text
27599
27600 \begin_layout Standard
27601 TMR2 matches PR2 interrupt
27602 \end_layout
27603
27604 \end_inset
27605 </cell>
27606 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27607 \begin_inset Text
27608
27609 \begin_layout Standard
27610
27611 \end_layout
27612
27613 \end_inset
27614 </cell>
27615 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27616 \begin_inset Text
27617
27618 \begin_layout Standard
27619
27620 \end_layout
27621
27622 \end_inset
27623 </cell>
27624 </row>
27625 <row topline="true" bottomline="true">
27626 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27627 \begin_inset Text
27628
27629 \begin_layout Standard
27630 SIG_TMR3
27631 \end_layout
27632
27633 \end_inset
27634 </cell>
27635 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27636 \begin_inset Text
27637
27638 \begin_layout Standard
27639 TMR3 overflow interrupt
27640 \end_layout
27641
27642 \end_inset
27643 </cell>
27644 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27645 \begin_inset Text
27646
27647 \begin_layout Standard
27648
27649 \end_layout
27650
27651 \end_inset
27652 </cell>
27653 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27654 \begin_inset Text
27655
27656 \begin_layout Standard
27657
27658 \end_layout
27659
27660 \end_inset
27661 </cell>
27662 </row>
27663 </lyxtabular>
27664
27665 \end_inset
27666
27667
27668 \end_layout
27669
27670 \begin_layout Standard
27671 The prototypes for these names are defined in the header file
27672 \emph on
27673 signal.h
27674 \emph default
27675  .
27676 \end_layout
27677
27678 \begin_layout Standard
27679 In order to simplify signal handling, a number of macros is provided:
27680 \end_layout
27681
27682 \begin_layout List
27683 \labelwidthstring 00.00.0000
27684 DEF_INTHIGH(name) begin the definition of the interrupt dispatch table for
27685  high priority interrupts.
27686 \emph on
27687 name
27688 \emph default
27689  is the function name to use.
27690 \end_layout
27691
27692 \begin_layout List
27693 \labelwidthstring 00.00.0000
27694 DEF_INTLOW(name) begin the definition of the interrupt dispatch table fo
27695  low priority interrupt.
27696 \emph on
27697 name
27698 \emph default
27699  is the function name to use.
27700 \end_layout
27701
27702 \begin_layout List
27703 \labelwidthstring 00.00.0000
27704 DEF_HANDLER(sig,handler) define a handler for signal
27705 \emph on
27706 sig.
27707 \end_layout
27708
27709 \begin_layout List
27710 \labelwidthstring 00.00.0000
27711 END_DEF end the declaration of the dispatch table.
27712 \end_layout
27713
27714 \begin_layout Standard
27715 Additionally there are two more macros to simplify the declaration of the
27716  signal handler:
27717 \end_layout
27718
27719 \begin_layout List
27720 \labelwidthstring 00.00.0000
27721
27722 \series medium
27723 SIGHANDLER(handler)
27724 \series default
27725 this declares the function prototype for the
27726 \emph on
27727 handler
27728 \emph default
27729  function.
27730 \end_layout
27731
27732 \begin_layout List
27733 \labelwidthstring 00.00.0000
27734 SIGHANDLERNAKED(handler) same as SIGHANDLER() but declares a naked function.
27735 \end_layout
27736
27737 \begin_layout Standard
27738 An example of using the macros above is shown below:
27739 \end_layout
27740
27741 \begin_layout LyX-Code
27742 #include <pic18fregs.h>
27743 \end_layout
27744
27745 \begin_layout LyX-Code
27746 #include <signal.h>
27747 \newline
27748
27749 \newline
27750 DEF_INTHIGH(high_int)
27751 \end_layout
27752
27753 \begin_layout LyX-Code
27754 DEF_HANDLER(SIG_TMR0, _tmr0_handler)
27755 \end_layout
27756
27757 \begin_layout LyX-Code
27758 DEF_HANDLER(SIG_BCOL, _bcol_handler)
27759 \end_layout
27760
27761 \begin_layout LyX-Code
27762 END_DEF
27763 \newline
27764
27765 \newline
27766 SIGHANDLER(_tmr0_handler)
27767 \end_layout
27768
27769 \begin_layout LyX-Code
27770 {
27771 \end_layout
27772
27773 \begin_layout LyX-Code
27774   /* action to be taken when timer 0 overflows */
27775 \end_layout
27776
27777 \begin_layout LyX-Code
27778 }
27779 \newline
27780
27781 \newline
27782 SIGHANDLERNAKED(_bcol_handler)
27783 \end_layout
27784
27785 \begin_layout LyX-Code
27786 {
27787 \end_layout
27788
27789 \begin_layout LyX-Code
27790   _asm
27791 \end_layout
27792
27793 \begin_layout LyX-Code
27794     /* action to be taken when bus collision occurs */
27795 \end_layout
27796
27797 \begin_layout LyX-Code
27798     retfie
27799 \end_layout
27800
27801 \begin_layout LyX-Code
27802  _endasm;
27803 \end_layout
27804
27805 \begin_layout LyX-Code
27806 }
27807 \end_layout
27808
27809 \begin_layout Standard
27810
27811 \series bold
27812 NOTES:
27813 \series default
27814  Special care should be taken when using the above scheme:
27815 \end_layout
27816
27817 \begin_layout Itemize
27818 do not place a colon (;) at the end of the DEF_* and END_DEF macros.
27819 \end_layout
27820
27821 \begin_layout Itemize
27822 when declaring SIGHANDLERNAKED handler never forget to use
27823 \emph on
27824 retfie
27825 \emph default
27826  for proper returning.
27827 \end_layout
27828
27829 \begin_layout Subsection
27830 PIC16 Port -- Tips
27831 \end_layout
27832
27833 \begin_layout Standard
27834 Here you can find some general tips for compiling programs with SDCC/pic16.
27835 \end_layout
27836
27837 \begin_layout Subsubsection
27838 Stack size
27839 \end_layout
27840
27841 \begin_layout Standard
27842 The default stack
27843 \begin_inset LatexCommand \index{PIC16!stack}
27844
27845 \end_inset
27846
27847  size (that is 64 bytes) probably is enough for many programs.
27848  One must take care that when there are many levels of function nesting,
27849  or there is excessive usage of stack, its size should be extended.
27850  An example of such a case is the printf/sprintf family of functions.
27851  If you encounter problems like not being able to print integers, then you
27852  need to set the stack size around the maximum (256 for small stack model).
27853  The following diagram shows what happens when calling printf to print an
27854  integer:
27855 \end_layout
27856
27857 \begin_layout LyX-Code
27858 printf () --> ltoa () --> ultoa () --> divschar ()
27859 \end_layout
27860
27861 \begin_layout Standard
27862 It is should be understood that stack is easily consumed when calling complicate
27863 d functions.
27864  Using command line arguments like -
27865 \begin_inset ERT
27866 status collapsed
27867
27868 \begin_layout Standard
27869
27870
27871 \backslash
27872 /
27873 \end_layout
27874
27875 \end_inset
27876
27877 -fommit-frame-pointer might reduce stack usage by not creating unnecessery
27878  stack frames.
27879  Other ways to reduce stack usage may exist.
27880 \end_layout
27881
27882 \begin_layout Subsection
27883 Known Bugs
27884 \end_layout
27885
27886 \begin_layout Standard
27887 The PIC16 Port currently does not pass SDCC's regression test
27888 \begin_inset LatexCommand \index{Regression test (PIC16)}
27889
27890 \end_inset
27891
27892  suite (see section
27893 \begin_inset LatexCommand \ref{sec:Quality-control}
27894
27895 \end_inset
27896
27897 ) and thus the snapshot build regression tests for the PIC16 target are
27898  currently disabled for all hosts
27899 \emph on
27900 .
27901 \end_layout
27902
27903 \begin_layout Chapter
27904 Debugging
27905 \end_layout
27906
27907 \begin_layout Standard
27908 There are several approaches to debugging your code.
27909  This chapter is meant to show your options and to give detail on some of
27910  them:
27911 \newline
27912
27913 \newline
27914 When writing your code:
27915 \end_layout
27916
27917 \begin_layout Itemize
27918 write your code with debugging in mind (avoid duplicating code, put conceptually
27919  similar variables into structs, use structured code, have strategic points
27920  within your code where all variables are consistent, ...)
27921 \end_layout
27922
27923 \begin_layout Itemize
27924 run a syntax-checking tool like splint
27925 \begin_inset LatexCommand \index{splint (syntax checking tool)}
27926
27927 \end_inset
27928
27929
27930 \begin_inset LatexCommand \index{lint (syntax checking tool)}
27931
27932 \end_inset
27933
27934  (see -
27935 \begin_inset ERT
27936 status collapsed
27937
27938 \begin_layout Standard
27939
27940
27941 \backslash
27942 /
27943 \end_layout
27944
27945 \end_inset
27946
27947 -more-pedantic
27948 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
27949
27950 \end_inset
27951
27952 ) over the code.
27953 \end_layout
27954
27955 \begin_layout Itemize
27956 for the high level code use a C-compiler (like f.e.
27957  GCC) to compile run and debug the code on your host.
27958  See (see -
27959 \begin_inset ERT
27960 status collapsed
27961
27962 \begin_layout Standard
27963
27964
27965 \backslash
27966 /
27967 \end_layout
27968
27969 \end_inset
27970
27971 -more-pedantic
27972 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
27973
27974 \end_inset
27975
27976 ) on how to handle syntax extensions like __xdata, __at(), ...
27977 \end_layout
27978
27979 \begin_layout Itemize
27980 use another C-compiler to compile code for your target.
27981  Always an option but not recommended:) And not very likely to help you.
27982  If you seriously consider walking this path you should at least occasionally
27983  check portability of your code.
27984  Most commercial compiler vendors will offer an evaluation version so you
27985  can test compile your code or snippets of your code.
27986 \end_layout
27987
27988 \begin_layout Standard
27989 Debugging on a simulator:
27990 \end_layout
27991
27992 \begin_layout Itemize
27993 there is a separate section about SDCDB (section
27994 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
27995
27996 \end_inset
27997
27998 ) below.
27999 \end_layout
28000
28001 \begin_layout Itemize
28002 or (8051 specific) use a freeware/commercial simulator which interfaces
28003  to the AOMF
28004 \begin_inset LatexCommand \index{AOMF, AOMF51}
28005
28006 \end_inset
28007
28008  file (see
28009 \begin_inset LatexCommand \ref{OMF file}
28010
28011 \end_inset
28012
28013 ) optionally generated by SDCC.
28014 \end_layout
28015
28016 \begin_layout Standard
28017 Debugging On-target:
28018 \end_layout
28019
28020 \begin_layout Itemize
28021 use a MCU port pin to serially output debug data to the RS232 port of your
28022  host.
28023  You'll probably want some level shifting device typically involving a MAX232
28024  or similar IC.
28025  If the hardware serial port of the MCU is not available search for 'Software
28026  UART' in your favourite search machine.
28027 \end_layout
28028
28029 \begin_layout Itemize
28030 use an on-target monitor.
28031  In this context a monitor is a small program which usually accepts commands
28032  via a serial line and allows to set program counter, to single step through
28033  a program and read/write memory locations.
28034  For the 8051 good examples of monitors are paulmon and cmon51 (see section
28035 \begin_inset LatexCommand \ref{sec:Related-open-source-tools}
28036
28037 \end_inset
28038
28039 ).
28040 \end_layout
28041
28042 \begin_layout Itemize
28043 toggle MCU port pins at strategic points within your code and use an oscilloscop
28044 e.
28045  A
28046 \emph on
28047 digital oscilloscope
28048 \emph default
28049
28050 \begin_inset LatexCommand \index{Oscilloscope}
28051
28052 \end_inset
28053
28054  with deep trace memory is really helpful especially if you have to debug
28055  a realtime application.
28056  If you need to monitor more pins than your oscilloscope provides you can
28057  sometimes get away with a small R-2R network.
28058  On a single channel oscilloscope you could f.e.
28059  monitor 2 push-pull driven pins by connecting one via a 10\InsetSpace ~
28060 k
28061 \begin_inset Formula $\Omega$
28062 \end_inset
28063
28064  resistor and the other one by a 5\InsetSpace ~
28065 k
28066 \begin_inset Formula $\Omega$
28067 \end_inset
28068
28069  resistor to the oscilloscope probe (check output drive capability of the
28070  pins you want to monitor).
28071  If you need to monitor many more pins a
28072 \emph on
28073 logic analyzer
28074 \emph default
28075  will be handy.
28076 \end_layout
28077
28078 \begin_layout Itemize
28079 use an ICE (
28080 \emph on
28081 i
28082 \emph default
28083 n
28084 \emph on
28085 c
28086 \emph default
28087 ircuit
28088 \emph on
28089 e
28090 \emph default
28091 mulator
28092 \begin_inset LatexCommand \index{ICE (in circuit emulator)}
28093
28094 \end_inset
28095
28096 ).
28097  Usually very expensive.
28098  And very nice to have too.
28099  And usually locks you (for years...) to the devices the ICE can emulate.
28100 \end_layout
28101
28102 \begin_layout Itemize
28103 use a remote debugger.
28104  In most 8-bit systems the symbol information is not available on the target,
28105  and a complete debugger is too bulky for the target system.
28106  Therefore usually a debugger on the host system connects to an on-target
28107  debugging stub which accepts only primitive commands.
28108 \newline
28109 Terms to enter into
28110  your favourite search engine could be 'remote debugging', 'gdb stub' or
28111  'inferior debugger'.
28112  (is there one?)
28113 \end_layout
28114
28115 \begin_layout Itemize
28116 use an on target hardware debugger.
28117  Some of the more modern MCUs include hardware support for setting break
28118  points and monitoring/changing variables by using dedicated hardware pins.
28119  This facility doesn't require additional code to run on the target and
28120 \emph on
28121 usually
28122 \emph default
28123  doesn't affect runtime behaviour until a breakpoint is hit.
28124  For the mcs51 most hardware debuggers use the AOMF
28125 \begin_inset LatexCommand \index{AOMF, AOMF51}
28126
28127 \end_inset
28128
28129  file (see
28130 \begin_inset LatexCommand \ref{OMF file}
28131
28132 \end_inset
28133
28134 ) as input file.
28135 \end_layout
28136
28137 \begin_layout Standard
28138 Last not least:
28139 \end_layout
28140
28141 \begin_layout Itemize
28142 if you are not familiar with any of the following terms you're likely to
28143  run into problems rather sooner than later:
28144 \emph on
28145 volatile
28146 \emph default
28147 ,
28148 \emph on
28149 atomic
28150 \emph default
28151 ,
28152 \emph on
28153 memory map
28154 \emph default
28155 ,
28156 \emph on
28157 overlay
28158 \emph default
28159 .
28160  As an embedded programmer you
28161 \emph on
28162 have
28163 \emph default
28164  to know them so why not look them up
28165 \emph on
28166 before
28167 \emph default
28168  you have problems?)
28169 \end_layout
28170
28171 \begin_layout Itemize
28172 tell someone else about your problem (actually this is a surprisingly effective
28173  means to hunt down the bug even if the listener is not familiar with your
28174  environment).
28175  As 'failure to communicate' is probably one of the job-induced deformations
28176  of an embedded programmer this is highly encouraged.
28177 \end_layout
28178
28179 \begin_layout Section
28180 Debugging with SDCDB
28181 \begin_inset LatexCommand \label{cha:Debugging-with-SDCDB}
28182
28183 \end_inset
28184
28185
28186 \begin_inset LatexCommand \index{SDCDB (debugger)}
28187
28188 \end_inset
28189
28190
28191 \end_layout
28192
28193 \begin_layout Standard
28194 SDCC is distributed with a source level debugger
28195 \begin_inset LatexCommand \index{Debugger}
28196
28197 \end_inset
28198
28199 .
28200  The debugger uses a command line interface, the command repertoire of the
28201  debugger has been kept as close to gdb
28202 \begin_inset LatexCommand \index{gdb}
28203
28204 \end_inset
28205
28206  (the GNU debugger) as possible.
28207  The configuration and build process is part of the standard compiler installati
28208 on, which also builds and installs the debugger in the target directory
28209  specified during configuration.
28210  The debugger allows you debug BOTH at the C source and at the ASM source
28211  level.
28212 \end_layout
28213
28214 \begin_layout Subsection
28215 Compiling for Debugging
28216 \end_layout
28217
28218 \begin_layout Standard
28219 The -
28220 \begin_inset ERT
28221 status collapsed
28222
28223 \begin_layout Standard
28224
28225
28226 \backslash
28227 /
28228 \end_layout
28229
28230 \end_inset
28231
28232 -debug
28233 \begin_inset LatexCommand \index{-\/-debug}
28234
28235 \end_inset
28236
28237  option must be specified for all files for which debug information is to
28238  be generated.
28239  The compiler generates a .adb file for each of these files.
28240  The linker creates the .cdb
28241 \begin_inset LatexCommand \index{<file>.cdb}
28242
28243 \end_inset
28244
28245  file from the .adb
28246 \begin_inset LatexCommand \index{<file>.adb}
28247
28248 \end_inset
28249
28250  files and the address information.
28251  This .cdb is used by the debugger.
28252 \end_layout
28253
28254 \begin_layout Subsection
28255 How the Debugger Works
28256 \end_layout
28257
28258 \begin_layout Standard
28259 When the -
28260 \begin_inset ERT
28261 status collapsed
28262
28263 \begin_layout Standard
28264
28265
28266 \backslash
28267 /
28268 \end_layout
28269
28270 \end_inset
28271
28272 -debug option is specified the compiler generates extra symbol information
28273  some of which are put into the assembler source and some are put into the
28274  .adb file.
28275  Then the linker creates the .cdb file from the individual .adb files with
28276  the address information for the symbols.
28277  The debugger reads the symbolic information generated by the compiler &
28278  the address information generated by the linker.
28279  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
28280  execution is controlled by the debugger.
28281  When a command is issued for the debugger, it translates it into appropriate
28282  commands for the simulator.
28283  (Currently SDCDM only connects to the simulator but
28284 \emph on
28285 newcdb
28286 \emph default
28287  at
28288 \begin_inset LatexCommand \url{http://ec2drv.sf.net/}
28289
28290 \end_inset
28291
28292  is an effort to connect directly to the hardware.)
28293 \end_layout
28294
28295 \begin_layout Subsection
28296 Starting the Debugger SDCDB
28297 \end_layout
28298
28299 \begin_layout Standard
28300 The debugger can be started using the following command line.
28301  (Assume the file you are debugging has the file name foo).
28302 \newline
28303
28304 \newline
28305
28306 \family sans
28307 \series bold
28308 sdcdb foo
28309 \newline
28310
28311 \family default
28312 \series default
28313
28314 \newline
28315 The debugger will look for the following files.
28316 \end_layout
28317
28318 \begin_layout Itemize
28319 foo.c - the source file.
28320 \end_layout
28321
28322 \begin_layout Itemize
28323 foo.cdb - the debugger symbol information file.
28324 \end_layout
28325
28326 \begin_layout Itemize
28327 foo.ihx - the Intel hex format
28328 \begin_inset LatexCommand \index{Intel hex format}
28329
28330 \end_inset
28331
28332  object file.
28333 \end_layout
28334
28335 \begin_layout Subsection
28336 SDCDB Command Line Options
28337 \end_layout
28338
28339 \begin_layout Itemize
28340 -
28341 \begin_inset ERT
28342 status collapsed
28343
28344 \begin_layout Standard
28345
28346
28347 \backslash
28348 /
28349 \end_layout
28350
28351 \end_inset
28352
28353 -directory=<source file directory> this option can used to specify the directory
28354  search list.
28355  The debugger will look into the directory list specified for source, cdb
28356  & ihx files.
28357  The items in the directory list must be separated by ':', e.g.
28358  if the source files can be in the directories /home/src1 and /home/src2,
28359  the -
28360 \begin_inset ERT
28361 status collapsed
28362
28363 \begin_layout Standard
28364
28365
28366 \backslash
28367 /
28368 \end_layout
28369
28370 \end_inset
28371
28372 -directory option should be -
28373 \begin_inset ERT
28374 status collapsed
28375
28376 \begin_layout Standard
28377
28378
28379 \backslash
28380 /
28381 \end_layout
28382
28383 \end_inset
28384
28385 -directory=/home/src1:/home/src2.
28386  Note there can be no spaces in the option.
28387 \end_layout
28388
28389 \begin_layout Itemize
28390 -cd <directory> - change to the <directory>.
28391 \end_layout
28392
28393 \begin_layout Itemize
28394 -fullname - used by GUI front ends.
28395 \end_layout
28396
28397 \begin_layout Itemize
28398 -cpu <cpu-type> - this argument is passed to the simulator please see the
28399  simulator docs for details.
28400 \end_layout
28401
28402 \begin_layout Itemize
28403 -X <Clock frequency > this options is passed to the simulator please see
28404  the simulator docs for details.
28405 \end_layout
28406
28407 \begin_layout Itemize
28408 -s <serial port file> passed to simulator see the simulator docs for details.
28409 \end_layout
28410
28411 \begin_layout Itemize
28412 -S <serial in,out> passed to simulator see the simulator docs for details.
28413 \end_layout
28414
28415 \begin_layout Itemize
28416 -k <port number> passed to simulator see the simulator docs for details.
28417 \end_layout
28418
28419 \begin_layout Subsection
28420 SDCDB Debugger Commands
28421 \end_layout
28422
28423 \begin_layout Standard
28424 As mentioned earlier the command interface for the debugger has been deliberatel
28425 y kept as close the GNU debugger gdb, as possible.
28426  This will help the integration with existing graphical user interfaces
28427  (like ddd, xxgdb or xemacs) existing for the GNU debugger.
28428  If you use a graphical user interface for the debugger you can skip this
28429  section.
28430 \end_layout
28431
28432 \begin_layout Subsubsection*
28433 break [line | file:line | function | file:function]
28434 \end_layout
28435
28436 \begin_layout Standard
28437 Set breakpoint at specified line or function:
28438 \newline
28439
28440 \newline
28441
28442 \family sans
28443 \series bold
28444 sdcdb>break 100
28445 \newline
28446 sdcdb>break foo.c:100
28447 \newline
28448 sdcdb>break funcfoo
28449 \newline
28450 sdcdb>break foo.c:funcfoo
28451 \end_layout
28452
28453 \begin_layout Subsubsection*
28454 clear [line | file:line | function | file:function ]
28455 \end_layout
28456
28457 \begin_layout Standard
28458 Clear breakpoint at specified line or function:
28459 \newline
28460
28461 \newline
28462
28463 \family sans
28464 \series bold
28465 sdcdb>clear 100
28466 \newline
28467 sdcdb>clear foo.c:100
28468 \newline
28469 sdcdb>clear funcfoo
28470 \newline
28471 sdcdb>clear foo.c:funcfoo
28472 \end_layout
28473
28474 \begin_layout Subsubsection*
28475 continue
28476 \end_layout
28477
28478 \begin_layout Standard
28479 Continue program being debugged, after breakpoint.
28480 \end_layout
28481
28482 \begin_layout Subsubsection*
28483 finish
28484 \end_layout
28485
28486 \begin_layout Standard
28487 Execute till the end of the current function.
28488 \end_layout
28489
28490 \begin_layout Subsubsection*
28491 delete [n]
28492 \end_layout
28493
28494 \begin_layout Standard
28495 Delete breakpoint number 'n'.
28496  If used without any option clear ALL user defined break points.
28497 \end_layout
28498
28499 \begin_layout Subsubsection*
28500 info [break | stack | frame | registers ]
28501 \end_layout
28502
28503 \begin_layout Itemize
28504 info break - list all breakpoints
28505 \end_layout
28506
28507 \begin_layout Itemize
28508 info stack - show the function call stack.
28509 \end_layout
28510
28511 \begin_layout Itemize
28512 info frame - show information about the current execution frame.
28513 \end_layout
28514
28515 \begin_layout Itemize
28516 info registers - show content of all registers.
28517 \end_layout
28518
28519 \begin_layout Subsubsection*
28520 step
28521 \end_layout
28522
28523 \begin_layout Standard
28524 Step program until it reaches a different source line.
28525  Note: pressing <return> repeats the last command.
28526 \end_layout
28527
28528 \begin_layout Subsubsection*
28529 next
28530 \end_layout
28531
28532 \begin_layout Standard
28533 Step program, proceeding through subroutine calls.
28534 \end_layout
28535
28536 \begin_layout Subsubsection*
28537 run
28538 \end_layout
28539
28540 \begin_layout Standard
28541 Start debugged program.
28542 \end_layout
28543
28544 \begin_layout Subsubsection*
28545 ptype variable
28546 \end_layout
28547
28548 \begin_layout Standard
28549 Print type information of the variable.
28550 \end_layout
28551
28552 \begin_layout Subsubsection*
28553 print variable
28554 \end_layout
28555
28556 \begin_layout Standard
28557 print value of variable.
28558 \end_layout
28559
28560 \begin_layout Subsubsection*
28561 file filename
28562 \end_layout
28563
28564 \begin_layout Standard
28565 load the given file name.
28566  Note this is an alternate method of loading file for debugging.
28567 \end_layout
28568
28569 \begin_layout Subsubsection*
28570 frame
28571 \end_layout
28572
28573 \begin_layout Standard
28574 print information about current frame.
28575 \end_layout
28576
28577 \begin_layout Subsubsection*
28578 set srcmode
28579 \end_layout
28580
28581 \begin_layout Standard
28582 Toggle between C source & assembly source.
28583 \end_layout
28584
28585 \begin_layout Subsubsection*
28586 ! simulator command
28587 \end_layout
28588
28589 \begin_layout Standard
28590 Send the string following '!' to the simulator, the simulator response is
28591  displayed.
28592  Note the debugger does not interpret the command being sent to the simulator,
28593  so if a command like 'go' is sent the debugger can loose its execution
28594  context and may display incorrect values.
28595 \end_layout
28596
28597 \begin_layout Subsubsection*
28598 quit
28599 \end_layout
28600
28601 \begin_layout Standard
28602 "Watch me now.
28603  Iam going Down.
28604  My name is Bobby Brown"
28605 \end_layout
28606
28607 \begin_layout Subsection
28608 Interfacing SDCDB with DDD
28609 \end_layout
28610
28611 \begin_layout Standard
28612 \begin_inset Note Note
28613 status collapsed
28614
28615 \begin_layout Standard
28616 The screenshot was converted from png to eps with:
28617 \begin_inset Quotes sld
28618 \end_inset
28619
28620 bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps
28621 \begin_inset Quotes srd
28622 \end_inset
28623
28624  which produces a pretty compact eps file which is free from compression
28625  artifacts.
28626 \end_layout
28627
28628 \begin_layout Standard
28629 The screenshot was included in sdccman.lyx cvs version 1.120 but later removed
28630  as this broke the build system on Sourceforge (pdf-file was broken.
28631  pdflatex does not accept eps files).
28632 \end_layout
28633
28634 \end_inset
28635
28636
28637 \end_layout
28638
28639 \begin_layout Standard
28640 The
28641 \emph on
28642 p
28643 \emph default
28644 ortable
28645 \emph on
28646 n
28647 \emph default
28648 etwork
28649 \emph on
28650 g
28651 \emph default
28652 raphics File
28653 \size footnotesize
28654
28655 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/doc/figures/ddd_example.png}
28656
28657 \end_inset
28658
28659
28660 \size default
28661  shows a screenshot of a debugging session with DDD
28662 \begin_inset LatexCommand \index{DDD (debugger)}
28663
28664 \end_inset
28665
28666  (Unix only) on a simulated 8032.
28667  The debugging session might not run as smoothly as the screenshot suggests.
28668  The debugger allows setting of breakpoints, displaying and changing variables,
28669  single stepping through C and assembler code.
28670 \newline
28671 The source was compiled with
28672 \family sans
28673 \series bold
28674
28675 \newline
28676
28677 \newline
28678 sdcc -
28679 \family default
28680 \series default
28681
28682 \begin_inset ERT
28683 status collapsed
28684
28685 \begin_layout Standard
28686
28687
28688 \backslash
28689 /
28690 \end_layout
28691
28692 \end_inset
28693
28694
28695 \family sans
28696 \series bold
28697 -debug ddd_example.c
28698 \newline
28699
28700 \family default
28701 \series default
28702
28703 \newline
28704 and DDD was invoked with
28705 \family sans
28706 \series bold
28707
28708 \newline
28709
28710 \newline
28711 ddd -debugger "sdcdb -cpu 8032 ddd_example"
28712 \end_layout
28713
28714 \begin_layout Standard
28715 \begin_inset Note Note
28716 status open
28717
28718 \begin_layout Standard
28719 Check that the double quotes or an apostroph within the command line survive
28720  the LyX tool chain.
28721  Previously the apostrophs got slanted in the PDF output so a cut and paste
28722  did not work.
28723 \end_layout
28724
28725 \end_inset
28726
28727
28728 \end_layout
28729
28730 \begin_layout Subsection
28731 Interfacing SDCDB with XEmacs
28732 \begin_inset LatexCommand \index{XEmacs}
28733
28734 \end_inset
28735
28736
28737 \begin_inset LatexCommand \index{Emacs}
28738
28739 \end_inset
28740
28741
28742 \end_layout
28743
28744 \begin_layout Standard
28745 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
28746  sdcdb.el and sdcdbsrc.el.
28747  These two files can be found in the $(prefix)/bin directory after the installat
28748 ion is complete.
28749  These files need to be loaded into XEmacs for the interface to work.
28750  This can be done at XEmacs startup time by inserting the following into
28751  your '.xemacs' file (which can be found in your HOME directory):
28752 \newline
28753
28754 \newline
28755
28756 \family typewriter
28757 (load-file sdcdbsrc.el)
28758 \family default
28759
28760 \newline
28761
28762 \newline
28763 .xemacs is a lisp file so the () around the command is REQUIRED.
28764  The files can also be loaded dynamically while XEmacs is running, set the
28765  environment variable 'EMACSLOADPATH' to the installation bin directory
28766  (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
28767  To start the interface enter the following command:
28768 \newline
28769
28770 \newline
28771
28772 \family sans
28773 \series bold
28774 ESC-x sdcdbsrc
28775 \family default
28776 \series default
28777
28778 \newline
28779
28780 \newline
28781 You will prompted to enter the file name to be debugged.
28782 \newline
28783
28784 \newline
28785 The command line
28786  options that are passed to the simulator directly are bound to default
28787  values in the file sdcdbsrc.el.
28788  The variables are listed below, these values maybe changed as required.
28789 \end_layout
28790
28791 \begin_layout Itemize
28792 sdcdbsrc-cpu-type '51
28793 \end_layout
28794
28795 \begin_layout Itemize
28796 sdcdbsrc-frequency '11059200
28797 \end_layout
28798
28799 \begin_layout Itemize
28800 sdcdbsrc-serial nil
28801 \end_layout
28802
28803 \begin_layout Standard
28804 The following is a list of key mapping for the debugger interface.
28805 \end_layout
28806
28807 \begin_layout Standard
28808 \InsetSpace ~
28809
28810 \family typewriter
28811
28812 \newline
28813 ;;\InsetSpace ~
28814 Current Listing ::
28815 \newline
28816 ;;key\InsetSpace ~
28817 \InsetSpace ~
28818 \InsetSpace ~
28819 \InsetSpace ~
28820 \InsetSpace ~
28821 \InsetSpace ~
28822 \InsetSpace ~
28823 \InsetSpace ~
28824 \InsetSpace ~
28825 \InsetSpace ~
28826 \InsetSpace ~
28827 \InsetSpace ~
28828 \InsetSpace ~
28829 \InsetSpace ~
28830 binding\InsetSpace ~
28831 \InsetSpace ~
28832 \InsetSpace ~
28833 \InsetSpace ~
28834 \InsetSpace ~
28835 \InsetSpace ~
28836 \InsetSpace ~
28837 \InsetSpace ~
28838 \InsetSpace ~
28839 \InsetSpace ~
28840 \InsetSpace ~
28841 \InsetSpace ~
28842 \InsetSpace ~
28843 \InsetSpace ~
28844 \InsetSpace ~
28845 \InsetSpace ~
28846 \InsetSpace ~
28847 \InsetSpace ~
28848 \InsetSpace ~
28849 \InsetSpace ~
28850 \InsetSpace ~
28851 \InsetSpace ~
28852 Comment
28853 \newline
28854 ;;---\InsetSpace ~
28855 \InsetSpace ~
28856 \InsetSpace ~
28857 \InsetSpace ~
28858 \InsetSpace ~
28859 \InsetSpace ~
28860 \InsetSpace ~
28861 \InsetSpace ~
28862 \InsetSpace ~
28863 \InsetSpace ~
28864 \InsetSpace ~
28865 \InsetSpace ~
28866 \InsetSpace ~
28867 \InsetSpace ~
28868 -------\InsetSpace ~
28869 \InsetSpace ~
28870 \InsetSpace ~
28871 \InsetSpace ~
28872 \InsetSpace ~
28873 \InsetSpace ~
28874 \InsetSpace ~
28875 \InsetSpace ~
28876 \InsetSpace ~
28877 \InsetSpace ~
28878 \InsetSpace ~
28879 \InsetSpace ~
28880 \InsetSpace ~
28881 \InsetSpace ~
28882 \InsetSpace ~
28883 \InsetSpace ~
28884 \InsetSpace ~
28885 \InsetSpace ~
28886 \InsetSpace ~
28887 \InsetSpace ~
28888 \InsetSpace ~
28889 \InsetSpace ~
28890 -------
28891 \newline
28892 ;;
28893 \newline
28894 ;;\InsetSpace ~
28895 n\InsetSpace ~
28896 \InsetSpace ~
28897 \InsetSpace ~
28898 \InsetSpace ~
28899 \InsetSpace ~
28900 \InsetSpace ~
28901 \InsetSpace ~
28902 \InsetSpace ~
28903 \InsetSpace ~
28904 \InsetSpace ~
28905 \InsetSpace ~
28906 \InsetSpace ~
28907 \InsetSpace ~
28908 \InsetSpace ~
28909 \InsetSpace ~
28910 sdcdb-next-from-s
28911 rc\InsetSpace ~
28912 \InsetSpace ~
28913 \InsetSpace ~
28914 \InsetSpace ~
28915 \InsetSpace ~
28916 \InsetSpace ~
28917 \InsetSpace ~
28918 \InsetSpace ~
28919 \InsetSpace ~
28920 \InsetSpace ~
28921 SDCDB next command
28922 \newline
28923 ;;\InsetSpace ~
28924 b\InsetSpace ~
28925 \InsetSpace ~
28926 \InsetSpace ~
28927 \InsetSpace ~
28928 \InsetSpace ~
28929 \InsetSpace ~
28930 \InsetSpace ~
28931 \InsetSpace ~
28932 \InsetSpace ~
28933 \InsetSpace ~
28934 \InsetSpace ~
28935 \InsetSpace ~
28936 \InsetSpace ~
28937 \InsetSpace ~
28938 \InsetSpace ~
28939 sdcdb-back-from-src\InsetSpace ~
28940 \InsetSpace ~
28941 \InsetSpace ~
28942 \InsetSpace ~
28943 \InsetSpace ~
28944 \InsetSpace ~
28945 \InsetSpace ~
28946 \InsetSpace ~
28947 \InsetSpace ~
28948 \InsetSpace ~
28949 SDCDB back command
28950 \newline
28951 ;;\InsetSpace ~
28952 c\InsetSpace ~
28953 \InsetSpace ~
28954 \InsetSpace ~
28955 \InsetSpace ~
28956 \InsetSpace ~
28957 \InsetSpace ~
28958 \InsetSpace ~
28959 \InsetSpace ~
28960 \InsetSpace ~
28961 \InsetSpace ~
28962 \InsetSpace ~
28963 \InsetSpace ~
28964 \InsetSpace ~
28965 \InsetSpace ~
28966 \InsetSpace ~
28967 sdcdb-cont-from-s
28968 rc\InsetSpace ~
28969 \InsetSpace ~
28970 \InsetSpace ~
28971 \InsetSpace ~
28972 \InsetSpace ~
28973 \InsetSpace ~
28974 \InsetSpace ~
28975 \InsetSpace ~
28976 \InsetSpace ~
28977 \InsetSpace ~
28978 SDCDB continue command
28979 \newline
28980 ;;\InsetSpace ~
28981 s\InsetSpace ~
28982 \InsetSpace ~
28983 \InsetSpace ~
28984 \InsetSpace ~
28985 \InsetSpace ~
28986 \InsetSpace ~
28987 \InsetSpace ~
28988 \InsetSpace ~
28989 \InsetSpace ~
28990 \InsetSpace ~
28991 \InsetSpace ~
28992 \InsetSpace ~
28993 \InsetSpace ~
28994 \InsetSpace ~
28995 \InsetSpace ~
28996 sdcdb-step-from-src\InsetSpace ~
28997 \InsetSpace ~
28998 \InsetSpace ~
28999 \InsetSpace ~
29000 \InsetSpace ~
29001 \InsetSpace ~
29002 \InsetSpace ~
29003 \InsetSpace ~
29004 \InsetSpace ~
29005 \InsetSpace ~
29006 SDCDB step command
29007 \newline
29008 ;;\InsetSpace ~
29009 ?\InsetSpace ~
29010 \InsetSpace ~
29011 \InsetSpace ~
29012 \InsetSpace ~
29013 \InsetSpace ~
29014 \InsetSpace ~
29015 \InsetSpace ~
29016 \InsetSpace ~
29017 \InsetSpace ~
29018 \InsetSpace ~
29019 \InsetSpace ~
29020 \InsetSpace ~
29021 \InsetSpace ~
29022 \InsetSpace ~
29023 \InsetSpace ~
29024 sdcdb-whatis-
29025 c-sexp\InsetSpace ~
29026 \InsetSpace ~
29027 \InsetSpace ~
29028 \InsetSpace ~
29029 \InsetSpace ~
29030 \InsetSpace ~
29031 \InsetSpace ~
29032 \InsetSpace ~
29033 \InsetSpace ~
29034 \InsetSpace ~
29035 SDCDB ptypecommand for data at
29036 \newline
29037 ;;\InsetSpace ~
29038 \InsetSpace ~
29039 \InsetSpace ~
29040 \InsetSpace ~
29041 \InsetSpace ~
29042 \InsetSpace ~
29043 \InsetSpace ~
29044 \InsetSpace ~
29045 \InsetSpace ~
29046 \InsetSpace ~
29047 \InsetSpace ~
29048 \InsetSpace ~
29049 \InsetSpace ~
29050 \InsetSpace ~
29051 \InsetSpace ~
29052 \InsetSpace ~
29053 \InsetSpace ~
29054 \InsetSpace ~
29055 \InsetSpace ~
29056 \InsetSpace ~
29057 \InsetSpace ~
29058 \InsetSpace ~
29059 \InsetSpace ~
29060 \InsetSpace ~
29061 \InsetSpace ~
29062 \InsetSpace ~
29063 \InsetSpace ~
29064 \InsetSpace ~
29065 \InsetSpace ~
29066 \InsetSpace ~
29067 \InsetSpace ~
29068 \InsetSpace ~
29069 \InsetSpace ~
29070 \InsetSpace ~
29071 \InsetSpace ~
29072 \InsetSpace ~
29073 \InsetSpace ~
29074 \InsetSpace ~
29075 \InsetSpace ~
29076 \InsetSpace ~
29077 \InsetSpace ~
29078 \InsetSpace ~
29079 \InsetSpace ~
29080 \InsetSpace ~
29081 \InsetSpace ~
29082 \InsetSpace ~
29083 \InsetSpace ~
29084 buffer point
29085 \newline
29086 ;;\InsetSpace ~
29087 x\InsetSpace ~
29088 \InsetSpace ~
29089 \InsetSpace ~
29090 \InsetSpace ~
29091 \InsetSpace ~
29092 \InsetSpace ~
29093 \InsetSpace ~
29094 \InsetSpace ~
29095 \InsetSpace ~
29096 \InsetSpace ~
29097 \InsetSpace ~
29098 \InsetSpace ~
29099 \InsetSpace ~
29100 \InsetSpace ~
29101 \InsetSpace ~
29102 sdcdbsrc-delete\InsetSpace ~
29103 \InsetSpace ~
29104 \InsetSpace ~
29105 \InsetSpace ~
29106 \InsetSpace ~
29107 \InsetSpace ~
29108 \InsetSpace ~
29109 \InsetSpace ~
29110 \InsetSpace ~
29111 \InsetSpace ~
29112 \InsetSpace ~
29113 \InsetSpace ~
29114 \InsetSpace ~
29115 \InsetSpace ~
29116 SDCDB
29117  Delete all breakpoints if no arg
29118 \newline
29119 ;;\InsetSpace ~
29120 \InsetSpace ~
29121 \InsetSpace ~
29122 \InsetSpace ~
29123 \InsetSpace ~
29124 \InsetSpace ~
29125 \InsetSpace ~
29126 \InsetSpace ~
29127 \InsetSpace ~
29128 \InsetSpace ~
29129 \InsetSpace ~
29130 \InsetSpace ~
29131 \InsetSpace ~
29132 \InsetSpace ~
29133 \InsetSpace ~
29134 \InsetSpace ~
29135 \InsetSpace ~
29136 \InsetSpace ~
29137 \InsetSpace ~
29138 \InsetSpace ~
29139 \InsetSpace ~
29140 \InsetSpace ~
29141 \InsetSpace ~
29142 \InsetSpace ~
29143 \InsetSpace ~
29144 \InsetSpace ~
29145 \InsetSpace ~
29146 \InsetSpace ~
29147 \InsetSpace ~
29148 \InsetSpace ~
29149 \InsetSpace ~
29150 \InsetSpace ~
29151 \InsetSpace ~
29152 \InsetSpace ~
29153 \InsetSpace ~
29154 \InsetSpace ~
29155 \InsetSpace ~
29156 \InsetSpace ~
29157 \InsetSpace ~
29158 \InsetSpace ~
29159 \InsetSpace ~
29160 \InsetSpace ~
29161 \InsetSpace ~
29162 \InsetSpace ~
29163 \InsetSpace ~
29164 \InsetSpace ~
29165 \InsetSpace ~
29166 given or delete arg (C-u arg x)
29167 \newline
29168 ;;\InsetSpace ~
29169 m\InsetSpace ~
29170 \InsetSpace ~
29171 \InsetSpace ~
29172 \InsetSpace ~
29173 \InsetSpace ~
29174 \InsetSpace ~
29175 \InsetSpace ~
29176 \InsetSpace ~
29177 \InsetSpace ~
29178 \InsetSpace ~
29179 \InsetSpace ~
29180 \InsetSpace ~
29181 \InsetSpace ~
29182 \InsetSpace ~
29183 \InsetSpace ~
29184 sdcdbsrc-fr
29185 ame\InsetSpace ~
29186 \InsetSpace ~
29187 \InsetSpace ~
29188 \InsetSpace ~
29189 \InsetSpace ~
29190 \InsetSpace ~
29191 \InsetSpace ~
29192 \InsetSpace ~
29193 \InsetSpace ~
29194 \InsetSpace ~
29195 \InsetSpace ~
29196 \InsetSpace ~
29197 \InsetSpace ~
29198 \InsetSpace ~
29199 \InsetSpace ~
29200 SDCDB Display current frame if no arg,
29201 \newline
29202 ;;\InsetSpace ~
29203 \InsetSpace ~
29204 \InsetSpace ~
29205 \InsetSpace ~
29206 \InsetSpace ~
29207 \InsetSpace ~
29208 \InsetSpace ~
29209 \InsetSpace ~
29210 \InsetSpace ~
29211 \InsetSpace ~
29212 \InsetSpace ~
29213 \InsetSpace ~
29214 \InsetSpace ~
29215 \InsetSpace ~
29216 \InsetSpace ~
29217 \InsetSpace ~
29218 \InsetSpace ~
29219 \InsetSpace ~
29220 \InsetSpace ~
29221 \InsetSpace ~
29222 \InsetSpace ~
29223 \InsetSpace ~
29224 \InsetSpace ~
29225 \InsetSpace ~
29226 \InsetSpace ~
29227 \InsetSpace ~
29228 \InsetSpace ~
29229 \InsetSpace ~
29230 \InsetSpace ~
29231 \InsetSpace ~
29232 \InsetSpace ~
29233 \InsetSpace ~
29234 \InsetSpace ~
29235 \InsetSpace ~
29236 \InsetSpace ~
29237 \InsetSpace ~
29238 \InsetSpace ~
29239 \InsetSpace ~
29240 \InsetSpace ~
29241 \InsetSpace ~
29242 \InsetSpace ~
29243 \InsetSpace ~
29244 \InsetSpace ~
29245 \InsetSpace ~
29246 \InsetSpace ~
29247 \InsetSpace ~
29248 \InsetSpace ~
29249 given or display frame arg
29250 \newline
29251 ;;\InsetSpace ~
29252 \InsetSpace ~
29253 \InsetSpace ~
29254 \InsetSpace ~
29255 \InsetSpace ~
29256 \InsetSpace ~
29257 \InsetSpace ~
29258 \InsetSpace ~
29259 \InsetSpace ~
29260 \InsetSpace ~
29261 \InsetSpace ~
29262 \InsetSpace ~
29263 \InsetSpace ~
29264 \InsetSpace ~
29265 \InsetSpace ~
29266 \InsetSpace ~
29267 \InsetSpace ~
29268 \InsetSpace ~
29269 \InsetSpace ~
29270 \InsetSpace ~
29271 \InsetSpace ~
29272 \InsetSpace ~
29273 \InsetSpace ~
29274 \InsetSpace ~
29275 \InsetSpace ~
29276 \InsetSpace ~
29277 \InsetSpace ~
29278 \InsetSpace ~
29279 \InsetSpace ~
29280 \InsetSpace ~
29281 \InsetSpace ~
29282 \InsetSpace ~
29283 \InsetSpace ~
29284 \InsetSpace ~
29285 \InsetSpace ~
29286 \InsetSpace ~
29287 \InsetSpace ~
29288 \InsetSpace ~
29289 \InsetSpace ~
29290 \InsetSpace ~
29291 \InsetSpace ~
29292 \InsetSpace ~
29293 \InsetSpace ~
29294 \InsetSpace ~
29295 \InsetSpace ~
29296 \InsetSpace ~
29297 \InsetSpace ~
29298 buffer
29299  point
29300 \newline
29301 ;;\InsetSpace ~
29302 !\InsetSpace ~
29303 \InsetSpace ~
29304 \InsetSpace ~
29305 \InsetSpace ~
29306 \InsetSpace ~
29307 \InsetSpace ~
29308 \InsetSpace ~
29309 \InsetSpace ~
29310 \InsetSpace ~
29311 \InsetSpace ~
29312 \InsetSpace ~
29313 \InsetSpace ~
29314 \InsetSpace ~
29315 \InsetSpace ~
29316 \InsetSpace ~
29317 sdcdbsrc-goto-sdcdb\InsetSpace ~
29318 \InsetSpace ~
29319 \InsetSpace ~
29320 \InsetSpace ~
29321 \InsetSpace ~
29322 \InsetSpace ~
29323 \InsetSpace ~
29324 \InsetSpace ~
29325 \InsetSpace ~
29326 \InsetSpace ~
29327 Goto the SDCDB output buffer
29328 \newline
29329 ;;\InsetSpace ~
29330 p\InsetSpace ~
29331 \InsetSpace ~
29332 \InsetSpace ~
29333 \InsetSpace ~
29334 \InsetSpace ~
29335 \InsetSpace ~
29336 \InsetSpace ~
29337 \InsetSpace ~
29338 \InsetSpace ~
29339 \InsetSpace ~
29340 \InsetSpace ~
29341 \InsetSpace ~
29342 \InsetSpace ~
29343 \InsetSpace ~
29344 \InsetSpace ~
29345 sdcdb-print-c-sexp\InsetSpace ~
29346 \InsetSpace ~
29347 \InsetSpace ~
29348 \InsetSpace ~
29349 \InsetSpace ~
29350 \InsetSpace ~
29351 \InsetSpace ~
29352 \InsetSpace ~
29353 \InsetSpace ~
29354 \InsetSpace ~
29355 \InsetSpace ~
29356 SDC
29357 DB print command for data at
29358 \newline
29359 ;;\InsetSpace ~
29360 \InsetSpace ~
29361 \InsetSpace ~
29362 \InsetSpace ~
29363 \InsetSpace ~
29364 \InsetSpace ~
29365 \InsetSpace ~
29366 \InsetSpace ~
29367 \InsetSpace ~
29368 \InsetSpace ~
29369 \InsetSpace ~
29370 \InsetSpace ~
29371 \InsetSpace ~
29372 \InsetSpace ~
29373 \InsetSpace ~
29374 \InsetSpace ~
29375 \InsetSpace ~
29376 \InsetSpace ~
29377 \InsetSpace ~
29378 \InsetSpace ~
29379 \InsetSpace ~
29380 \InsetSpace ~
29381 \InsetSpace ~
29382 \InsetSpace ~
29383 \InsetSpace ~
29384 \InsetSpace ~
29385 \InsetSpace ~
29386 \InsetSpace ~
29387 \InsetSpace ~
29388 \InsetSpace ~
29389 \InsetSpace ~
29390 \InsetSpace ~
29391 \InsetSpace ~
29392 \InsetSpace ~
29393 \InsetSpace ~
29394 \InsetSpace ~
29395 \InsetSpace ~
29396 \InsetSpace ~
29397 \InsetSpace ~
29398 \InsetSpace ~
29399 \InsetSpace ~
29400 \InsetSpace ~
29401 \InsetSpace ~
29402 \InsetSpace ~
29403 \InsetSpace ~
29404 \InsetSpace ~
29405 \InsetSpace ~
29406 buffer point
29407 \newline
29408 ;;\InsetSpace ~
29409 g\InsetSpace ~
29410 \InsetSpace ~
29411 \InsetSpace ~
29412 \InsetSpace ~
29413 \InsetSpace ~
29414 \InsetSpace ~
29415 \InsetSpace ~
29416 \InsetSpace ~
29417 \InsetSpace ~
29418 \InsetSpace ~
29419 \InsetSpace ~
29420 \InsetSpace ~
29421 \InsetSpace ~
29422 \InsetSpace ~
29423 \InsetSpace ~
29424 sdcdbsrc-goto-sdcdb\InsetSpace ~
29425 \InsetSpace ~
29426 \InsetSpace ~
29427 \InsetSpace ~
29428 \InsetSpace ~
29429 \InsetSpace ~
29430 \InsetSpace ~
29431 \InsetSpace ~
29432 \InsetSpace ~
29433 \InsetSpace ~
29434 Goto the
29435  SDCDB output buffer
29436 \newline
29437 ;;\InsetSpace ~
29438 t\InsetSpace ~
29439 \InsetSpace ~
29440 \InsetSpace ~
29441 \InsetSpace ~
29442 \InsetSpace ~
29443 \InsetSpace ~
29444 \InsetSpace ~
29445 \InsetSpace ~
29446 \InsetSpace ~
29447 \InsetSpace ~
29448 \InsetSpace ~
29449 \InsetSpace ~
29450 \InsetSpace ~
29451 \InsetSpace ~
29452 \InsetSpace ~
29453 sdcdbsrc-mode\InsetSpace ~
29454 \InsetSpace ~
29455 \InsetSpace ~
29456 \InsetSpace ~
29457 \InsetSpace ~
29458 \InsetSpace ~
29459 \InsetSpace ~
29460 \InsetSpace ~
29461 \InsetSpace ~
29462 \InsetSpace ~
29463 \InsetSpace ~
29464 \InsetSpace ~
29465 \InsetSpace ~
29466 \InsetSpace ~
29467 \InsetSpace ~
29468 \InsetSpace ~
29469 Toggles Sdcdbsrc mode (turns it off)
29470 \newline
29471 ;;
29472 \newline
29473 ;;\InsetSpace ~
29474 C-c\InsetSpace ~
29475 C
29476 -f\InsetSpace ~
29477 \InsetSpace ~
29478 \InsetSpace ~
29479 \InsetSpace ~
29480 \InsetSpace ~
29481 \InsetSpace ~
29482 \InsetSpace ~
29483 \InsetSpace ~
29484 \InsetSpace ~
29485 sdcdb-finish-from-src\InsetSpace ~
29486 \InsetSpace ~
29487 \InsetSpace ~
29488 \InsetSpace ~
29489 \InsetSpace ~
29490 \InsetSpace ~
29491 \InsetSpace ~
29492 \InsetSpace ~
29493 SDCDB finish command
29494 \newline
29495 ;;
29496 \newline
29497 ;;\InsetSpace ~
29498 C-x\InsetSpace ~
29499 SPC\InsetSpace ~
29500 \InsetSpace ~
29501 \InsetSpace ~
29502 \InsetSpace ~
29503 \InsetSpace ~
29504 \InsetSpace ~
29505 \InsetSpace ~
29506 \InsetSpace ~
29507 \InsetSpace ~
29508 sdcdb-break\InsetSpace ~
29509 \InsetSpace ~
29510 \InsetSpace ~
29511 \InsetSpace ~
29512 \InsetSpace ~
29513 \InsetSpace ~
29514 \InsetSpace ~
29515 \InsetSpace ~
29516 \InsetSpace ~
29517 \InsetSpace ~
29518 \InsetSpace ~
29519 \InsetSpace ~
29520 \InsetSpace ~
29521 \InsetSpace ~
29522 \InsetSpace ~
29523 \InsetSpace ~
29524 \InsetSpace ~
29525 \InsetSpace ~
29526 Set break
29527  for line with point
29528 \newline
29529 ;;\InsetSpace ~
29530 ESC\InsetSpace ~
29531 t\InsetSpace ~
29532 \InsetSpace ~
29533 \InsetSpace ~
29534 \InsetSpace ~
29535 \InsetSpace ~
29536 \InsetSpace ~
29537 \InsetSpace ~
29538 \InsetSpace ~
29539 \InsetSpace ~
29540 \InsetSpace ~
29541 \InsetSpace ~
29542 sdcdbsrc-mode\InsetSpace ~
29543 \InsetSpace ~
29544 \InsetSpace ~
29545 \InsetSpace ~
29546 \InsetSpace ~
29547 \InsetSpace ~
29548 \InsetSpace ~
29549 \InsetSpace ~
29550 \InsetSpace ~
29551 \InsetSpace ~
29552 \InsetSpace ~
29553 \InsetSpace ~
29554 \InsetSpace ~
29555 \InsetSpace ~
29556 \InsetSpace ~
29557 \InsetSpace ~
29558 Toggle Sdcdbsrc mode
29559 \newline
29560 ;;\InsetSpace ~
29561 ESC\InsetSpace ~
29562 m\InsetSpace ~
29563 \InsetSpace ~
29564 \InsetSpace ~
29565 \InsetSpace ~
29566 \InsetSpace ~
29567 \InsetSpace ~
29568 \InsetSpace ~
29569 \InsetSpace ~
29570 \InsetSpace ~
29571 \InsetSpace ~
29572 \InsetSpace ~
29573 sdcdbsrc-srcmod
29574 e\InsetSpace ~
29575 \InsetSpace ~
29576 \InsetSpace ~
29577 \InsetSpace ~
29578 \InsetSpace ~
29579 \InsetSpace ~
29580 \InsetSpace ~
29581 \InsetSpace ~
29582 \InsetSpace ~
29583 \InsetSpace ~
29584 \InsetSpace ~
29585 \InsetSpace ~
29586 \InsetSpace ~
29587 Toggle list mode
29588 \newline
29589 ;;
29590 \newline
29591
29592 \family default
29593
29594 \newpage
29595
29596 \end_layout
29597
29598 \begin_layout Chapter
29599 TIPS
29600 \end_layout
29601
29602 \begin_layout Standard
29603 Here are a few guidelines that will help the compiler generate more efficient
29604  code, some of the tips are specific to this compiler others are generally
29605  good programming practice.
29606 \end_layout
29607
29608 \begin_layout Itemize
29609 Use the smallest data type to represent your data-value.
29610  If it is known in advance that the value is going to be less than 256 then
29611  use an 'unsigned char' instead of a 'short' or 'int'.
29612  Please note, that ANSI C requires both signed and unsigned chars to be
29613  promoted to 'signed int'
29614 \begin_inset LatexCommand \index{promotion to signed int}
29615
29616 \end_inset
29617
29618
29619 \begin_inset Marginal
29620 status collapsed
29621
29622 \begin_layout Standard
29623
29624 \series bold
29625 \InsetSpace ~
29626 !
29627 \end_layout
29628
29629 \end_inset
29630
29631  before doing any operation.
29632  This promotion
29633 \begin_inset LatexCommand \index{type promotion}
29634
29635 \end_inset
29636
29637
29638 \begin_inset LatexCommand \label{type promotion}
29639
29640 \end_inset
29641
29642  can be omitted, if the result is the same.
29643  The effect of the promotion rules together with the sign-extension is often
29644  surprising:
29645 \end_layout
29646
29647 \begin_deeper
29648 \begin_layout Verse
29649
29650 \family typewriter
29651 unsigned char uc = 0xfe;
29652 \newline
29653 if (uc * uc < 0) /* this is true! */
29654 \newline
29655 {
29656 \newline
29657 \InsetSpace ~
29658 \InsetSpace ~
29659 \InsetSpace ~
29660 \InsetSpace ~
29661 ....
29662 \newline
29663 }
29664 \end_layout
29665
29666 \begin_layout Standard
29667
29668 \family typewriter
29669 uc * uc
29670 \family default
29671  is evaluated as
29672 \family typewriter
29673 (int) uc * (int) uc = (int) 0xfe * (int) 0xfe = (int) 0xfc04 = -1024
29674 \family default
29675 .
29676 \newline
29677 Another one:
29678 \end_layout
29679
29680 \begin_layout Verse
29681
29682 \family typewriter
29683 (unsigned char) -12 / (signed char) -3 = ...
29684 \end_layout
29685
29686 \begin_layout Standard
29687 No, the result is not 4:
29688 \end_layout
29689
29690 \begin_layout Verse
29691
29692 \family typewriter
29693 (int) (unsigned char) -12 / (int) (signed char) -3 =
29694 \newline
29695 (int) (unsigned char)
29696  0xf4 / (int) (signed char) 0xfd =
29697 \newline
29698 (int) 0x00f4 / (int) 0xfffd =
29699 \newline
29700 (int) 0x00f4
29701  / (int) 0xfffd =
29702 \newline
29703 (int) 244 / (int) -3 =
29704 \newline
29705 (int) -81 = (int) 0xffaf;
29706 \end_layout
29707
29708 \begin_layout Standard
29709 Don't complain, that gcc gives you a different result.
29710  gcc uses 32 bit ints, while SDCC uses 16 bit ints.
29711  Therefore the results are different.
29712 \newline
29713 From
29714 \begin_inset Quotes sld
29715 \end_inset
29716
29717 comp.lang.c FAQ
29718 \begin_inset Quotes srd
29719 \end_inset
29720
29721 :
29722 \end_layout
29723
29724 \begin_layout Quote
29725
29726 \emph on
29727 If well-defined overflow characteristics are important and negative values
29728  are not, or if you want to steer clear of sign-extension problems when
29729  manipulating bits or bytes, use one of the corresponding unsigned types.
29730  (Beware when mixing signed and unsigned values in expressions, though.)
29731 \newline
29732 Although
29733  character types (especially unsigned char) can be used as "tiny" integers,
29734  doing so is sometimes more trouble than it's worth, due to unpredictable
29735  sign extension and increased code size.
29736 \end_layout
29737
29738 \end_deeper
29739 \begin_layout Itemize
29740 Use unsigned when it is known in advance that the value is not going to
29741  be negative.
29742  This helps especially if you are doing division or multiplication, bit-shifting
29743  or are using an array index.
29744 \end_layout
29745
29746 \begin_layout Itemize
29747 NEVER jump into a LOOP.
29748 \end_layout
29749
29750 \begin_layout Itemize
29751 Declare the variables to be local
29752 \begin_inset LatexCommand \index{local variables}
29753
29754 \end_inset
29755
29756  whenever possible, especially loop control variables (induction).
29757 \end_layout
29758
29759 \begin_layout Itemize
29760 Have a look at the assembly listing to get a
29761 \begin_inset Quotes sld
29762 \end_inset
29763
29764 feeling
29765 \begin_inset Quotes srd
29766 \end_inset
29767
29768  for the code generation.
29769 \end_layout
29770
29771 \begin_layout Section
29772 Porting code from or to other compilers
29773 \begin_inset LatexCommand \label{sec:Porting-code-to-other-compilers}
29774
29775 \end_inset
29776
29777
29778 \end_layout
29779
29780 \begin_layout Itemize
29781 check whether endianness of the compilers differs and adapt where needed.
29782 \end_layout
29783
29784 \begin_layout Itemize
29785 check the device specific header files
29786 \begin_inset LatexCommand \index{Header files}
29787
29788 \end_inset
29789
29790
29791 \begin_inset LatexCommand \index{Include files}
29792
29793 \end_inset
29794
29795  for compiler specific syntax.
29796  Eventually include the file <compiler.h
29797 \begin_inset LatexCommand \index{compiler.h (include file)}
29798
29799 \end_inset
29800
29801 >
29802 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/compiler.h?view=markup}
29803
29804 \end_inset
29805
29806  to allow using common header files.
29807  (see f.e.
29808  cc2510fx.h
29809 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/cc2510fx.h?view=markup}
29810
29811 \end_inset
29812
29813 ).
29814 \end_layout
29815
29816 \begin_layout Itemize
29817 check whether the startup code contains the correct initialization (watchdog,
29818  peripherals).
29819 \end_layout
29820
29821 \begin_layout Itemize
29822 check whether the sizes of short, int, long match.
29823 \end_layout
29824
29825 \begin_layout Itemize
29826 check if some 16 or 32 bit hardware registers require a specific addressing
29827  order (least significant or most significant byte first) and adapt if needed
29828  (
29829 \emph on
29830 first
29831 \emph default
29832  and
29833 \emph on
29834 last
29835 \emph default
29836  relate to time and not to lower/upper memory location here, so this is
29837 \emph on
29838 not
29839 \emph default
29840  the same as endianness).
29841 \end_layout
29842
29843 \begin_layout Itemize
29844 check whether the keyword
29845 \emph on
29846 volatile
29847 \emph default
29848  is used where needed.
29849  The compilers might differ in their optimization characteristics (as different
29850  versions of the same compiler might also use more clever optimizations
29851  this is good idea anyway).
29852  See section
29853 \begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
29854
29855 \end_inset
29856
29857 .
29858 \end_layout
29859
29860 \begin_layout Itemize
29861 check that the compilers are not told to supress warnings.
29862 \end_layout
29863
29864 \begin_layout Itemize
29865 check and convert compiler specific extensions (interrupts, memory areas,
29866  pragmas etc.).
29867 \end_layout
29868
29869 \begin_layout Itemize
29870 check for differences in type promotion.
29871  Especially check for math operations on
29872 \family typewriter
29873 char
29874 \family default
29875  or
29876 \family typewriter
29877 unsigned char
29878 \family default
29879  variables.
29880  For the sake of C99 compatibility SDCC will probably promote these to
29881 \family typewriter
29882 int
29883 \family default
29884  more often than other compilers.
29885  Eventually insert explicit casts to
29886 \family typewriter
29887 (char)
29888 \family default
29889 or
29890 \family typewriter
29891  (unsigned char)
29892 \family default
29893 .
29894  Also check that the ~\InsetSpace ~
29895 operator
29896 \begin_inset LatexCommand \index{\~\/ Operator}
29897
29898 \end_inset
29899
29900  is not used on
29901 \family typewriter
29902 bit
29903 \begin_inset LatexCommand \index{bit}
29904
29905 \end_inset
29906
29907
29908 \family default
29909  variables, use the !\InsetSpace ~
29910 operator instead.
29911  See sections
29912 \begin_inset LatexCommand \ref{type promotion}
29913
29914 \end_inset
29915
29916  and
29917 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
29918
29919 \end_inset
29920
29921 .
29922 \end_layout
29923
29924 \begin_layout Itemize
29925 check the assembly code generated for interrupt routines (f.e.
29926  for calls to possibly non-reentrant library functions).
29927 \end_layout
29928
29929 \begin_layout Itemize
29930 check whether timing loops result in proper timing (or preferably consider
29931  a rewrite of the code with timer based delays instead).
29932 \end_layout
29933
29934 \begin_layout Itemize
29935 check for differences in printf parameters (some compilers push (va_arg
29936 \begin_inset LatexCommand \index{vararg, va\_arg}
29937
29938 \end_inset
29939
29940 ) char variables as
29941 \family typewriter
29942 int
29943 \family default
29944  others push them as
29945 \family typewriter
29946 char
29947 \family default
29948 .
29949  See section
29950 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
29951
29952 \end_inset
29953
29954 ).
29955 \end_layout
29956
29957 \begin_layout Itemize
29958 check the resulting memory map
29959 \begin_inset LatexCommand \index{Memory map}
29960
29961 \end_inset
29962
29963 .
29964  Usage of different memory spaces: code, stack, data (for mcs51/ds390 additional
29965 ly idata, pdata, xdata).
29966  Eventually check if unexpected library functions are included.
29967 \end_layout
29968
29969 \begin_layout Section
29970 Tools
29971 \begin_inset LatexCommand \index{Tools}
29972
29973 \end_inset
29974
29975  included in the distribution
29976 \end_layout
29977
29978 \begin_layout Standard
29979 \align left
29980 \begin_inset Tabular
29981 <lyxtabular version="3" rows="12" columns="3">
29982 <features>
29983 <column alignment="left" valignment="top" leftline="true" width="0pt">
29984 <column alignment="left" valignment="top" leftline="true" width="0pt">
29985 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
29986 <row topline="true" bottomline="true">
29987 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29988 \begin_inset Text
29989
29990 \begin_layout Standard
29991
29992 \series bold
29993 Name
29994 \end_layout
29995
29996 \end_inset
29997 </cell>
29998 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29999 \begin_inset Text
30000
30001 \begin_layout Standard
30002
30003 \series bold
30004 Purpose
30005 \end_layout
30006
30007 \end_inset
30008 </cell>
30009 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30010 \begin_inset Text
30011
30012 \begin_layout Standard
30013
30014 \series bold
30015 Directory
30016 \end_layout
30017
30018 \end_inset
30019 </cell>
30020 </row>
30021 <row topline="true">
30022 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30023 \begin_inset Text
30024
30025 \begin_layout Standard
30026 uCsim
30027 \begin_inset LatexCommand \index{uCsim}
30028
30029 \end_inset
30030
30031
30032 \end_layout
30033
30034 \end_inset
30035 </cell>
30036 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30037 \begin_inset Text
30038
30039 \begin_layout Standard
30040 Simulator for various architectures
30041 \end_layout
30042
30043 \end_inset
30044 </cell>
30045 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30046 \begin_inset Text
30047
30048 \begin_layout Standard
30049 sdcc/sim/ucsim
30050 \end_layout
30051
30052 \end_inset
30053 </cell>
30054 </row>
30055 <row topline="true">
30056 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30057 \begin_inset Text
30058
30059 \begin_layout Standard
30060 keil2sdcc.pl
30061 \end_layout
30062
30063 \end_inset
30064 </cell>
30065 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30066 \begin_inset Text
30067
30068 \begin_layout Standard
30069 header file
30070 \begin_inset LatexCommand \index{Header files}
30071
30072 \end_inset
30073
30074
30075 \begin_inset LatexCommand \index{Include files}
30076
30077 \end_inset
30078
30079  conversion
30080 \end_layout
30081
30082 \end_inset
30083 </cell>
30084 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30085 \begin_inset Text
30086
30087 \begin_layout Standard
30088 sdcc/support/scripts
30089 \end_layout
30090
30091 \end_inset
30092 </cell>
30093 </row>
30094 <row topline="true">
30095 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30096 \begin_inset Text
30097
30098 \begin_layout Standard
30099 mh2h.c
30100 \end_layout
30101
30102 \end_inset
30103 </cell>
30104 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30105 \begin_inset Text
30106
30107 \begin_layout Standard
30108 header file conversion
30109 \end_layout
30110
30111 \end_inset
30112 </cell>
30113 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30114 \begin_inset Text
30115
30116 \begin_layout Standard
30117 sdcc/support/scripts
30118 \end_layout
30119
30120 \end_inset
30121 </cell>
30122 </row>
30123 <row topline="true">
30124 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30125 \begin_inset Text
30126
30127 \begin_layout Standard
30128 as-gbz80
30129 \end_layout
30130
30131 \end_inset
30132 </cell>
30133 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30134 \begin_inset Text
30135
30136 \begin_layout Standard
30137 Assembler
30138 \end_layout
30139
30140 \end_inset
30141 </cell>
30142 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30143 \begin_inset Text
30144
30145 \begin_layout Standard
30146
30147 \family roman
30148 \series medium
30149 \shape up
30150 \size normal
30151 \emph off
30152 \bar no
30153 \noun off
30154 \color none
30155 sdcc/bin
30156 \end_layout
30157
30158 \end_inset
30159 </cell>
30160 </row>
30161 <row topline="true">
30162 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30163 \begin_inset Text
30164
30165 \begin_layout Standard
30166 as-z80
30167 \end_layout
30168
30169 \end_inset
30170 </cell>
30171 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30172 \begin_inset Text
30173
30174 \begin_layout Standard
30175 Assembler
30176 \end_layout
30177
30178 \end_inset
30179 </cell>
30180 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30181 \begin_inset Text
30182
30183 \begin_layout Standard
30184
30185 \family roman
30186 \series medium
30187 \shape up
30188 \size normal
30189 \emph off
30190 \bar no
30191 \noun off
30192 \color none
30193 sdcc/bin
30194 \end_layout
30195
30196 \end_inset
30197 </cell>
30198 </row>
30199 <row topline="true">
30200 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30201 \begin_inset Text
30202
30203 \begin_layout Standard
30204 asx8051
30205 \end_layout
30206
30207 \end_inset
30208 </cell>
30209 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30210 \begin_inset Text
30211
30212 \begin_layout Standard
30213 Assembler
30214 \end_layout
30215
30216 \end_inset
30217 </cell>
30218 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30219 \begin_inset Text
30220
30221 \begin_layout Standard
30222
30223 \family roman
30224 \series medium
30225 \shape up
30226 \size normal
30227 \emph off
30228 \bar no
30229 \noun off
30230 \color none
30231 sdcc/bin
30232 \end_layout
30233
30234 \end_inset
30235 </cell>
30236 </row>
30237 <row topline="true">
30238 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30239 \begin_inset Text
30240
30241 \begin_layout Standard
30242 SDCDB
30243 \end_layout
30244
30245 \end_inset
30246 </cell>
30247 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30248 \begin_inset Text
30249
30250 \begin_layout Standard
30251 Simulator
30252 \end_layout
30253
30254 \end_inset
30255 </cell>
30256 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30257 \begin_inset Text
30258
30259 \begin_layout Standard
30260
30261 \family roman
30262 \series medium
30263 \shape up
30264 \size normal
30265 \emph off
30266 \bar no
30267 \noun off
30268 \color none
30269 sdcc/bin
30270 \end_layout
30271
30272 \end_inset
30273 </cell>
30274 </row>
30275 <row topline="true">
30276 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30277 \begin_inset Text
30278
30279 \begin_layout Standard
30280 aslink
30281 \end_layout
30282
30283 \end_inset
30284 </cell>
30285 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30286 \begin_inset Text
30287
30288 \begin_layout Standard
30289 Linker
30290 \end_layout
30291
30292 \end_inset
30293 </cell>
30294 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30295 \begin_inset Text
30296
30297 \begin_layout Standard
30298
30299 \family roman
30300 \series medium
30301 \shape up
30302 \size normal
30303 \emph off
30304 \bar no
30305 \noun off
30306 \color none
30307 sdcc/bin
30308 \end_layout
30309
30310 \end_inset
30311 </cell>
30312 </row>
30313 <row topline="true">
30314 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30315 \begin_inset Text
30316
30317 \begin_layout Standard
30318 link-z80
30319 \end_layout
30320
30321 \end_inset
30322 </cell>
30323 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30324 \begin_inset Text
30325
30326 \begin_layout Standard
30327 Linker
30328 \end_layout
30329
30330 \end_inset
30331 </cell>
30332 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30333 \begin_inset Text
30334
30335 \begin_layout Standard
30336
30337 \family roman
30338 \series medium
30339 \shape up
30340 \size normal
30341 \emph off
30342 \bar no
30343 \noun off
30344 \color none
30345 sdcc/bin
30346 \end_layout
30347
30348 \end_inset
30349 </cell>
30350 </row>
30351 <row topline="true">
30352 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30353 \begin_inset Text
30354
30355 \begin_layout Standard
30356 link-gbz80
30357 \end_layout
30358
30359 \end_inset
30360 </cell>
30361 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30362 \begin_inset Text
30363
30364 \begin_layout Standard
30365 Linker
30366 \end_layout
30367
30368 \end_inset
30369 </cell>
30370 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30371 \begin_inset Text
30372
30373 \begin_layout Standard
30374
30375 \family roman
30376 \series medium
30377 \shape up
30378 \size normal
30379 \emph off
30380 \bar no
30381 \noun off
30382 \color none
30383 sdcc/bin
30384 \end_layout
30385
30386 \end_inset
30387 </cell>
30388 </row>
30389 <row topline="true" bottomline="true">
30390 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30391 \begin_inset Text
30392
30393 \begin_layout Standard
30394 packihx
30395 \end_layout
30396
30397 \end_inset
30398 </cell>
30399 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30400 \begin_inset Text
30401
30402 \begin_layout Standard
30403 Intel Hex packer
30404 \begin_inset LatexCommand \index{packihx (tool)}
30405
30406 \end_inset
30407
30408
30409 \end_layout
30410
30411 \end_inset
30412 </cell>
30413 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30414 \begin_inset Text
30415
30416 \begin_layout Standard
30417
30418 \family roman
30419 \series medium
30420 \shape up
30421 \size normal
30422 \emph off
30423 \bar no
30424 \noun off
30425 \color none
30426 sdcc/bin
30427 \end_layout
30428
30429 \end_inset
30430 </cell>
30431 </row>
30432 </lyxtabular>
30433
30434 \end_inset
30435
30436
30437 \newline
30438
30439 \end_layout
30440
30441 \begin_layout Section
30442 Documentation
30443 \begin_inset LatexCommand \index{Documentation}
30444
30445 \end_inset
30446
30447  included in the distribution
30448 \end_layout
30449
30450 \begin_layout Standard
30451 \align left
30452 \begin_inset Tabular
30453 <lyxtabular version="3" rows="10" columns="2">
30454 <features>
30455 <column alignment="block" valignment="top" leftline="true" width="40col%">
30456 <column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
30457 <row topline="true" bottomline="true" endhead="true">
30458 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30459 \begin_inset Text
30460
30461 \begin_layout Standard
30462
30463 \series bold
30464 Subject / Title
30465 \end_layout
30466
30467 \end_inset
30468 </cell>
30469 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30470 \begin_inset Text
30471
30472 \begin_layout Standard
30473
30474 \series bold
30475 Filename / Where to get
30476 \end_layout
30477
30478 \end_inset
30479 </cell>
30480 </row>
30481 <row topline="true">
30482 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30483 \begin_inset Text
30484
30485 \begin_layout Standard
30486 SDCC Compiler User Guide
30487 \end_layout
30488
30489 \end_inset
30490 </cell>
30491 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30492 \begin_inset Text
30493
30494 \begin_layout Standard
30495 You're reading it right now
30496 \emph on
30497  \InsetSpace ~
30498 \InsetSpace ~
30499 \InsetSpace ~
30500
30501 \hfill
30502 online at:
30503 \emph default
30504
30505 \newline
30506
30507 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
30508
30509 \end_inset
30510
30511
30512 \end_layout
30513
30514 \end_inset
30515 </cell>
30516 </row>
30517 <row topline="true">
30518 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30519 \begin_inset Text
30520
30521 \begin_layout Standard
30522 Changelog of SDCC
30523 \end_layout
30524
30525 \end_inset
30526 </cell>
30527 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30528 \begin_inset Text
30529
30530 \begin_layout Standard
30531 sdcc/Changelog
30532 \emph on
30533  \InsetSpace ~
30534 \InsetSpace ~
30535 \InsetSpace ~
30536
30537 \hfill
30538 online at:
30539 \emph default
30540
30541 \newline
30542
30543 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog}
30544
30545 \end_inset
30546
30547
30548 \end_layout
30549
30550 \end_inset
30551 </cell>
30552 </row>
30553 <row topline="true">
30554 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30555 \begin_inset Text
30556
30557 \begin_layout Standard
30558 ASXXXX
30559 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
30560
30561 \end_inset
30562
30563
30564 \begin_inset LatexCommand \index{Assembler documentation}
30565
30566 \end_inset
30567
30568  Assemblers and
30569 \newline
30570 ASLINK
30571 \begin_inset LatexCommand \index{aslink}
30572
30573 \end_inset
30574
30575
30576 \begin_inset LatexCommand \index{Linker documentation}
30577
30578 \end_inset
30579
30580  Relocating Linker
30581 \end_layout
30582
30583 \end_inset
30584 </cell>
30585 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30586 \begin_inset Text
30587
30588 \begin_layout Standard
30589 sdcc/as/doc/asxhtm.html
30590 \emph on
30591 \InsetSpace ~
30592 \InsetSpace ~
30593 \InsetSpace ~
30594
30595 \hfill
30596 online at:
30597 \emph default
30598
30599 \newline
30600
30601 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
30602
30603 \end_inset
30604
30605
30606 \end_layout
30607
30608 \end_inset
30609 </cell>
30610 </row>
30611 <row topline="true">
30612 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30613 \begin_inset Text
30614
30615 \begin_layout Standard
30616 SDCC regression test
30617 \begin_inset LatexCommand \index{Regression test}
30618
30619 \end_inset
30620
30621
30622 \end_layout
30623
30624 \end_inset
30625 </cell>
30626 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30627 \begin_inset Text
30628
30629 \begin_layout Standard
30630 sdcc/doc/test_suite_spec.pdf
30631 \emph on
30632 \InsetSpace ~
30633 \InsetSpace ~
30634 \InsetSpace ~
30635
30636 \hfill
30637 online at:
30638 \emph default
30639
30640 \newline
30641
30642 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
30643
30644 \end_inset
30645
30646
30647 \end_layout
30648
30649 \end_inset
30650 </cell>
30651 </row>
30652 <row topline="true">
30653 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30654 \begin_inset Text
30655
30656 \begin_layout Standard
30657 Various notes
30658 \end_layout
30659
30660 \end_inset
30661 </cell>
30662 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30663 \begin_inset Text
30664
30665 \begin_layout Standard
30666 sdcc/doc/*
30667 \emph on
30668 \InsetSpace ~
30669 \InsetSpace ~
30670 \InsetSpace ~
30671
30672 \hfill
30673 online at:
30674 \emph default
30675
30676 \newline
30677
30678 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/doc/}
30679
30680 \end_inset
30681
30682
30683 \end_layout
30684
30685 \end_inset
30686 </cell>
30687 </row>
30688 <row topline="true">
30689 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30690 \begin_inset Text
30691
30692 \begin_layout Standard
30693 Notes on debugging with SDCDB
30694 \begin_inset LatexCommand \index{SDCDB (debugger)}
30695
30696 \end_inset
30697
30698
30699 \end_layout
30700
30701 \end_inset
30702 </cell>
30703 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30704 \begin_inset Text
30705
30706 \begin_layout Standard
30707 sdcc/debugger/README
30708 \emph on
30709 \InsetSpace ~
30710 \InsetSpace ~
30711 \InsetSpace ~
30712
30713 \hfill
30714 online at
30715 \emph default
30716 :
30717 \newline
30718
30719 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README}
30720
30721 \end_inset
30722
30723
30724 \end_layout
30725
30726 \end_inset
30727 </cell>
30728 </row>
30729 <row topline="true">
30730 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30731 \begin_inset Text
30732
30733 \begin_layout Standard
30734 uCsim
30735 \begin_inset LatexCommand \index{uCsim}
30736
30737 \end_inset
30738
30739  Software simulator for microcontrollers
30740 \end_layout
30741
30742 \end_inset
30743 </cell>
30744 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30745 \begin_inset Text
30746
30747 \begin_layout Standard
30748
30749 \family roman
30750 \series medium
30751 \shape up
30752 \size normal
30753 \emph off
30754 \bar no
30755 \noun off
30756 \color none
30757 sdcc/sim/ucsim/doc
30758 \family default
30759 \series default
30760 \shape default
30761 \size default
30762 \emph default
30763 \bar default
30764 \noun default
30765 /index.html
30766 \emph on
30767 \InsetSpace ~
30768 \InsetSpace ~
30769 \InsetSpace ~
30770
30771 \hfill
30772 online at:
30773 \emph default
30774
30775 \newline
30776
30777 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html}
30778
30779 \end_inset
30780
30781
30782 \end_layout
30783
30784 \end_inset
30785 </cell>
30786 </row>
30787 <row topline="true">
30788 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30789 \begin_inset Text
30790
30791 \begin_layout Standard
30792 Temporary notes on the pic16
30793 \begin_inset LatexCommand \index{PIC16}
30794
30795 \end_inset
30796
30797  port
30798 \end_layout
30799
30800 \end_inset
30801 </cell>
30802 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30803 \begin_inset Text
30804
30805 \begin_layout Standard
30806 sdcc/src/pic16/NOTES
30807 \emph on
30808 \InsetSpace ~
30809 \InsetSpace ~
30810 \InsetSpace ~
30811
30812 \hfill
30813 online at:
30814 \newline
30815
30816 \emph default
30817
30818 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES}
30819
30820 \end_inset
30821
30822
30823 \end_layout
30824
30825 \end_inset
30826 </cell>
30827 </row>
30828 <row topline="true" bottomline="true">
30829 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30830 \begin_inset Text
30831
30832 \begin_layout Standard
30833 SDCC internal documentation (debugging file format)
30834 \end_layout
30835
30836 \end_inset
30837 </cell>
30838 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30839 \begin_inset Text
30840
30841 \begin_layout Standard
30842 sdcc/doc/
30843 \family roman
30844 \series medium
30845 \shape up
30846 \size normal
30847 \emph off
30848 \bar no
30849 \noun off
30850 \color none
30851 cdbfileformat.pd
30852 \family default
30853 \series default
30854 \shape default
30855 \size default
30856 \emph default
30857 \bar default
30858 \noun default
30859 f
30860 \emph on
30861  \InsetSpace ~
30862 \InsetSpace ~
30863 \InsetSpace ~
30864
30865 \hfill
30866 online at:
30867 \emph default
30868
30869 \newline
30870
30871 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/cdbfileformat.pdf}
30872
30873 \end_inset
30874
30875
30876 \end_layout
30877
30878 \end_inset
30879 </cell>
30880 </row>
30881 </lyxtabular>
30882
30883 \end_inset
30884
30885
30886 \newline
30887
30888 \end_layout
30889
30890 \begin_layout Section
30891 Related open source tools
30892 \begin_inset LatexCommand \label{sec:Related-open-source-tools}
30893
30894 \end_inset
30895
30896
30897 \begin_inset LatexCommand \index{Related tools}
30898
30899 \end_inset
30900
30901
30902 \end_layout
30903
30904 \begin_layout Standard
30905 \align left
30906 \begin_inset Tabular
30907 <lyxtabular version="3" rows="16" columns="3">
30908 <features>
30909 <column alignment="left" valignment="top" leftline="true" width="0pt">
30910 <column alignment="block" valignment="top" leftline="true" width="30line%">
30911 <column alignment="left" valignment="top" leftline="true" rightline="true" width="40col%">
30912 <row topline="true" bottomline="true">
30913 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30914 \begin_inset Text
30915
30916 \begin_layout Standard
30917
30918 \series bold
30919 Name
30920 \end_layout
30921
30922 \end_inset
30923 </cell>
30924 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30925 \begin_inset Text
30926
30927 \begin_layout Standard
30928
30929 \series bold
30930 Purpose
30931 \end_layout
30932
30933 \end_inset
30934 </cell>
30935 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30936 \begin_inset Text
30937
30938 \begin_layout Standard
30939
30940 \series bold
30941 Where to get
30942 \end_layout
30943
30944 \end_inset
30945 </cell>
30946 </row>
30947 <row topline="true">
30948 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30949 \begin_inset Text
30950
30951 \begin_layout Standard
30952 gpsim
30953 \begin_inset LatexCommand \index{gpsim (pic simulator)}
30954
30955 \end_inset
30956
30957
30958 \end_layout
30959
30960 \end_inset
30961 </cell>
30962 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30963 \begin_inset Text
30964
30965 \begin_layout Standard
30966 PIC simulator
30967 \end_layout
30968
30969 \end_inset
30970 </cell>
30971 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30972 \begin_inset Text
30973
30974 \begin_layout Standard
30975 \begin_inset LatexCommand \url{http://www.dattalo.com/gnupic/gpsim.html}
30976
30977 \end_inset
30978
30979
30980 \end_layout
30981
30982 \end_inset
30983 </cell>
30984 </row>
30985 <row topline="true">
30986 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30987 \begin_inset Text
30988
30989 \begin_layout Standard
30990 gputils
30991 \begin_inset LatexCommand \index{gputils (pic tools)}
30992
30993 \end_inset
30994
30995
30996 \end_layout
30997
30998 \end_inset
30999 </cell>
31000 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31001 \begin_inset Text
31002
31003 \begin_layout Standard
31004 GNU PIC utilities
31005 \end_layout
31006
31007 \end_inset
31008 </cell>
31009 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31010 \begin_inset Text
31011
31012 \begin_layout Standard
31013 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
31014
31015 \end_inset
31016
31017
31018 \end_layout
31019
31020 \end_inset
31021 </cell>
31022 </row>
31023 <row topline="true">
31024 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31025 \begin_inset Text
31026
31027 \begin_layout Standard
31028 flP5
31029 \end_layout
31030
31031 \end_inset
31032 </cell>
31033 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31034 \begin_inset Text
31035
31036 \begin_layout Standard
31037 PIC programmer
31038 \end_layout
31039
31040 \end_inset
31041 </cell>
31042 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31043 \begin_inset Text
31044
31045 \begin_layout Standard
31046 \begin_inset LatexCommand \url{http://freshmeat.net/projects/flp5/}
31047
31048 \end_inset
31049
31050
31051 \end_layout
31052
31053 \end_inset
31054 </cell>
31055 </row>
31056 <row topline="true">
31057 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31058 \begin_inset Text
31059
31060 \begin_layout Standard
31061 ec2drv/newcdb
31062 \end_layout
31063
31064 \end_inset
31065 </cell>
31066 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31067 \begin_inset Text
31068
31069 \begin_layout Standard
31070 Tools for Silicon Laboratories JTAG debug adapter, partly based on SDCDB
31071  (Unix only)
31072 \end_layout
31073
31074 \end_inset
31075 </cell>
31076 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31077 \begin_inset Text
31078
31079 \begin_layout Standard
31080 \begin_inset LatexCommand \url{http://sourceforge.net/projects/ec2drv}
31081
31082 \end_inset
31083
31084
31085 \end_layout
31086
31087 \end_inset
31088 </cell>
31089 </row>
31090 <row topline="true">
31091 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31092 \begin_inset Text
31093
31094 \begin_layout Standard
31095 indent
31096 \begin_inset LatexCommand \index{indent (source formatting tool)}
31097
31098 \end_inset
31099
31100
31101 \end_layout
31102
31103 \end_inset
31104 </cell>
31105 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31106 \begin_inset Text
31107
31108 \begin_layout Standard
31109 Formats C source - Master of the white spaces
31110 \end_layout
31111
31112 \end_inset
31113 </cell>
31114 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31115 \begin_inset Text
31116
31117 \begin_layout Standard
31118 \begin_inset LatexCommand \url{http://directory.fsf.org/GNU/indent.html}
31119
31120 \end_inset
31121
31122
31123 \end_layout
31124
31125 \end_inset
31126 </cell>
31127 </row>
31128 <row topline="true">
31129 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31130 \begin_inset Text
31131
31132 \begin_layout Standard
31133 srecord
31134 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
31135
31136 \end_inset
31137
31138
31139 \end_layout
31140
31141 \end_inset
31142 </cell>
31143 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31144 \begin_inset Text
31145
31146 \begin_layout Standard
31147 Object file conversion, checksumming, ...
31148 \end_layout
31149
31150 \end_inset
31151 </cell>
31152 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31153 \begin_inset Text
31154
31155 \begin_layout Standard
31156 \begin_inset LatexCommand \url{http://sourceforge.net/projects/srecord}
31157
31158 \end_inset
31159
31160
31161 \end_layout
31162
31163 \end_inset
31164 </cell>
31165 </row>
31166 <row topline="true">
31167 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31168 \begin_inset Text
31169
31170 \begin_layout Standard
31171 objdump
31172 \begin_inset LatexCommand \index{objdump (tool)}
31173
31174 \end_inset
31175
31176
31177 \end_layout
31178
31179 \end_inset
31180 </cell>
31181 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31182 \begin_inset Text
31183
31184 \begin_layout Standard
31185 Object file conversion, ...
31186 \end_layout
31187
31188 \end_inset
31189 </cell>
31190 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31191 \begin_inset Text
31192
31193 \begin_layout Standard
31194 Part of binutils (should be there anyway)
31195 \end_layout
31196
31197 \end_inset
31198 </cell>
31199 </row>
31200 <row topline="true">
31201 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31202 \begin_inset Text
31203
31204 \begin_layout Standard
31205 cmon51
31206 \end_layout
31207
31208 \end_inset
31209 </cell>
31210 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31211 \begin_inset Text
31212
31213 \begin_layout Standard
31214 8051 monitor (hex up-/download, single step, disassemble)
31215 \end_layout
31216
31217 \end_inset
31218 </cell>
31219 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31220 \begin_inset Text
31221
31222 \begin_layout Standard
31223 \begin_inset LatexCommand \url{http://sourceforge.net/projects/cmon51}
31224
31225 \end_inset
31226
31227
31228 \end_layout
31229
31230 \end_inset
31231 </cell>
31232 </row>
31233 <row topline="true">
31234 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31235 \begin_inset Text
31236
31237 \begin_layout Standard
31238 doxygen
31239 \begin_inset LatexCommand \index{doxygen (source documentation tool)}
31240
31241 \end_inset
31242
31243
31244 \end_layout
31245
31246 \end_inset
31247 </cell>
31248 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31249 \begin_inset Text
31250
31251 \begin_layout Standard
31252 Source code documentation system
31253 \end_layout
31254
31255 \end_inset
31256 </cell>
31257 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31258 \begin_inset Text
31259
31260 \begin_layout Standard
31261 \begin_inset LatexCommand \url{http://www.doxygen.org}
31262
31263 \end_inset
31264
31265
31266 \end_layout
31267
31268 \end_inset
31269 </cell>
31270 </row>
31271 <row topline="true">
31272 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31273 \begin_inset Text
31274
31275 \begin_layout Standard
31276 kdevelop
31277 \end_layout
31278
31279 \end_inset
31280 </cell>
31281 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31282 \begin_inset Text
31283
31284 \begin_layout Standard
31285 IDE (has anyone tried integrating SDCC & SDCDB? Unix only)
31286 \end_layout
31287
31288 \end_inset
31289 </cell>
31290 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31291 \begin_inset Text
31292
31293 \begin_layout Standard
31294 \begin_inset LatexCommand \url{http://www.kdevelop.org}
31295
31296 \end_inset
31297
31298
31299 \end_layout
31300
31301 \end_inset
31302 </cell>
31303 </row>
31304 <row topline="true">
31305 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31306 \begin_inset Text
31307
31308 \begin_layout Standard
31309 paulmon
31310 \end_layout
31311
31312 \end_inset
31313 </cell>
31314 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31315 \begin_inset Text
31316
31317 \begin_layout Standard
31318 8051 monitor (hex up-/download, single step, disassemble)
31319 \end_layout
31320
31321 \end_inset
31322 </cell>
31323 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31324 \begin_inset Text
31325
31326 \begin_layout Standard
31327 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/paulmon2.html}
31328
31329 \end_inset
31330
31331
31332 \end_layout
31333
31334 \end_inset
31335 </cell>
31336 </row>
31337 <row topline="true">
31338 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31339 \begin_inset Text
31340
31341 \begin_layout Standard
31342 splint
31343 \begin_inset LatexCommand \index{splint (syntax checking tool)}
31344
31345 \end_inset
31346
31347
31348 \end_layout
31349
31350 \end_inset
31351 </cell>
31352 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31353 \begin_inset Text
31354
31355 \begin_layout Standard
31356 Statically checks c sources (see
31357 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
31358
31359 \end_inset
31360
31361 )
31362 \end_layout
31363
31364 \end_inset
31365 </cell>
31366 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31367 \begin_inset Text
31368
31369 \begin_layout Standard
31370 \begin_inset LatexCommand \url{http://www.splint.org}
31371
31372 \end_inset
31373
31374
31375 \end_layout
31376
31377 \end_inset
31378 </cell>
31379 </row>
31380 <row topline="true" bottomline="true">
31381 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31382 \begin_inset Text
31383
31384 \begin_layout Standard
31385 ddd
31386 \begin_inset LatexCommand \index{DDD (debugger)}
31387
31388 \end_inset
31389
31390
31391 \end_layout
31392
31393 \end_inset
31394 </cell>
31395 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31396 \begin_inset Text
31397
31398 \begin_layout Standard
31399 Debugger, serves nicely as GUI to SDCDB
31400 \begin_inset LatexCommand \index{SDCDB (debugger)}
31401
31402 \end_inset
31403
31404  (Unix only)
31405 \end_layout
31406
31407 \end_inset
31408 </cell>
31409 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31410 \begin_inset Text
31411
31412 \begin_layout Standard
31413 \begin_inset LatexCommand \url{http://www.gnu.org/software/ddd/}
31414
31415 \end_inset
31416
31417
31418 \end_layout
31419
31420 \end_inset
31421 </cell>
31422 </row>
31423 <row bottomline="true">
31424 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31425 \begin_inset Text
31426
31427 \begin_layout Standard
31428 d52
31429 \begin_inset LatexCommand \index{d52}
31430
31431 \end_inset
31432
31433
31434 \begin_inset LatexCommand \index{d52 (disassembler)}
31435
31436 \end_inset
31437
31438
31439 \end_layout
31440
31441 \end_inset
31442 </cell>
31443 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31444 \begin_inset Text
31445
31446 \begin_layout Standard
31447 Disassembler, can count instruction cycles
31448 \begin_inset LatexCommand \index{instruction cycles (count)}
31449
31450 \end_inset
31451
31452 , use with options -pnd
31453 \end_layout
31454
31455 \end_inset
31456 </cell>
31457 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31458 \begin_inset Text
31459
31460 \begin_layout Standard
31461 \begin_inset LatexCommand \url{http://www.8052.com/users/disasm/}
31462
31463 \end_inset
31464
31465
31466 \end_layout
31467
31468 \end_inset
31469 </cell>
31470 </row>
31471 <row bottomline="true">
31472 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31473 \begin_inset Text
31474
31475 \begin_layout Standard
31476 cmake
31477 \begin_inset LatexCommand \index{cmake}
31478
31479 \end_inset
31480
31481
31482 \end_layout
31483
31484 \end_inset
31485 </cell>
31486 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31487 \begin_inset Text
31488
31489 \begin_layout Standard
31490 Cross platform build system, generates Makefiles
31491 \begin_inset LatexCommand \index{Makefile}
31492
31493 \end_inset
31494
31495  and project workspaces
31496 \begin_inset LatexCommand \index{project workspace}
31497
31498 \end_inset
31499
31500
31501 \end_layout
31502
31503 \end_inset
31504 </cell>
31505 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31506 \begin_inset Text
31507
31508 \begin_layout Standard
31509 \begin_inset LatexCommand \url{http://www.cmake.org}
31510
31511 \end_inset
31512
31513  \InsetSpace ~
31514 \InsetSpace ~
31515 \InsetSpace ~
31516 \InsetSpace ~
31517 and a dedicated wiki entry:
31518 \begin_inset LatexCommand \url{http://www.cmake.org/Wiki/CmakeSdcc}
31519
31520 \end_inset
31521
31522
31523 \end_layout
31524
31525 \end_inset
31526 </cell>
31527 </row>
31528 </lyxtabular>
31529
31530 \end_inset
31531
31532
31533 \newline
31534
31535 \end_layout
31536
31537 \begin_layout Section
31538 Related documentation / recommended reading
31539 \end_layout
31540
31541 \begin_layout Standard
31542 \align left
31543 \begin_inset Tabular
31544 <lyxtabular version="3" rows="7" columns="3">
31545 <features>
31546 <column alignment="left" valignment="top" leftline="true" width="0pt">
31547 <column alignment="left" valignment="top" leftline="true" width="0">
31548 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
31549 <row topline="true" bottomline="true">
31550 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31551 \begin_inset Text
31552
31553 \begin_layout Standard
31554
31555 \series bold
31556 Name
31557 \end_layout
31558
31559 \end_inset
31560 </cell>
31561 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31562 \begin_inset Text
31563
31564 \begin_layout Standard
31565
31566 \series bold
31567 Subject / Title
31568 \end_layout
31569
31570 \end_inset
31571 </cell>
31572 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31573 \begin_inset Text
31574
31575 \begin_layout Standard
31576
31577 \series bold
31578 Where to get
31579 \end_layout
31580
31581 \end_inset
31582 </cell>
31583 </row>
31584 <row topline="true">
31585 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31586 \begin_inset Text
31587
31588 \begin_layout Standard
31589
31590 \family roman
31591 \series medium
31592 \shape up
31593 \size normal
31594 \emph off
31595 \bar no
31596 \noun off
31597 \color none
31598 c-refcard.pdf
31599 \end_layout
31600
31601 \end_inset
31602 </cell>
31603 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31604 \begin_inset Text
31605
31606 \begin_layout Standard
31607 C Reference Card
31608 \begin_inset LatexCommand \index{C Reference card}
31609
31610 \end_inset
31611
31612 , 2 pages
31613 \end_layout
31614
31615 \end_inset
31616 </cell>
31617 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31618 \begin_inset Text
31619
31620 \begin_layout Standard
31621 \begin_inset LatexCommand \url{http://refcards.com/refcards/c/index.html}
31622
31623 \end_inset
31624
31625
31626 \end_layout
31627
31628 \end_inset
31629 </cell>
31630 </row>
31631 <row topline="true">
31632 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31633 \begin_inset Text
31634
31635 \begin_layout Standard
31636 c-faq
31637 \end_layout
31638
31639 \end_inset
31640 </cell>
31641 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31642 \begin_inset Text
31643
31644 \begin_layout Standard
31645 C-FAQ
31646 \begin_inset LatexCommand \index{C FAQ}
31647
31648 \end_inset
31649
31650
31651 \end_layout
31652
31653 \end_inset
31654 </cell>
31655 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31656 \begin_inset Text
31657
31658 \begin_layout Standard
31659 \begin_inset LatexCommand \url{http://www.c-faq.com}
31660
31661 \end_inset
31662
31663
31664 \end_layout
31665
31666 \end_inset
31667 </cell>
31668 </row>
31669 <row topline="true">
31670 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31671 \begin_inset Text
31672
31673 \begin_layout Standard
31674 ISO/IEC 9899:TC2
31675 \end_layout
31676
31677 \end_inset
31678 </cell>
31679 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31680 \begin_inset Text
31681
31682 \begin_layout Standard
31683 \begin_inset Quotes sld
31684 \end_inset
31685
31686 C-Standard
31687 \begin_inset Quotes srd
31688 \end_inset
31689
31690
31691 \end_layout
31692
31693 \end_inset
31694 </cell>
31695 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31696 \begin_inset Text
31697
31698 \begin_layout Standard
31699
31700 \size footnotesize
31701 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
31702
31703 \end_inset
31704
31705
31706 \end_layout
31707
31708 \end_inset
31709 </cell>
31710 </row>
31711 <row topline="true">
31712 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31713 \begin_inset Text
31714
31715 \begin_layout Standard
31716 ISO/IEC DTR 18037
31717 \end_layout
31718
31719 \end_inset
31720 </cell>
31721 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31722 \begin_inset Text
31723
31724 \begin_layout Standard
31725 \begin_inset Quotes sld
31726 \end_inset
31727
31728 Extensions for Embedded C
31729 \begin_inset Quotes srd
31730 \end_inset
31731
31732
31733 \end_layout
31734
31735 \end_inset
31736 </cell>
31737 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31738 \begin_inset Text
31739
31740 \begin_layout Standard
31741
31742 \size footnotesize
31743 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1021.pdf}
31744
31745 \end_inset
31746
31747
31748 \end_layout
31749
31750 \end_inset
31751 </cell>
31752 </row>
31753 <row topline="true">
31754 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31755 \begin_inset Text
31756
31757 \begin_layout Standard
31758
31759 \end_layout
31760
31761 \end_inset
31762 </cell>
31763 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31764 \begin_inset Text
31765
31766 \begin_layout Standard
31767 Latest datasheet of target CPU
31768 \end_layout
31769
31770 \end_inset
31771 </cell>
31772 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31773 \begin_inset Text
31774
31775 \begin_layout Standard
31776 vendor
31777 \end_layout
31778
31779 \end_inset
31780 </cell>
31781 </row>
31782 <row topline="true" bottomline="true">
31783 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31784 \begin_inset Text
31785
31786 \begin_layout Standard
31787
31788 \end_layout
31789
31790 \end_inset
31791 </cell>
31792 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31793 \begin_inset Text
31794
31795 \begin_layout Standard
31796 Revision history of datasheet
31797 \end_layout
31798
31799 \end_inset
31800 </cell>
31801 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31802 \begin_inset Text
31803
31804 \begin_layout Standard
31805 vendor
31806 \end_layout
31807
31808 \end_inset
31809 </cell>
31810 </row>
31811 </lyxtabular>
31812
31813 \end_inset
31814
31815
31816 \newline
31817
31818 \end_layout
31819
31820 \begin_layout Section
31821 Application notes specifically for SDCC
31822 \end_layout
31823
31824 \begin_layout Standard
31825 SDCC makes no claims about the completeness of this list and about up-to-datenes
31826 s or correctness of the application notes
31827 \begin_inset LatexCommand \index{Application notes}
31828
31829 \end_inset
31830
31831 .
31832 \end_layout
31833
31834 \begin_layout Standard
31835 \align left
31836
31837 \size footnotesize
31838 \begin_inset Tabular
31839 <lyxtabular version="3" rows="7" columns="3">
31840 <features>
31841 <column alignment="block" valignment="top" leftline="true" width="17col%">
31842 <column alignment="block" valignment="top" leftline="true" width="27col%">
31843 <column alignment="block" valignment="top" leftline="true" rightline="true" width="57col%">
31844 <row topline="true" bottomline="true">
31845 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31846 \begin_inset Text
31847
31848 \begin_layout Standard
31849
31850 \series bold
31851 \size footnotesize
31852 Vendor
31853 \end_layout
31854
31855 \end_inset
31856 </cell>
31857 <cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
31858 \begin_inset Text
31859
31860 \begin_layout Standard
31861
31862 \series bold
31863 \size footnotesize
31864 Subject / Title
31865 \end_layout
31866
31867 \end_inset
31868 </cell>
31869 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31870 \begin_inset Text
31871
31872 \begin_layout Standard
31873
31874 \series bold
31875 \size footnotesize
31876 Where to get
31877 \end_layout
31878
31879 \end_inset
31880 </cell>
31881 </row>
31882 <row topline="true">
31883 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31884 \begin_inset Text
31885
31886 \begin_layout Standard
31887
31888 \size footnotesize
31889 Maxim / Dallas
31890 \end_layout
31891
31892 \end_inset
31893 </cell>
31894 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31895 \begin_inset Text
31896
31897 \begin_layout Standard
31898
31899 \size footnotesize
31900 Using the SDCC Compiler for the DS80C400
31901 \begin_inset LatexCommand \index{DS80C400}
31902
31903 \end_inset
31904
31905
31906 \end_layout
31907
31908 \end_inset
31909 </cell>
31910 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31911 \begin_inset Text
31912
31913 \begin_layout Standard
31914
31915 \size footnotesize
31916 \begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3346.pdf}
31917
31918 \end_inset
31919
31920
31921 \end_layout
31922
31923 \end_inset
31924 </cell>
31925 </row>
31926 <row topline="true">
31927 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31928 \begin_inset Text
31929
31930 \begin_layout Standard
31931
31932 \size footnotesize
31933 Maxim / Dallas
31934 \end_layout
31935
31936 \end_inset
31937 </cell>
31938 <cell multicolumn="1" alignment="left" valignment="top" topline="true" leftline="true" usebox="none" width="30line%">
31939 \begin_inset Text
31940
31941 \begin_layout Standard
31942
31943 \size footnotesize
31944 Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450
31945 \begin_inset LatexCommand \index{DS89C4x0}
31946
31947 \end_inset
31948
31949  Family of Microcontrollers
31950 \end_layout
31951
31952 \end_inset
31953 </cell>
31954 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31955 \begin_inset Text
31956
31957 \begin_layout Standard
31958
31959 \size footnotesize
31960 \begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3477.pdf}
31961
31962 \end_inset
31963
31964
31965 \end_layout
31966
31967 \end_inset
31968 </cell>
31969 </row>
31970 <row topline="true">
31971 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31972 \begin_inset Text
31973
31974 \begin_layout Standard
31975
31976 \size footnotesize
31977 Silicon Laboratories / Cygnal
31978 \end_layout
31979
31980 \end_inset
31981 </cell>
31982 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31983 \begin_inset Text
31984
31985 \begin_layout Standard
31986
31987 \size footnotesize
31988 Integrating SDCC 8051 Tools Into The Silicon Labs IDE
31989 \begin_inset LatexCommand \index{IDE}
31990
31991 \end_inset
31992
31993
31994 \end_layout
31995
31996 \end_inset
31997 </cell>
31998 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31999 \begin_inset Text
32000
32001 \begin_layout Standard
32002
32003 \size footnotesize
32004 \begin_inset LatexCommand \url{http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/en/an198.pdf}
32005
32006 \end_inset
32007
32008
32009 \end_layout
32010
32011 \end_inset
32012 </cell>
32013 </row>
32014 <row topline="true">
32015 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32016 \begin_inset Text
32017
32018 \begin_layout Standard
32019
32020 \size footnotesize
32021 Ramtron / Goal Semiconductor
32022 \end_layout
32023
32024 \end_inset
32025 </cell>
32026 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32027 \begin_inset Text
32028
32029 \begin_layout Standard
32030
32031 \size footnotesize
32032 Interfacing SDCC to Syn and Textpad
32033 \end_layout
32034
32035 \end_inset
32036 </cell>
32037 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32038 \begin_inset Text
32039
32040 \begin_layout Standard
32041
32042 \size footnotesize
32043 \begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
32044
32045 \end_inset
32046
32047
32048 \end_layout
32049
32050 \end_inset
32051 </cell>
32052 </row>
32053 <row topline="true">
32054 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32055 \begin_inset Text
32056
32057 \begin_layout Standard
32058
32059 \size footnotesize
32060 Ramtron / Goal Semiconductor
32061 \end_layout
32062
32063 \end_inset
32064 </cell>
32065 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32066 \begin_inset Text
32067
32068 \begin_layout Standard
32069
32070 \size footnotesize
32071 Installing and Configuring SDCC and Crimson Editor
32072 \end_layout
32073
32074 \end_inset
32075 </cell>
32076 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32077 \begin_inset Text
32078
32079 \begin_layout Standard
32080
32081 \size footnotesize
32082 \begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
32083
32084 \end_inset
32085
32086
32087 \end_layout
32088
32089 \end_inset
32090 </cell>
32091 </row>
32092 <row topline="true" bottomline="true">
32093 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32094 \begin_inset Text
32095
32096 \begin_layout Standard
32097
32098 \size footnotesize
32099 Texas Instruments
32100 \end_layout
32101
32102 \end_inset
32103 </cell>
32104 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32105 \begin_inset Text
32106
32107 \begin_layout Standard
32108
32109 \size footnotesize
32110 MSC12xx Programming with SDCC
32111 \end_layout
32112
32113 \end_inset
32114 </cell>
32115 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32116 \begin_inset Text
32117
32118 \begin_layout Standard
32119
32120 \size footnotesize
32121 \begin_inset LatexCommand \url{http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sbaa109&fileType=pdf}
32122
32123 \end_inset
32124
32125
32126 \end_layout
32127
32128 \end_inset
32129 </cell>
32130 </row>
32131 </lyxtabular>
32132
32133 \end_inset
32134
32135
32136 \end_layout
32137
32138 \begin_layout Section
32139 Some Questions
32140 \end_layout
32141
32142 \begin_layout Standard
32143 Some questions answered, some pointers given - it might be time to in turn
32144  ask
32145 \emph on
32146 you
32147 \emph default
32148  some questions:
32149 \end_layout
32150
32151 \begin_layout Itemize
32152 can you solve your project with the selected microcontroller? Would you
32153  find out early or rather late that your target is too small/slow/whatever?
32154  Can you switch to a slightly better device if it doesn't fit?
32155 \end_layout
32156
32157 \begin_layout Itemize
32158 should you solve the problem with an 8 bit CPU? Or would a 16/32 bit CPU
32159  and/or another programming language be more adequate? Would an operating
32160  system on the target device help?
32161 \end_layout
32162
32163 \begin_layout Itemize
32164 if you solved the problem, will the marketing department be happy?
32165 \end_layout
32166
32167 \begin_layout Itemize
32168 if the marketing department is happy, will customers be happy?
32169 \end_layout
32170
32171 \begin_layout Itemize
32172 if you're the project manager, marketing department and maybe even the customer
32173  in one person, have you tried to see the project from the outside?
32174 \end_layout
32175
32176 \begin_layout Itemize
32177 is the project done if you think it is done? Or is just that other interface/pro
32178 tocol/feature/configuration/option missing? How about website, manual(s),
32179  internationali(z|s)ation, packaging, labels, 2nd source for components,
32180  electromagnetic compatability/interference, documentation for production,
32181  production test software, update mechanism, patent issues?
32182 \end_layout
32183
32184 \begin_layout Itemize
32185 is your project adequately positioned in that magic triangle: fame, fortune,
32186  fun?
32187 \end_layout
32188
32189 \begin_layout Standard
32190 Maybe not all answers to these questions are known and some answers may
32191  even be
32192 \emph on
32193 no
32194 \emph default
32195 , nevertheless knowing these questions may help you to avoid burnout
32196 \begin_inset Foot
32197 status open
32198
32199 \begin_layout Standard
32200 burnout is bad for electronic devices, programmers and motorcycle tyres
32201 \end_layout
32202
32203 \end_inset
32204
32205 .
32206  Chances are you didn't want to hear some of them...
32207 \end_layout
32208
32209 \begin_layout Chapter
32210 Support
32211 \begin_inset LatexCommand \index{Support}
32212
32213 \end_inset
32214
32215
32216 \end_layout
32217
32218 \begin_layout Standard
32219 SDCC has grown to be a large project.
32220  The compiler alone (without the preprocessor, assembler and linker) is
32221  well over 150,000 lines of code (blank stripped).
32222  The open source nature of this project is a key to its continued growth
32223  and support.
32224  You gain the benefit and support of many active software developers and
32225  end users.
32226  Is SDCC perfect? No, that's why we need your help.
32227  The developers take pride in fixing reported bugs.
32228  You can help by reporting the bugs and helping other SDCC users.
32229  There are lots of ways to contribute, and we encourage you to take part
32230  in making SDCC a great software package.
32231 \end_layout
32232
32233 \begin_layout Standard
32234 The SDCC project is hosted on the SDCC sourceforge site at
32235 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/sdcc}
32236
32237 \end_inset
32238
32239 .
32240  You'll find the complete set of mailing lists
32241 \begin_inset LatexCommand \index{Mailing list(s)}
32242
32243 \end_inset
32244
32245 , forums, bug reporting system, patch submission
32246 \begin_inset LatexCommand \index{Patch submission}
32247
32248 \end_inset
32249
32250  system, download
32251 \begin_inset LatexCommand \index{download}
32252
32253 \end_inset
32254
32255  area and Subversion code repository
32256 \begin_inset LatexCommand \index{Subversion code repository}
32257
32258 \end_inset
32259
32260  there.
32261 \end_layout
32262
32263 \begin_layout Section
32264 Reporting Bugs
32265 \begin_inset LatexCommand \index{Bug reporting}
32266
32267 \end_inset
32268
32269
32270 \begin_inset LatexCommand \index{Reporting bugs}
32271
32272 \end_inset
32273
32274
32275 \end_layout
32276
32277 \begin_layout Standard
32278 The recommended way of reporting bugs is using the infrastructure of the
32279  sourceforge site.
32280  You can follow the status of bug reports there and have an overview about
32281  the known bugs.
32282 \end_layout
32283
32284 \begin_layout Standard
32285 Bug reports are automatically forwarded to the developer mailing list and
32286  will be fixed ASAP.
32287  When reporting a bug, it is very useful to include a small test program
32288  (the smaller the better) which reproduces the problem.
32289  If you can isolate the problem by looking at the generated assembly code,
32290  this can be very helpful.
32291  Compiling your program with the -
32292 \begin_inset ERT
32293 status collapsed
32294
32295 \begin_layout Standard
32296
32297
32298 \backslash
32299 /
32300 \end_layout
32301
32302 \end_inset
32303
32304 -dumpall
32305 \begin_inset LatexCommand \index{-\/-dumpall}
32306
32307 \end_inset
32308
32309  option can sometimes be useful in locating optimization problems.
32310  When reporting a bug please make sure you:
32311 \end_layout
32312
32313 \begin_layout Enumerate
32314 Attach the code you are compiling with SDCC.
32315 \end_layout
32316
32317 \begin_layout Enumerate
32318 Specify the exact command you use to run SDCC, or attach your Makefile.
32319 \end_layout
32320
32321 \begin_layout Enumerate
32322 Specify the SDCC version (type "
32323 \family sans
32324 \series bold
32325 sdcc -v
32326 \family default
32327 \series default
32328 "), your platform, and operating system.
32329 \end_layout
32330
32331 \begin_layout Enumerate
32332 Provide an exact copy of any error message or incorrect output.
32333 \end_layout
32334
32335 \begin_layout Enumerate
32336 Put something meaningful in the subject of your message.
32337 \end_layout
32338
32339 \begin_layout Standard
32340 Please attempt to include these 5 important parts, as applicable, in all
32341  requests for support or when reporting any problems or bugs with SDCC.
32342  Though this will make your message lengthy, it will greatly improve your
32343  chance that SDCC users and developers will be able to help you.
32344  Some SDCC developers are frustrated by bug reports without code provided
32345  that they can use to reproduce and ultimately fix the problem, so please
32346  be sure to provide sample code if you are reporting a bug!
32347 \end_layout
32348
32349 \begin_layout Standard
32350 Please have a short check that you are using a recent version of SDCC and
32351  the bug is not yet known.
32352  This is the link for reporting bugs:
32353 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=100599}
32354
32355 \end_inset
32356
32357 .
32358  With SDCC on average having more than 200 downloads
32359 \begin_inset LatexCommand \index{download}
32360
32361 \end_inset
32362
32363  on sourceforge per day
32364 \begin_inset Foot
32365 status open
32366
32367 \begin_layout Standard
32368 220 daily downloads on average Jan-Sept 2006 and about 150 daily downloads
32369  between 2002 and 2005.
32370  This does not include other methods of distribution.
32371 \end_layout
32372
32373 \end_inset
32374
32375  there must be some users.
32376  So it's not exactly easy to find a new bug.
32377  If you find one we need it:
32378 \emph on
32379 reporting bugs is good
32380 \emph default
32381 .
32382 \end_layout
32383
32384 \begin_layout Section
32385 Requesting Features
32386 \begin_inset LatexCommand \label{sub:Requesting-Features}
32387
32388 \end_inset
32389
32390
32391 \begin_inset LatexCommand \index{Feature request}
32392
32393 \end_inset
32394
32395
32396 \begin_inset LatexCommand \index{Requesting features}
32397
32398 \end_inset
32399
32400
32401 \end_layout
32402
32403 \begin_layout Standard
32404 Like bug reports feature requests are forwarded to the developer mailing
32405  list.
32406  This is the link for requesting features:
32407 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
32408
32409 \end_inset
32410
32411 .
32412 \end_layout
32413
32414 \begin_layout Section
32415 Submitting patches
32416 \end_layout
32417
32418 \begin_layout Standard
32419 Like bug reports contributed patches are forwarded to the developer mailing
32420  list.
32421  This is the link for submitting patches
32422 \begin_inset LatexCommand \index{Patch submission}
32423
32424 \end_inset
32425
32426 :
32427 \begin_inset LatexCommand \url{http://sourceforge.net/tracker/?group_id=599&atid=300599}
32428
32429 \end_inset
32430
32431 .
32432 \end_layout
32433
32434 \begin_layout Standard
32435 You need to specify some parameters to the
32436 \family typewriter
32437 diff
32438 \family default
32439  command for the patches to be useful.
32440  If you modified more than one file a patch created f.e.
32441  with
32442 \family sans
32443 \series bold
32444
32445 \begin_inset Quotes sld
32446 \end_inset
32447
32448 diff -Naur unmodified_directory modified_directory >my_changes.patch
32449 \begin_inset Quotes srd
32450 \end_inset
32451
32452
32453 \family default
32454 \series default
32455  will be fine, otherwise
32456 \family sans
32457 \series bold
32458
32459 \begin_inset Quotes sld
32460 \end_inset
32461
32462 diff -u sourcefile.c.orig sourcefile.c >my_changes.patch
32463 \begin_inset Quotes srd
32464 \end_inset
32465
32466
32467 \family default
32468 \series default
32469 will do.
32470 \end_layout
32471
32472 \begin_layout Section
32473 Getting Help
32474 \end_layout
32475
32476 \begin_layout Standard
32477 These links should take you directly to the
32478 \begin_inset LatexCommand \url[Mailing lists]{http://sourceforge.net/mail/?group_id=599}
32479
32480 \end_inset
32481
32482
32483 \begin_inset Foot
32484 status open
32485
32486 \begin_layout Standard
32487 Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
32488  automated messages (mid 2003)
32489 \end_layout
32490
32491 \end_inset
32492
32493  and the
32494 \begin_inset LatexCommand \url[Forums]{http://sourceforge.net/forum/?group_id=599}
32495
32496 \end_inset
32497
32498 , lists
32499 \begin_inset LatexCommand \index{Mailing list(s)}
32500
32501 \end_inset
32502
32503  and forums are archived and searchable so if you are lucky someone already
32504  had a similar problem.
32505  While mails to the lists themselves are delivered promptly their web front
32506  end on sourceforge sometimes shows a severe time lag (up to several weeks),
32507  if you're seriously using SDCC please consider subscribing to the lists.
32508 \end_layout
32509
32510 \begin_layout Section
32511 ChangeLog
32512 \end_layout
32513
32514 \begin_layout Standard
32515 You can follow the status of the Subversion version
32516 \begin_inset LatexCommand \index{version}
32517
32518 \end_inset
32519
32520  of SDCC by watching the Changelog
32521 \begin_inset LatexCommand \index{Changelog}
32522
32523 \end_inset
32524
32525  in the Subversion repository
32526 \size footnotesize
32527
32528 \begin_inset LatexCommand \htmlurl{http://sdcc.svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/ChangeLog}
32529
32530 \end_inset
32531
32532 .
32533 \end_layout
32534
32535 \begin_layout Section
32536 Subversion Source Code Repository
32537 \end_layout
32538
32539 \begin_layout Standard
32540 The output of
32541 \family sans
32542 \series bold
32543 sdcc -
32544 \family default
32545
32546 \begin_inset ERT
32547 status open
32548
32549 \begin_layout Standard
32550
32551
32552 \backslash
32553 /
32554 \end_layout
32555
32556 \end_inset
32557
32558
32559 \family sans
32560 -version
32561 \family default
32562 \series default
32563  or the filenames of the snapshot versions of SDCC include date and its
32564  Subversion
32565 \begin_inset LatexCommand \index{Subversion code repository}
32566
32567 \end_inset
32568
32569  number.
32570  Subversion allows to download the source of recent or previous versions
32571 \begin_inset LatexCommand \url{http://sourceforge.net/svn/?group_id=599}
32572
32573 \end_inset
32574
32575  (by number or by date).
32576  An on-line source code browser and detailled instructions are also available
32577  there.
32578  SDCC versions starting from 1999 up to now are available (currently the
32579  versions prior to the conversion from cvs
32580 \begin_inset LatexCommand \index{cvs|see{Subversion}}
32581
32582 \end_inset
32583
32584  to Subversion (April 2006) are either by accessible by Subversion or by
32585  cvs).
32586 \end_layout
32587
32588 \begin_layout Section
32589 Release policy
32590 \begin_inset LatexCommand \index{Release policy}
32591
32592 \end_inset
32593
32594
32595 \end_layout
32596
32597 \begin_layout Standard
32598 Historically there often were long delays between official releases and
32599  the sourceforge download area tends to get not updated at all.
32600  Excuses in the past might have referred to problems with live range analysis,
32601  but as this was fixed a while ago, the current problem is that another
32602  excuse has to be found.
32603  Kidding aside, we have to get better there! On the other hand there are
32604  daily snapshots available at
32605 \begin_inset LatexCommand \htmlurl[snap]{http://sdcc.sourceforge.net/snap.php}
32606
32607 \end_inset
32608
32609 , and you can always build the very last version (hopefully with many bugs
32610  fixed, and features added) from the source code available at
32611 \begin_inset LatexCommand \htmlurl[Source]{http://sdcc.sourceforge.net/snap.php#Source}
32612
32613 \end_inset
32614
32615 .
32616  The SDCC Wiki
32617 \begin_inset LatexCommand \index{wiki}
32618
32619 \end_inset
32620
32621
32622 \begin_inset LatexCommand \index{SDCC Wiki}
32623
32624 \end_inset
32625
32626  at
32627 \begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/}
32628
32629 \end_inset
32630
32631  also holds some information about past and future releases.
32632 \end_layout
32633
32634 \begin_layout Section
32635 Examples
32636 \begin_inset LatexCommand \index{Examples}
32637
32638 \end_inset
32639
32640
32641 \end_layout
32642
32643 \begin_layout Standard
32644 You'll find some small examples in the directory
32645 \emph on
32646 sdcc/device/examples/.
32647 \emph default
32648 More examples and libraries are available at
32649 \emph on
32650  The SDCC Open Knowledge Resource
32651 \begin_inset LatexCommand \url{http://sdccokr.dl9sec.de/}
32652
32653 \end_inset
32654
32655
32656 \emph default
32657 web site or at
32658 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/}
32659
32660 \end_inset
32661
32662 .
32663 \end_layout
32664
32665 \begin_layout Standard
32666 \begin_inset Note Note
32667 status collapsed
32668
32669 \begin_layout Standard
32670 I did insert a reference to Paul's web site here although it seems rather
32671  dedicated to a specific 8032 board (I think it's okay because it f.e.
32672  shows LCD/Harddisc interface and has a free 8051 monitor.
32673  Independent 8032 board vendors face hard competition of heavily subsidized
32674  development boards anyway).
32675 \end_layout
32676
32677 \begin_layout Standard
32678 Maybe we should include some links to real world applications.
32679  Preferably pointer to pointers (one for each architecture) so this stays
32680  manageable here?
32681 \end_layout
32682
32683 \end_inset
32684
32685
32686 \end_layout
32687
32688 \begin_layout Section
32689 Quality control
32690 \begin_inset LatexCommand \label{sec:Quality-control}
32691
32692 \end_inset
32693
32694
32695 \begin_inset LatexCommand \index{Quality control}
32696
32697 \end_inset
32698
32699
32700 \end_layout
32701
32702 \begin_layout Standard
32703 The compiler is passed through snaphot build compile and build checks.
32704  The so called
32705 \shape italic
32706 regression tests
32707 \shape default
32708
32709 \begin_inset LatexCommand \index{Regression test}
32710
32711 \end_inset
32712
32713  check that SDCC itself compiles flawlessly on several host platforms (i386,
32714  Opteron, 64 bit Alpha, ppc64, Mac OS X on ppc and i386, Solaris on Sparc)
32715  and checks the quality of the code generated by SDCC by running the code
32716  for several target platforms through simulators.
32717  The regression test suite comprises more than 100 files which expand to
32718  more than 500 test cases which include more than 4500 tests.
32719  The results of these tests are published daily on SDCC's snapshot page
32720  (click on the red or green symbols on the right side of
32721 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
32722
32723 \end_inset
32724
32725 ).
32726 \end_layout
32727
32728 \begin_layout Standard
32729 There is a separate document
32730 \shape italic
32731 test_suite.pdf
32732 \begin_inset LatexCommand \index{Test suite}
32733
32734 \end_inset
32735
32736
32737 \shape default
32738
32739 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
32740
32741 \end_inset
32742
32743  about the regression test suite.
32744 \end_layout
32745
32746 \begin_layout Standard
32747 You'll find the test code in the directory
32748 \shape italic
32749 sdcc/support/regression
32750 \shape default
32751 .
32752  You can run these tests manually by running
32753 \family sans
32754 make
32755 \family default
32756  in this directory (or f.e.
32757 \family sans
32758 \series bold
32759
32760 \begin_inset Quotes sld
32761 \end_inset
32762
32763 make test-mcs51
32764 \begin_inset Quotes srd
32765 \end_inset
32766
32767
32768 \family default
32769 \series default
32770  if you don't want to run the complete tests).
32771  The test code might also be interesting if you want to look for examples
32772 \begin_inset LatexCommand \index{Examples}
32773
32774 \end_inset
32775
32776  checking corner cases of SDCC or if you plan to submit patches
32777 \begin_inset LatexCommand \index{Patch submission}
32778
32779 \end_inset
32780
32781 .
32782 \end_layout
32783
32784 \begin_layout Standard
32785 The PIC14 port uses a different set of regression tests
32786 \begin_inset LatexCommand \index{Regression test (PIC14)}
32787
32788 \end_inset
32789
32790 , you'll find them in the directory
32791 \shape italic
32792 sdcc/src/regression
32793 \shape default
32794 .
32795 \end_layout
32796
32797 \begin_layout Section
32798 Use of SDCC in Education
32799 \end_layout
32800
32801 \begin_layout Standard
32802 In short:
32803 \emph on
32804 highly
32805 \emph default
32806  encouraged
32807 \begin_inset Foot
32808 status open
32809
32810 \begin_layout Standard
32811 the phrase "use in education" might evoke the association "
32812 \emph on
32813 only
32814 \emph default
32815  fit for use in education".
32816  This connotation is not intended but nevertheless risked as the licensing
32817  of SDCC makes it difficult to offer educational discounts
32818 \end_layout
32819
32820 \end_inset
32821
32822 .
32823  If your rationales are to:
32824 \end_layout
32825
32826 \begin_layout Enumerate
32827 give students a chance to understand the
32828 \emph on
32829 complete
32830 \emph default
32831  steps of code generation
32832 \end_layout
32833
32834 \begin_layout Enumerate
32835 have a curriculum that can be extended for years.
32836  Then you could use an fpga board as target and your curriculum will seamlessly
32837  extend from logic synthesis (
32838 \begin_inset LatexCommand \url[http://www.opencores.org]{opencores.org}
32839
32840 \end_inset
32841
32842 ,
32843 \begin_inset LatexCommand \url[Oregano]{http://www.oregano.at/ip/ip01.htm}
32844
32845 \end_inset
32846
32847 ), over assembly programming, to C to FPGA compilers (
32848 \begin_inset LatexCommand \url[FPGAC]{http://sf.net/projects/fpgac}
32849
32850 \end_inset
32851
32852 ) and to C.
32853 \end_layout
32854
32855 \begin_layout Enumerate
32856 be able to insert excursions about skills like using a revision control
32857  system, submitting/applying patches, using a type-setting (as opposed to
32858  word-processing) engine LyX/LaTeX, using
32859 \begin_inset LatexCommand \url[SourceForge]{http://www.sf.net}
32860
32861 \end_inset
32862
32863 , following some
32864 \begin_inset LatexCommand \url[netiquette]{http://en.wikipedia.org/wiki/Netiquette}
32865
32866 \end_inset
32867
32868 , understanding BSD/LGPL/GPL/Proprietary licensing, growth models of Open
32869  Source Software, CPU simulation, compiler regression tests
32870 \begin_inset LatexCommand \index{Regression test}
32871
32872 \end_inset
32873
32874 .
32875 \newline
32876 And if there should be a shortage of ideas then you can always point students
32877  to the ever-growing feature request list
32878 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
32879
32880 \end_inset
32881
32882 .
32883 \end_layout
32884
32885 \begin_layout Enumerate
32886 not tie students to a specific host platform and instead allow them to use
32887  a host platform of
32888 \emph on
32889 their
32890 \emph default
32891  choice (among them Alpha, i386, i386_64, Mac OS X, Mips, Sparc, Windows
32892  and eventually
32893 \begin_inset LatexCommand \url[OLPC]{http://www.laptop.org}
32894
32895 \end_inset
32896
32897 )
32898 \end_layout
32899
32900 \begin_layout Enumerate
32901 not encourage students to use illegal copies of educational software
32902 \end_layout
32903
32904 \begin_layout Enumerate
32905 be immune to licensing/availability/price changes of the chosen tool chain
32906 \end_layout
32907
32908 \begin_layout Enumerate
32909 be able to change to a new target platform without having to adopt a new
32910  tool chain
32911 \end_layout
32912
32913 \begin_layout Enumerate
32914 have complete control over and insight into the tool chain
32915 \end_layout
32916
32917 \begin_layout Enumerate
32918 make your students aware about the pros and cons of open source software
32919  development
32920 \end_layout
32921
32922 \begin_layout Enumerate
32923 give back to the public as you are probably at least partially publically
32924  funded
32925 \end_layout
32926
32927 \begin_layout Enumerate
32928 give students a chance to publically prove their skills and to possibly
32929  see a world wide impact
32930 \end_layout
32931
32932 \begin_layout Standard
32933 then SDCC is probably among the first choices.
32934  Well, probably SDCC might be the only choice.
32935 \newpage
32936
32937 \end_layout
32938
32939 \begin_layout Chapter
32940 SDCC Technical Data
32941 \end_layout
32942
32943 \begin_layout Section
32944 Optimizations
32945 \begin_inset LatexCommand \index{Optimizations}
32946
32947 \end_inset
32948
32949
32950 \end_layout
32951
32952 \begin_layout Standard
32953 SDCC performs a host of standard optimizations in addition to some MCU specific
32954  optimizations.
32955 \end_layout
32956
32957 \begin_layout Subsection
32958 Sub-expression Elimination
32959 \begin_inset LatexCommand \index{Subexpression elimination}
32960
32961 \end_inset
32962
32963
32964 \end_layout
32965
32966 \begin_layout Standard
32967 The compiler does local and
32968 \emph on
32969 g
32970 \emph default
32971 lobal
32972 \emph on
32973 c
32974 \emph default
32975 ommon
32976 \emph on
32977 s
32978 \emph default
32979 ubexpression
32980 \emph on
32981 e
32982 \emph default
32983 limination, e.g.:
32984 \end_layout
32985
32986 \begin_layout Verse
32987
32988 \family typewriter
32989 i = x + y + 1;
32990 \newline
32991 j = x + y;
32992 \end_layout
32993
32994 \begin_layout Standard
32995 will be translated to
32996 \end_layout
32997
32998 \begin_layout Verse
32999
33000 \family typewriter
33001 iTemp = x + y;
33002 \newline
33003 i = iTemp + 1;
33004 \newline
33005 j = iTemp;
33006 \end_layout
33007
33008 \begin_layout Standard
33009 Some subexpressions are not as obvious as the above example, e.g.:
33010 \end_layout
33011
33012 \begin_layout Verse
33013
33014 \family typewriter
33015 a->b[i].c = 10;
33016 \newline
33017 a->b[i].d = 11;
33018 \end_layout
33019
33020 \begin_layout Standard
33021 In this case the address arithmetic a->b[i] will be computed only once;
33022  the equivalent code in C would be.
33023 \end_layout
33024
33025 \begin_layout Verse
33026
33027 \family typewriter
33028 iTemp = a->b[i];
33029 \newline
33030 iTemp.c = 10;
33031 \newline
33032 iTemp.d = 11;
33033 \end_layout
33034
33035 \begin_layout Standard
33036 The compiler will try to keep these temporary variables in registers.
33037 \end_layout
33038
33039 \begin_layout Subsection
33040 Dead-Code Elimination
33041 \begin_inset LatexCommand \index{Dead-code elimination}
33042
33043 \end_inset
33044
33045
33046 \end_layout
33047
33048 \begin_layout Verse
33049
33050 \family typewriter
33051 int global;
33052 \newline
33053
33054 \newline
33055 void f () {
33056 \newline
33057 \InsetSpace ~
33058 \InsetSpace ~
33059 int i;
33060 \newline
33061 \InsetSpace ~
33062 \InsetSpace ~
33063 i = 1; \InsetSpace ~
33064 \InsetSpace ~
33065 \InsetSpace ~
33066 \InsetSpace ~
33067 \InsetSpace ~
33068 /* dead store */
33069 \newline
33070 \InsetSpace ~
33071 \InsetSpace ~
33072 global = 1;\InsetSpace ~
33073 /* dead store
33074  */
33075 \newline
33076 \InsetSpace ~
33077 \InsetSpace ~
33078 global = 2;
33079 \newline
33080 \InsetSpace ~
33081 \InsetSpace ~
33082 return;
33083 \newline
33084 \InsetSpace ~
33085 \InsetSpace ~
33086 global = 3;\InsetSpace ~
33087 /* unreachable */
33088 \newline
33089 }
33090 \end_layout
33091
33092 \begin_layout Standard
33093 will be changed to
33094 \end_layout
33095
33096 \begin_layout Verse
33097
33098 \family typewriter
33099 int global;
33100 \newline
33101
33102 \newline
33103 void f () {
33104 \newline
33105 \InsetSpace ~
33106 \InsetSpace ~
33107 global = 2;
33108 \newline
33109 }
33110 \end_layout
33111
33112 \begin_layout Subsection
33113 Copy-Propagation
33114 \begin_inset LatexCommand \index{Copy propagation}
33115
33116 \end_inset
33117
33118
33119 \end_layout
33120
33121 \begin_layout Verse
33122
33123 \family typewriter
33124 int f() {
33125 \newline
33126 \InsetSpace ~
33127 \InsetSpace ~
33128 int i, j;
33129 \newline
33130 \InsetSpace ~
33131 \InsetSpace ~
33132 i = 10;
33133 \newline
33134 \InsetSpace ~
33135 \InsetSpace ~
33136 j = i;
33137 \newline
33138 \InsetSpace ~
33139 \InsetSpace ~
33140 return j;
33141 \newline
33142 }
33143 \end_layout
33144
33145 \begin_layout Standard
33146 will be changed to
33147 \end_layout
33148
33149 \begin_layout Verse
33150
33151 \family typewriter
33152 int f() {
33153 \newline
33154 \InsetSpace ~
33155 \InsetSpace ~
33156 int i, j;
33157 \newline
33158 \InsetSpace ~
33159 \InsetSpace ~
33160 i = 10;
33161 \newline
33162 \InsetSpace ~
33163 \InsetSpace ~
33164 j = 10;
33165 \newline
33166 \InsetSpace ~
33167 \InsetSpace ~
33168 return 10;
33169 \newline
33170 }
33171 \end_layout
33172
33173 \begin_layout Standard
33174 Note: the dead stores created by this copy propagation will be eliminated
33175  by dead-code elimination.
33176 \end_layout
33177
33178 \begin_layout Subsection
33179 Loop Optimizations
33180 \begin_inset LatexCommand \index{Loop optimization}
33181
33182 \end_inset
33183
33184
33185 \begin_inset LatexCommand \label{sub:Loop-Optimizations}
33186
33187 \end_inset
33188
33189
33190 \end_layout
33191
33192 \begin_layout Standard
33193 Two types of loop optimizations are done by SDCC
33194 \emph on
33195 loop invariant
33196 \emph default
33197  lifting and
33198 \emph on
33199  strength reduction
33200 \emph default
33201  of loop induction variables.
33202  In addition to the strength reduction the optimizer marks the induction
33203  variables and the register allocator tries to keep the induction variables
33204  in registers for the duration of the loop.
33205  Because of this preference of the register allocator
33206 \begin_inset LatexCommand \index{Register allocation}
33207
33208 \end_inset
33209
33210 , loop induction optimization causes an increase in register pressure, which
33211  may cause unwanted spilling of other temporary variables into the stack
33212 \begin_inset LatexCommand \index{stack}
33213
33214 \end_inset
33215
33216  / data space.
33217  The compiler will generate a warning message when it is forced to allocate
33218  extra space either on the stack or data space.
33219  If this extra space allocation is undesirable then induction optimization
33220  can be eliminated either for the entire source file (with -
33221 \begin_inset ERT
33222 status collapsed
33223
33224 \begin_layout Standard
33225
33226
33227 \backslash
33228 /
33229 \end_layout
33230
33231 \end_inset
33232
33233 -noinduction option) or for a given function only using #pragma\InsetSpace ~
33234 noinduction
33235 \begin_inset LatexCommand \index{\#pragma noinduction}
33236
33237 \end_inset
33238
33239 .
33240 \newline
33241
33242 \newline
33243 Loop Invariant:
33244 \end_layout
33245
33246 \begin_layout Verse
33247
33248 \family typewriter
33249 for (i = 0 ; i < 100 ; i ++)
33250 \newline
33251 \InsetSpace ~
33252 \InsetSpace ~
33253 \InsetSpace ~
33254 \InsetSpace ~
33255 f += k + l;
33256 \end_layout
33257
33258 \begin_layout Standard
33259 changed to
33260 \end_layout
33261
33262 \begin_layout Verse
33263
33264 \family typewriter
33265 itemp = k + l;
33266 \newline
33267 for (i = 0; i < 100; i++)
33268 \newline
33269 \InsetSpace ~
33270 \InsetSpace ~
33271 \InsetSpace ~
33272 \InsetSpace ~
33273 f += itemp;
33274 \end_layout
33275
33276 \begin_layout Standard
33277 As mentioned previously some loop invariants are not as apparent, all static
33278  address computations are also moved out of the loop.
33279 \newline
33280
33281 \newline
33282 Strength Reduction
33283 \begin_inset LatexCommand \index{Strength reduction}
33284
33285 \end_inset
33286
33287 , this optimization substitutes an expression by a cheaper expression:
33288 \end_layout
33289
33290 \begin_layout Verse
33291
33292 \family typewriter
33293 for (i=0;i < 100; i++)
33294 \newline
33295 \InsetSpace ~
33296 \InsetSpace ~
33297 \InsetSpace ~
33298 \InsetSpace ~
33299 ar[i*5] = i*3;
33300 \end_layout
33301
33302 \begin_layout Standard
33303 changed to
33304 \end_layout
33305
33306 \begin_layout Verse
33307
33308 \family typewriter
33309 itemp1 = 0;
33310 \newline
33311 itemp2 = 0;
33312 \newline
33313 for (i=0;i< 100;i++) {
33314 \newline
33315 \InsetSpace ~
33316 \InsetSpace ~
33317 \InsetSpace ~
33318 \InsetSpace ~
33319 ar[itemp1] = itemp2;
33320 \newline
33321 \InsetSpace ~
33322 \InsetSpace ~
33323 \InsetSpace ~
33324 \InsetSpace ~
33325 itemp1 +=
33326  5;
33327 \newline
33328 \InsetSpace ~
33329 \InsetSpace ~
33330 \InsetSpace ~
33331 \InsetSpace ~
33332 itemp2 += 3;
33333 \newline
33334 }
33335 \end_layout
33336
33337 \begin_layout Standard
33338 The more expensive multiplication
33339 \begin_inset LatexCommand \index{Multiplication}
33340
33341 \end_inset
33342
33343  is changed to a less expensive addition.
33344 \end_layout
33345
33346 \begin_layout Subsection
33347 Loop Reversing
33348 \begin_inset LatexCommand \index{Loop reversing}
33349
33350 \end_inset
33351
33352
33353 \end_layout
33354
33355 \begin_layout Standard
33356 This optimization is done to reduce the overhead of checking loop boundaries
33357  for every iteration.
33358  Some simple loops can be reversed and implemented using a
33359 \begin_inset Quotes eld
33360 \end_inset
33361
33362 decrement and jump if not zero
33363 \begin_inset Quotes erd
33364 \end_inset
33365
33366  instruction.
33367  SDCC checks for the following criterion to determine if a loop is reversible
33368  (note: more sophisticated compilers use data-dependency analysis to make
33369  this determination, SDCC uses a more simple minded analysis).
33370 \end_layout
33371
33372 \begin_layout Itemize
33373 The 'for' loop is of the form
33374 \newline
33375
33376 \newline
33377
33378 \family typewriter
33379 for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
33380  += 1])
33381 \newline
33382 \InsetSpace ~
33383 \InsetSpace ~
33384 \InsetSpace ~
33385 \InsetSpace ~
33386 <for body>
33387 \end_layout
33388
33389 \begin_layout Itemize
33390 The <for body> does not contain
33391 \begin_inset Quotes eld
33392 \end_inset
33393
33394 continue
33395 \begin_inset Quotes erd
33396 \end_inset
33397
33398  or 'break
33399 \begin_inset Quotes erd
33400 \end_inset
33401
33402 .
33403 \end_layout
33404
33405 \begin_layout Itemize
33406 All goto's are contained within the loop.
33407 \end_layout
33408
33409 \begin_layout Itemize
33410 No function calls within the loop.
33411 \end_layout
33412
33413 \begin_layout Itemize
33414 The loop control variable <sym> is not assigned any value within the loop
33415 \end_layout
33416
33417 \begin_layout Itemize
33418 The loop control variable does NOT participate in any arithmetic operation
33419  within the loop.
33420 \end_layout
33421
33422 \begin_layout Itemize
33423 There are NO switch statements in the loop.
33424 \end_layout
33425
33426 \begin_layout Subsection
33427 Algebraic Simplifications
33428 \end_layout
33429
33430 \begin_layout Standard
33431 SDCC does numerous algebraic simplifications, the following is a small sub-set
33432  of these optimizations.
33433 \end_layout
33434
33435 \begin_layout Verse
33436
33437 \family typewriter
33438 i = j + 0;\InsetSpace ~
33439 \InsetSpace ~
33440 \InsetSpace ~
33441 \InsetSpace ~
33442  /* changed to: */\InsetSpace ~
33443 \InsetSpace ~
33444 \InsetSpace ~
33445 \InsetSpace ~
33446  i = j;
33447 \newline
33448 i /= 2;\InsetSpace ~
33449 \InsetSpace ~
33450 \InsetSpace ~
33451 \InsetSpace ~
33452 \InsetSpace ~
33453 \InsetSpace ~
33454 \InsetSpace ~
33455  /* changed to: */\InsetSpace ~
33456 \InsetSpace ~
33457 \InsetSpace ~
33458 \InsetSpace ~
33459  i >>= 1;
33460 \newline
33461 i =
33462  j - j;\InsetSpace ~
33463 \InsetSpace ~
33464 \InsetSpace ~
33465 \InsetSpace ~
33466  /* changed to: */\InsetSpace ~
33467 \InsetSpace ~
33468 \InsetSpace ~
33469 \InsetSpace ~
33470  i = 0;
33471 \newline
33472 i = j / 1;\InsetSpace ~
33473 \InsetSpace ~
33474 \InsetSpace ~
33475 \InsetSpace ~
33476  /* changed to: */\InsetSpace ~
33477 \InsetSpace ~
33478 \InsetSpace ~
33479 \InsetSpace ~
33480  i = j;
33481 \end_layout
33482
33483 \begin_layout Standard
33484 Note the subexpressions
33485 \begin_inset LatexCommand \index{Subexpression}
33486
33487 \end_inset
33488
33489  given above are generally introduced by macro expansions or as a result
33490  of copy/constant propagation.
33491 \end_layout
33492
33493 \begin_layout Subsection
33494 'switch' Statements
33495 \begin_inset LatexCommand \label{sub:'switch'-Statements}
33496
33497 \end_inset
33498
33499
33500 \begin_inset LatexCommand \index{switch statement}
33501
33502 \end_inset
33503
33504
33505 \end_layout
33506
33507 \begin_layout Standard
33508 SDCC can optimize switch statements to jump tables
33509 \begin_inset LatexCommand \index{jump tables}
33510
33511 \end_inset
33512
33513 .
33514  It makes the decision based on an estimate of the generated code size.
33515  SDCC is quite liberal in the requirements for jump table generation:
33516 \end_layout
33517
33518 \begin_layout Itemize
33519 The labels need not be in order, and the starting number need not be one
33520  or zero, the case labels are in numerical sequence or not too many case
33521  labels are missing.
33522 \end_layout
33523
33524 \begin_deeper
33525 \begin_layout Verse
33526
33527 \family typewriter
33528 switch(i) {\InsetSpace ~
33529 \InsetSpace ~
33530 \InsetSpace ~
33531 \InsetSpace ~
33532 \InsetSpace ~
33533 \InsetSpace ~
33534 \InsetSpace ~
33535 \InsetSpace ~
33536 \InsetSpace ~
33537 \InsetSpace ~
33538 \InsetSpace ~
33539 \InsetSpace ~
33540 \InsetSpace ~
33541 \InsetSpace ~
33542 \InsetSpace ~
33543 \InsetSpace ~
33544 \InsetSpace ~
33545 \InsetSpace ~
33546 \InsetSpace ~
33547 \InsetSpace ~
33548 \InsetSpace ~
33549 \InsetSpace ~
33550 \InsetSpace ~
33551 \InsetSpace ~
33552 \InsetSpace ~
33553 \InsetSpace ~
33554 switch (i) {
33555 \newline
33556 \InsetSpace ~
33557 \InsetSpace ~
33558 \InsetSpace ~
33559 case 4: ...\InsetSpace ~
33560 \InsetSpace ~
33561 \InsetSpace ~
33562 \InsetSpace ~
33563 \InsetSpace ~
33564 \InsetSpace ~
33565 \InsetSpace ~
33566 \InsetSpace ~
33567 \InsetSpace ~
33568 \InsetSpace ~
33569 \InsetSpace ~
33570 \InsetSpace ~
33571 \InsetSpace ~
33572 \InsetSpace ~
33573 \InsetSpace ~
33574 \InsetSpace ~
33575 \InsetSpace ~
33576 \InsetSpace ~
33577 \InsetSpace ~
33578 \InsetSpace ~
33579 \InsetSpace ~
33580 \InsetSpace ~
33581 \InsetSpace ~
33582 \InsetSpace ~
33583 \InsetSpace ~
33584 \InsetSpace ~
33585 case 0: ...
33586 \newline
33587 \InsetSpace ~
33588 \InsetSpace ~
33589 \InsetSpace ~
33590 case 5: ...\InsetSpace ~
33591 \InsetSpace ~
33592 \InsetSpace ~
33593 \InsetSpace ~
33594 \InsetSpace ~
33595 \InsetSpace ~
33596 \InsetSpace ~
33597 \InsetSpace ~
33598 \InsetSpace ~
33599 \InsetSpace ~
33600 \InsetSpace ~
33601 \InsetSpace ~
33602 \InsetSpace ~
33603 \InsetSpace ~
33604 \InsetSpace ~
33605 \InsetSpace ~
33606 \InsetSpace ~
33607 \InsetSpace ~
33608 \InsetSpace ~
33609 \InsetSpace ~
33610 \InsetSpace ~
33611 \InsetSpace ~
33612 \InsetSpace ~
33613 \InsetSpace ~
33614 \InsetSpace ~
33615 \InsetSpace ~
33616 case 1: ...
33617 \newline
33618 \InsetSpace ~
33619 \InsetSpace ~
33620 \InsetSpace ~
33621 case 3: ...\InsetSpace ~
33622 \InsetSpace ~
33623 \InsetSpace ~
33624 \InsetSpace ~
33625 \InsetSpace ~
33626 \InsetSpace ~
33627 \InsetSpace ~
33628 \InsetSpace ~
33629 \InsetSpace ~
33630 \InsetSpace ~
33631 \InsetSpace ~
33632 \InsetSpace ~
33633 \InsetSpace ~
33634 \InsetSpace ~
33635 \InsetSpace ~
33636 \InsetSpace ~
33637 \InsetSpace ~
33638 \InsetSpace ~
33639 \InsetSpace ~
33640 \InsetSpace ~
33641 \InsetSpace ~
33642 \InsetSpace ~
33643 \InsetSpace ~
33644 \InsetSpace ~
33645 \InsetSpace ~
33646 \InsetSpace ~
33647
33648 \newline
33649 \InsetSpace ~
33650 \InsetSpace ~
33651 \InsetSpace ~
33652 case 6: ...\InsetSpace ~
33653 \InsetSpace ~
33654 \InsetSpace ~
33655 \InsetSpace ~
33656 \InsetSpace ~
33657 \InsetSpace ~
33658 \InsetSpace ~
33659 \InsetSpace ~
33660 \InsetSpace ~
33661 \InsetSpace ~
33662 \InsetSpace ~
33663 \InsetSpace ~
33664 \InsetSpace ~
33665 \InsetSpace ~
33666 \InsetSpace ~
33667 \InsetSpace ~
33668 \InsetSpace ~
33669 \InsetSpace ~
33670 \InsetSpace ~
33671 \InsetSpace ~
33672 \InsetSpace ~
33673 \InsetSpace ~
33674 \InsetSpace ~
33675 \InsetSpace ~
33676 \InsetSpace ~
33677 \InsetSpace ~
33678 case
33679  3: ...
33680 \newline
33681 \InsetSpace ~
33682 \InsetSpace ~
33683 \InsetSpace ~
33684 case 7: ...\InsetSpace ~
33685 \InsetSpace ~
33686 \InsetSpace ~
33687 \InsetSpace ~
33688 \InsetSpace ~
33689 \InsetSpace ~
33690 \InsetSpace ~
33691 \InsetSpace ~
33692 \InsetSpace ~
33693 \InsetSpace ~
33694 \InsetSpace ~
33695 \InsetSpace ~
33696 \InsetSpace ~
33697 \InsetSpace ~
33698 \InsetSpace ~
33699 \InsetSpace ~
33700 \InsetSpace ~
33701 \InsetSpace ~
33702 \InsetSpace ~
33703 \InsetSpace ~
33704 \InsetSpace ~
33705 \InsetSpace ~
33706 \InsetSpace ~
33707 \InsetSpace ~
33708 \InsetSpace ~
33709 \InsetSpace ~
33710 case 4: ...
33711 \newline
33712 \InsetSpace ~
33713 \InsetSpace ~
33714 \InsetSpace ~
33715 case 8: ...\InsetSpace ~
33716 \InsetSpace ~
33717 \InsetSpace ~
33718 \InsetSpace ~
33719 \InsetSpace ~
33720 \InsetSpace ~
33721 \InsetSpace ~
33722 \InsetSpace ~
33723 \InsetSpace ~
33724 \InsetSpace ~
33725 \InsetSpace ~
33726 \InsetSpace ~
33727 \InsetSpace ~
33728 \InsetSpace ~
33729 \InsetSpace ~
33730 \InsetSpace ~
33731 \InsetSpace ~
33732 \InsetSpace ~
33733 \InsetSpace ~
33734 \InsetSpace ~
33735 \InsetSpace ~
33736 \InsetSpace ~
33737 \InsetSpace ~
33738 \InsetSpace ~
33739 \InsetSpace ~
33740 \InsetSpace ~
33741 case 5: ...
33742 \newline
33743 \InsetSpace ~
33744 \InsetSpace ~
33745 \InsetSpace ~
33746 case 9: ...\InsetSpace ~
33747 \InsetSpace ~
33748 \InsetSpace ~
33749 \InsetSpace ~
33750 \InsetSpace ~
33751 \InsetSpace ~
33752 \InsetSpace ~
33753 \InsetSpace ~
33754 \InsetSpace ~
33755 \InsetSpace ~
33756 \InsetSpace ~
33757 \InsetSpace ~
33758 \InsetSpace ~
33759 \InsetSpace ~
33760 \InsetSpace ~
33761 \InsetSpace ~
33762 \InsetSpace ~
33763 \InsetSpace ~
33764 \InsetSpace ~
33765 \InsetSpace ~
33766 \InsetSpace ~
33767 \InsetSpace ~
33768 \InsetSpace ~
33769 \InsetSpace ~
33770 \InsetSpace ~
33771 \InsetSpace ~
33772 case 6: ...
33773 \newline
33774 \InsetSpace ~
33775 \InsetSpace ~
33776 \InsetSpace ~
33777 case 10: ...\InsetSpace ~
33778 \InsetSpace ~
33779 \InsetSpace ~
33780 \InsetSpace ~
33781 \InsetSpace ~
33782 \InsetSpace ~
33783 \InsetSpace ~
33784 \InsetSpace ~
33785 \InsetSpace ~
33786 \InsetSpace ~
33787 \InsetSpace ~
33788 \InsetSpace ~
33789 \InsetSpace ~
33790 \InsetSpace ~
33791 \InsetSpace ~
33792 \InsetSpace ~
33793 \InsetSpace ~
33794 \InsetSpace ~
33795 \InsetSpace ~
33796 \InsetSpace ~
33797 \InsetSpace ~
33798 \InsetSpace ~
33799 \InsetSpace ~
33800 \InsetSpace ~
33801 \InsetSpace ~
33802 case 7: ...
33803 \newline
33804 \InsetSpace ~
33805 \InsetSpace ~
33806 \InsetSpace ~
33807 case
33808  11: ...\InsetSpace ~
33809 \InsetSpace ~
33810 \InsetSpace ~
33811 \InsetSpace ~
33812 \InsetSpace ~
33813 \InsetSpace ~
33814 \InsetSpace ~
33815 \InsetSpace ~
33816 \InsetSpace ~
33817 \InsetSpace ~
33818 \InsetSpace ~
33819 \InsetSpace ~
33820 \InsetSpace ~
33821 \InsetSpace ~
33822 \InsetSpace ~
33823 \InsetSpace ~
33824 \InsetSpace ~
33825 \InsetSpace ~
33826 \InsetSpace ~
33827 \InsetSpace ~
33828 \InsetSpace ~
33829 \InsetSpace ~
33830 \InsetSpace ~
33831 \InsetSpace ~
33832 \InsetSpace ~
33833 case 8: ...
33834 \newline
33835 }\InsetSpace ~
33836 \InsetSpace ~
33837 \InsetSpace ~
33838 \InsetSpace ~
33839 \InsetSpace ~
33840 \InsetSpace ~
33841 \InsetSpace ~
33842 \InsetSpace ~
33843 \InsetSpace ~
33844 \InsetSpace ~
33845 \InsetSpace ~
33846 \InsetSpace ~
33847 \InsetSpace ~
33848 \InsetSpace ~
33849 \InsetSpace ~
33850 \InsetSpace ~
33851 \InsetSpace ~
33852 \InsetSpace ~
33853 \InsetSpace ~
33854 \InsetSpace ~
33855 \InsetSpace ~
33856 \InsetSpace ~
33857 \InsetSpace ~
33858 \InsetSpace ~
33859 \InsetSpace ~
33860 \InsetSpace ~
33861 \InsetSpace ~
33862 \InsetSpace ~
33863 \InsetSpace ~
33864 \InsetSpace ~
33865 \InsetSpace ~
33866 \InsetSpace ~
33867 \InsetSpace ~
33868 \InsetSpace ~
33869 \InsetSpace ~
33870 \InsetSpace ~
33871 }
33872 \end_layout
33873
33874 \begin_layout Standard
33875 Both the above switch statements will be implemented using a jump-table.
33876  The example to the right side is slightly more efficient as the check for
33877  the lower boundary of the jump-table is not needed.
33878 \end_layout
33879
33880 \end_deeper
33881 \begin_layout Itemize
33882 The number of case labels is not larger than supported by the target architectur
33883 e.
33884 \end_layout
33885
33886 \begin_layout Itemize
33887 If the case labels are not in numerical sequence ('gaps' between cases)
33888  SDCC checks whether a jump table with additionally inserted dummy cases
33889  is still attractive.
33890 \end_layout
33891
33892 \begin_layout Itemize
33893 If the starting number is not zero and a check for the lower boundary of
33894  the jump-table can thus be eliminated SDCC might insert dummy cases 0,
33895  ...
33896  .
33897 \end_layout
33898
33899 \begin_layout Standard
33900 Switch statements which have large gaps in the numeric sequence or those
33901  that have too many case labels can be split into more than one switch statement
33902  for efficient code generation, e.g.:
33903 \end_layout
33904
33905 \begin_layout Verse
33906
33907 \family typewriter
33908 switch (i) {
33909 \newline
33910 \InsetSpace ~
33911 \InsetSpace ~
33912 case 1: ...
33913 \newline
33914 \InsetSpace ~
33915 \InsetSpace ~
33916 case 2: ...
33917 \newline
33918 \InsetSpace ~
33919 \InsetSpace ~
33920 case 3: ...
33921 \newline
33922 \InsetSpace ~
33923 \InsetSpace ~
33924 case 4: ...
33925 \newline
33926 \InsetSpace ~
33927 \InsetSpace ~
33928 case 5: ...
33929 \newline
33930 \InsetSpace ~
33931 \InsetSpace ~
33932 case 6: ...
33933 \newline
33934 \InsetSpace ~
33935 \InsetSpace ~
33936 case 7: ...
33937 \newline
33938 \InsetSpace ~
33939 \InsetSpace ~
33940 case
33941  101: ...
33942 \newline
33943 \InsetSpace ~
33944 \InsetSpace ~
33945 case 102: ...
33946 \newline
33947 \InsetSpace ~
33948 \InsetSpace ~
33949 case 103: ...
33950 \newline
33951 \InsetSpace ~
33952 \InsetSpace ~
33953 case 104: ...
33954 \newline
33955 \InsetSpace ~
33956 \InsetSpace ~
33957 case 105: ...
33958 \newline
33959 \InsetSpace ~
33960 \InsetSpace ~
33961 case 106: ...
33962 \newline
33963 \InsetSpace ~
33964 \InsetSpace ~
33965 case 107: ...
33966 \newline
33967 }
33968 \end_layout
33969
33970 \begin_layout Standard
33971 If the above switch statement is broken down into two switch statements
33972 \end_layout
33973
33974 \begin_layout Verse
33975
33976 \family typewriter
33977 switch (i) {
33978 \newline
33979 \InsetSpace ~
33980 \InsetSpace ~
33981 case 1: ...
33982 \newline
33983 \InsetSpace ~
33984 \InsetSpace ~
33985 case 2: ...
33986 \newline
33987 \InsetSpace ~
33988 \InsetSpace ~
33989 case 3: ...
33990 \newline
33991 \InsetSpace ~
33992 \InsetSpace ~
33993 case 4: ...
33994 \newline
33995 \InsetSpace ~
33996 \InsetSpace ~
33997 case 5: ...
33998 \newline
33999 \InsetSpace ~
34000 \InsetSpace ~
34001 case 6: ...
34002 \newline
34003 \InsetSpace ~
34004 \InsetSpace ~
34005 case 7: ...
34006 \newline
34007 }
34008 \end_layout
34009
34010 \begin_layout Standard
34011 and
34012 \end_layout
34013
34014 \begin_layout Verse
34015
34016 \family typewriter
34017 switch (i) {
34018 \newline
34019 \InsetSpace ~
34020 \InsetSpace ~
34021 case 101: ...
34022 \newline
34023 \InsetSpace ~
34024 \InsetSpace ~
34025 case 102: ...
34026 \newline
34027 \InsetSpace ~
34028 \InsetSpace ~
34029 case 103: ...
34030 \newline
34031 \InsetSpace ~
34032 \InsetSpace ~
34033 case 104: ...
34034 \newline
34035 \InsetSpace ~
34036 \InsetSpace ~
34037 case 105: ...
34038 \newline
34039 \InsetSpace ~
34040 \InsetSpace ~
34041 case 106:
34042  ...
34043 \newline
34044 \InsetSpace ~
34045 \InsetSpace ~
34046 case 107: ...
34047 \newline
34048 }
34049 \end_layout
34050
34051 \begin_layout Standard
34052 then both the switch statements will be implemented using jump-tables whereas
34053  the unmodified switch statement will not be.
34054 \end_layout
34055
34056 \begin_layout Standard
34057 \begin_inset Note Note
34058 status collapsed
34059
34060 \begin_layout Standard
34061 There might be reasons which SDCC cannot know about to either favour or
34062  not favour jump tables.
34063  If the target system has to be as quick for the last switch case as for
34064  the first (pro jump table), or if the switch argument is known to be zero
34065  in the majority of the cases (contra jump table).
34066 \end_layout
34067
34068 \end_inset
34069
34070
34071 \end_layout
34072
34073 \begin_layout Standard
34074 The pragma nojtbound
34075 \begin_inset LatexCommand \index{\#pragma nojtbound}
34076
34077 \end_inset
34078
34079  can be used to turn off checking the
34080 \emph on
34081 j
34082 \emph default
34083 ump
34084 \emph on
34085 t
34086 \emph default
34087 able
34088 \emph on
34089 bound
34090 \emph default
34091 aries.
34092  It has no effect if a default label is supplied.
34093  Use of this pragma is dangerous: if the switch
34094 \begin_inset LatexCommand \index{switch statement}
34095
34096 \end_inset
34097
34098  argument is not matched by a case statement the processor will happily
34099  jump into Nirvana.
34100 \end_layout
34101
34102 \begin_layout Subsection
34103 Bit-shifting Operations
34104 \begin_inset LatexCommand \index{Bit shifting}
34105
34106 \end_inset
34107
34108 .
34109 \end_layout
34110
34111 \begin_layout Standard
34112 Bit shifting is one of the most frequently used operation in embedded programmin
34113 g.
34114  SDCC tries to implement bit-shift operations in the most efficient way
34115  possible, e.g.:
34116 \end_layout
34117
34118 \begin_layout Verse
34119
34120 \family typewriter
34121 unsigned char i;
34122 \newline
34123 ...
34124 \newline
34125 i >>= 4;
34126 \newline
34127 ...
34128 \end_layout
34129
34130 \begin_layout Standard
34131 generates the following code:
34132 \end_layout
34133
34134 \begin_layout Verse
34135
34136 \family typewriter
34137 mov\InsetSpace ~
34138  a,_i
34139 \newline
34140 swap a
34141 \newline
34142 anl\InsetSpace ~
34143  a,#0x0f
34144 \newline
34145 mov\InsetSpace ~
34146  _i,a
34147 \end_layout
34148
34149 \begin_layout Standard
34150 In general SDCC will never setup a loop if the shift count is known.
34151  Another example:
34152 \end_layout
34153
34154 \begin_layout Verse
34155
34156 \family typewriter
34157 unsigned int i;
34158 \newline
34159 ...
34160 \newline
34161 i >>= 9;
34162 \newline
34163 ...
34164 \end_layout
34165
34166 \begin_layout Standard
34167 will generate:
34168 \end_layout
34169
34170 \begin_layout Verse
34171
34172 \family typewriter
34173 mov\InsetSpace ~
34174 \InsetSpace ~
34175 a,(_i + 1)
34176 \newline
34177 mov\InsetSpace ~
34178 \InsetSpace ~
34179 (_i + 1),#0x00
34180 \newline
34181 clr\InsetSpace ~
34182 \InsetSpace ~
34183 c
34184 \newline
34185 rrc\InsetSpace ~
34186 \InsetSpace ~
34187 a
34188 \newline
34189 mov\InsetSpace ~
34190 \InsetSpace ~
34191 _i,a
34192 \end_layout
34193
34194 \begin_layout Subsection
34195 Bit-rotation
34196 \begin_inset LatexCommand \index{Bit rotation}
34197
34198 \end_inset
34199
34200
34201 \end_layout
34202
34203 \begin_layout Standard
34204 A special case of the bit-shift operation is bit rotation
34205 \begin_inset LatexCommand \index{rotating bits}
34206
34207 \end_inset
34208
34209 , SDCC recognizes the following expression to be a left bit-rotation:
34210 \end_layout
34211
34212 \begin_layout Verse
34213
34214 \family typewriter
34215 \series bold
34216 unsigned
34217 \series default
34218 \InsetSpace ~
34219 \InsetSpace ~
34220 char i;\InsetSpace ~
34221 \InsetSpace ~
34222 \InsetSpace ~
34223 \InsetSpace ~
34224 \InsetSpace ~
34225 \InsetSpace ~
34226 \InsetSpace ~
34227 \InsetSpace ~
34228 \InsetSpace ~
34229 \InsetSpace ~
34230 \InsetSpace ~
34231 /* unsigned is needed for rotation */
34232 \newline
34233 ...
34234 \newline
34235 i = ((i << 1) | (i >> 7));
34236 \family default
34237
34238 \newline
34239
34240 \family typewriter
34241 ...
34242 \end_layout
34243
34244 \begin_layout Standard
34245 will generate the following code:
34246 \end_layout
34247
34248 \begin_layout Verse
34249
34250 \family typewriter
34251 mov\InsetSpace ~
34252 \InsetSpace ~
34253 a,_i
34254 \newline
34255 rl\InsetSpace ~
34256 \InsetSpace ~
34257 \InsetSpace ~
34258 a
34259 \newline
34260 mov\InsetSpace ~
34261 \InsetSpace ~
34262 _i,a
34263 \end_layout
34264
34265 \begin_layout Standard
34266 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
34267 ns of this case will also be recognized as bit-rotation, i.e.:
34268 \end_layout
34269
34270 \begin_layout Verse
34271
34272 \family typewriter
34273 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
34274 \end_layout
34275
34276 \begin_layout Subsection
34277 Nibble and Byte Swapping
34278 \end_layout
34279
34280 \begin_layout Standard
34281 Other special cases of the bit-shift operations are nibble or byte swapping
34282 \begin_inset LatexCommand \index{swapping nibbles/bytes}
34283
34284 \end_inset
34285
34286 , SDCC recognizes the following expressions:
34287 \end_layout
34288
34289 \begin_layout Verse
34290
34291 \family typewriter
34292 \series bold
34293 unsigned
34294 \series default
34295 \InsetSpace ~
34296 \InsetSpace ~
34297 char i;
34298 \newline
34299
34300 \series bold
34301 unsigned
34302 \series default
34303 \InsetSpace ~
34304 \InsetSpace ~
34305 int j;
34306 \newline
34307 ...
34308 \newline
34309 i = ((i << 4) | (i >> 4));
34310 \family default
34311
34312 \newline
34313
34314 \family typewriter
34315 j = ((j << 8) | (j >> 8));
34316 \end_layout
34317
34318 \begin_layout Standard
34319 and generates a swap instruction for the nibble swapping
34320 \begin_inset LatexCommand \index{Nibble swapping}
34321
34322 \end_inset
34323
34324  or move instructions for the byte swapping
34325 \begin_inset LatexCommand \index{Byte swapping}
34326
34327 \end_inset
34328
34329 .
34330  The
34331 \begin_inset Quotes sld
34332 \end_inset
34333
34334 j
34335 \begin_inset Quotes srd
34336 \end_inset
34337
34338  example can be used to convert from little to big-endian or vice versa.
34339  If you want to change the endianness of a
34340 \emph on
34341 signed
34342 \emph default
34343  integer you have to cast to
34344 \family typewriter
34345 (unsigned int)
34346 \family default
34347  first.
34348 \end_layout
34349
34350 \begin_layout Standard
34351 Note that SDCC stores numbers in little-endian
34352 \begin_inset Foot
34353 status open
34354
34355 \begin_layout Standard
34356 Usually 8-bit processors don't care much about endianness.
34357  This is not the case for the standard 8051 which only has an instruction
34358  to increment its
34359 \emph on
34360 dptr
34361 \emph default
34362
34363 \begin_inset LatexCommand \index{DPTR}
34364
34365 \end_inset
34366
34367 -datapointerso little-endian is the more efficient byte order.
34368 \end_layout
34369
34370 \end_inset
34371
34372
34373 \begin_inset LatexCommand \index{little-endian}
34374
34375 \end_inset
34376
34377
34378 \begin_inset LatexCommand \index{Endianness}
34379
34380 \end_inset
34381
34382  format (i.e.
34383  lowest order first).
34384 \end_layout
34385
34386 \begin_layout Subsection
34387 Highest Order Bit
34388 \begin_inset LatexCommand \index{Highest Order Bit}
34389
34390 \end_inset
34391
34392  / Any Order Bit
34393 \begin_inset LatexCommand \index{Any Order Bit}
34394
34395 \end_inset
34396
34397
34398 \end_layout
34399
34400 \begin_layout Standard
34401 It is frequently required to obtain the highest order bit of an integral
34402  type (long, int, short or char types).
34403  Also obtaining any other order bit is not uncommon.
34404  SDCC recognizes the following expressions to yield the highest order bit
34405  and generates optimized code for it, e.g.:
34406 \end_layout
34407
34408 \begin_layout Verse
34409
34410 \family typewriter
34411 unsigned int gint;
34412 \newline
34413
34414 \newline
34415 foo () {
34416 \newline
34417 \InsetSpace ~
34418 \InsetSpace ~
34419 unsigned char hob1, aob1;
34420 \newline
34421 \InsetSpace ~
34422 \InsetSpace ~
34423 bit hob2, hob3, aob2,
34424  aob3;
34425 \newline
34426 \InsetSpace ~
34427 \InsetSpace ~
34428 ...
34429 \newline
34430 \InsetSpace ~
34431 \InsetSpace ~
34432 hob1 = (gint >> 15) & 1;
34433 \newline
34434 \InsetSpace ~
34435 \InsetSpace ~
34436 hob2 = (gint >> 15) & 1;
34437 \newline
34438 \InsetSpace ~
34439 \InsetSpace ~
34440 hob3 = gint & 0x8000;
34441 \newline
34442 \InsetSpace ~
34443 \InsetSpace ~
34444 aob1
34445  = (gint >> 9) & 1;
34446 \newline
34447 \InsetSpace ~
34448 \InsetSpace ~
34449 aob2 = (gint >> 8) & 1;
34450 \newline
34451 \InsetSpace ~
34452 \InsetSpace ~
34453 aob3 = gint & 0x0800;
34454 \newline
34455 \InsetSpace ~
34456 \InsetSpace ~
34457 ..
34458 \newline
34459 }
34460 \end_layout
34461
34462 \begin_layout Standard
34463 will generate the following code:
34464 \end_layout
34465
34466 \begin_layout Verse
34467
34468 \family typewriter
34469 \InsetSpace ~
34470 \InsetSpace ~
34471 \InsetSpace ~
34472 \InsetSpace ~
34473 \InsetSpace ~
34474 \InsetSpace ~
34475 \InsetSpace ~
34476 \InsetSpace ~
34477 \InsetSpace ~
34478 \InsetSpace ~
34479 \InsetSpace ~
34480 \InsetSpace ~
34481 \InsetSpace ~
34482 \InsetSpace ~
34483 \InsetSpace ~
34484 \InsetSpace ~
34485 \InsetSpace ~
34486 \InsetSpace ~
34487 \InsetSpace ~
34488 \InsetSpace ~
34489 \InsetSpace ~
34490 \InsetSpace ~
34491 \InsetSpace ~
34492 \InsetSpace ~
34493 \InsetSpace ~
34494  61 ;\InsetSpace ~
34495  hob.c 7
34496 \newline
34497 000A E5*01\InsetSpace ~
34498 \InsetSpace ~
34499 \InsetSpace ~
34500 \InsetSpace ~
34501 \InsetSpace ~
34502 \InsetSpace ~
34503 \InsetSpace ~
34504 \InsetSpace ~
34505 \InsetSpace ~
34506 \InsetSpace ~
34507 \InsetSpace ~
34508 \InsetSpace ~
34509 \InsetSpace ~
34510 \InsetSpace ~
34511 \InsetSpace ~
34512  62\InsetSpace ~
34513 \InsetSpace ~
34514 \InsetSpace ~
34515 \InsetSpace ~
34516 \InsetSpace ~
34517 \InsetSpace ~
34518 \InsetSpace ~
34519 \InsetSpace ~
34520  mov\InsetSpace ~
34521 \InsetSpace ~
34522  a,(_gint + 1)
34523 \newline
34524 000C 23\InsetSpace ~
34525 \InsetSpace ~
34526 \InsetSpace ~
34527 \InsetSpace ~
34528 \InsetSpace ~
34529 \InsetSpace ~
34530 \InsetSpace ~
34531 \InsetSpace ~
34532 \InsetSpace ~
34533 \InsetSpace ~
34534 \InsetSpace ~
34535 \InsetSpace ~
34536 \InsetSpace ~
34537 \InsetSpace ~
34538 \InsetSpace ~
34539 \InsetSpace ~
34540 \InsetSpace ~
34541 \InsetSpace ~
34542  63\InsetSpace ~
34543 \InsetSpace ~
34544 \InsetSpace ~
34545 \InsetSpace ~
34546 \InsetSpace ~
34547 \InsetSpace ~
34548 \InsetSpace ~
34549 \InsetSpace ~
34550  rl\InsetSpace ~
34551 \InsetSpace ~
34552 \InsetSpace ~
34553  a
34554 \newline
34555 000D 54 01\InsetSpace ~
34556 \InsetSpace ~
34557 \InsetSpace ~
34558 \InsetSpace ~
34559 \InsetSpace ~
34560 \InsetSpace ~
34561 \InsetSpace ~
34562 \InsetSpace ~
34563 \InsetSpace ~
34564 \InsetSpace ~
34565 \InsetSpace ~
34566 \InsetSpace ~
34567 \InsetSpace ~
34568 \InsetSpace ~
34569 \InsetSpace ~
34570  64\InsetSpace ~
34571 \InsetSpace ~
34572 \InsetSpace ~
34573 \InsetSpace ~
34574 \InsetSpace ~
34575 \InsetSpace ~
34576 \InsetSpace ~
34577 \InsetSpace ~
34578
34579  anl\InsetSpace ~
34580 \InsetSpace ~
34581  a,#0x01
34582 \newline
34583 000F F5*02\InsetSpace ~
34584 \InsetSpace ~
34585 \InsetSpace ~
34586 \InsetSpace ~
34587 \InsetSpace ~
34588 \InsetSpace ~
34589 \InsetSpace ~
34590 \InsetSpace ~
34591 \InsetSpace ~
34592 \InsetSpace ~
34593 \InsetSpace ~
34594 \InsetSpace ~
34595 \InsetSpace ~
34596 \InsetSpace ~
34597 \InsetSpace ~
34598  65\InsetSpace ~
34599 \InsetSpace ~
34600 \InsetSpace ~
34601 \InsetSpace ~
34602 \InsetSpace ~
34603 \InsetSpace ~
34604 \InsetSpace ~
34605 \InsetSpace ~
34606  mov\InsetSpace ~
34607 \InsetSpace ~
34608  _foo_hob1_1_1,a
34609 \newline
34610 \InsetSpace ~
34611 \InsetSpace ~
34612 \InsetSpace ~
34613 \InsetSpace ~
34614 \InsetSpace ~
34615 \InsetSpace ~
34616 \InsetSpace ~
34617 \InsetSpace ~
34618 \InsetSpace ~
34619 \InsetSpace ~
34620 \InsetSpace ~
34621 \InsetSpace ~
34622 \InsetSpace ~
34623 \InsetSpace ~
34624 \InsetSpace ~
34625 \InsetSpace ~
34626 \InsetSpace ~
34627 \InsetSpace ~
34628 \InsetSpace ~
34629 \InsetSpace ~
34630 \InsetSpace ~
34631 \InsetSpace ~
34632 \InsetSpace ~
34633 \InsetSpace ~
34634 \InsetSpace ~
34635  66 ;\InsetSpace ~
34636  hob.c 8
34637 \newline
34638 0011 E5*01\InsetSpace ~
34639 \InsetSpace ~
34640 \InsetSpace ~
34641 \InsetSpace ~
34642 \InsetSpace ~
34643 \InsetSpace ~
34644 \InsetSpace ~
34645 \InsetSpace ~
34646 \InsetSpace ~
34647 \InsetSpace ~
34648 \InsetSpace ~
34649 \InsetSpace ~
34650 \InsetSpace ~
34651 \InsetSpace ~
34652 \InsetSpace ~
34653  67\InsetSpace ~
34654 \InsetSpace ~
34655 \InsetSpace ~
34656 \InsetSpace ~
34657 \InsetSpace ~
34658 \InsetSpace ~
34659 \InsetSpace ~
34660 \InsetSpace ~
34661  mov\InsetSpace ~
34662 \InsetSpace ~
34663
34664  a,(_gint + 1)
34665 \newline
34666 0013 33\InsetSpace ~
34667 \InsetSpace ~
34668 \InsetSpace ~
34669 \InsetSpace ~
34670 \InsetSpace ~
34671 \InsetSpace ~
34672 \InsetSpace ~
34673 \InsetSpace ~
34674 \InsetSpace ~
34675 \InsetSpace ~
34676 \InsetSpace ~
34677 \InsetSpace ~
34678 \InsetSpace ~
34679 \InsetSpace ~
34680 \InsetSpace ~
34681 \InsetSpace ~
34682 \InsetSpace ~
34683 \InsetSpace ~
34684  68\InsetSpace ~
34685 \InsetSpace ~
34686 \InsetSpace ~
34687 \InsetSpace ~
34688 \InsetSpace ~
34689 \InsetSpace ~
34690 \InsetSpace ~
34691 \InsetSpace ~
34692  rlc\InsetSpace ~
34693 \InsetSpace ~
34694  a
34695 \newline
34696 0014 92*00\InsetSpace ~
34697 \InsetSpace ~
34698 \InsetSpace ~
34699 \InsetSpace ~
34700 \InsetSpace ~
34701 \InsetSpace ~
34702 \InsetSpace ~
34703 \InsetSpace ~
34704 \InsetSpace ~
34705 \InsetSpace ~
34706 \InsetSpace ~
34707 \InsetSpace ~
34708 \InsetSpace ~
34709 \InsetSpace ~
34710 \InsetSpace ~
34711  69\InsetSpace ~
34712 \InsetSpace ~
34713 \InsetSpace ~
34714 \InsetSpace ~
34715 \InsetSpace ~
34716 \InsetSpace ~
34717 \InsetSpace ~
34718 \InsetSpace ~
34719  mov\InsetSpace ~
34720 \InsetSpace ~
34721  _foo_hob2_1_1,c
34722 \newline
34723 \InsetSpace ~
34724 \InsetSpace ~
34725 \InsetSpace ~
34726 \InsetSpace ~
34727 \InsetSpace ~
34728 \InsetSpace ~
34729 \InsetSpace ~
34730 \InsetSpace ~
34731 \InsetSpace ~
34732 \InsetSpace ~
34733 \InsetSpace ~
34734 \InsetSpace ~
34735 \InsetSpace ~
34736 \InsetSpace ~
34737 \InsetSpace ~
34738 \InsetSpace ~
34739 \InsetSpace ~
34740 \InsetSpace ~
34741 \InsetSpace ~
34742 \InsetSpace ~
34743 \InsetSpace ~
34744 \InsetSpace ~
34745 \InsetSpace ~
34746 \InsetSpace ~
34747 \InsetSpace ~
34748  66 ;\InsetSpace ~
34749  hob.c
34750  9
34751 \newline
34752 0016 E5*01\InsetSpace ~
34753 \InsetSpace ~
34754 \InsetSpace ~
34755 \InsetSpace ~
34756 \InsetSpace ~
34757 \InsetSpace ~
34758 \InsetSpace ~
34759 \InsetSpace ~
34760 \InsetSpace ~
34761 \InsetSpace ~
34762 \InsetSpace ~
34763 \InsetSpace ~
34764 \InsetSpace ~
34765 \InsetSpace ~
34766 \InsetSpace ~
34767  67\InsetSpace ~
34768 \InsetSpace ~
34769 \InsetSpace ~
34770 \InsetSpace ~
34771 \InsetSpace ~
34772 \InsetSpace ~
34773 \InsetSpace ~
34774 \InsetSpace ~
34775  mov\InsetSpace ~
34776 \InsetSpace ~
34777  a,(_gint + 1)
34778 \newline
34779 0018 33\InsetSpace ~
34780 \InsetSpace ~
34781 \InsetSpace ~
34782 \InsetSpace ~
34783 \InsetSpace ~
34784 \InsetSpace ~
34785 \InsetSpace ~
34786 \InsetSpace ~
34787 \InsetSpace ~
34788 \InsetSpace ~
34789 \InsetSpace ~
34790 \InsetSpace ~
34791 \InsetSpace ~
34792 \InsetSpace ~
34793 \InsetSpace ~
34794 \InsetSpace ~
34795 \InsetSpace ~
34796 \InsetSpace ~
34797  68\InsetSpace ~
34798 \InsetSpace ~
34799 \InsetSpace ~
34800 \InsetSpace ~
34801 \InsetSpace ~
34802 \InsetSpace ~
34803 \InsetSpace ~
34804 \InsetSpace ~
34805  rlc\InsetSpace ~
34806 \InsetSpace ~
34807  a
34808 \newline
34809 0019 92*01\InsetSpace ~
34810 \InsetSpace ~
34811 \InsetSpace ~
34812 \InsetSpace ~
34813 \InsetSpace ~
34814 \InsetSpace ~
34815 \InsetSpace ~
34816 \InsetSpace ~
34817 \InsetSpace ~
34818 \InsetSpace ~
34819 \InsetSpace ~
34820 \InsetSpace ~
34821 \InsetSpace ~
34822 \InsetSpace ~
34823 \InsetSpace ~
34824  69\InsetSpace ~
34825 \InsetSpace ~
34826 \InsetSpace ~
34827 \InsetSpace ~
34828 \InsetSpace ~
34829 \InsetSpace ~
34830 \InsetSpace ~
34831 \InsetSpace ~
34832  mov\InsetSpace ~
34833 \InsetSpace ~
34834  _foo_hob3_1_1
34835 ,c
34836 \newline
34837 \InsetSpace ~
34838 \InsetSpace ~
34839 \InsetSpace ~
34840 \InsetSpace ~
34841 \InsetSpace ~
34842 \InsetSpace ~
34843 \InsetSpace ~
34844 \InsetSpace ~
34845 \InsetSpace ~
34846 \InsetSpace ~
34847 \InsetSpace ~
34848 \InsetSpace ~
34849 \InsetSpace ~
34850 \InsetSpace ~
34851 \InsetSpace ~
34852 \InsetSpace ~
34853 \InsetSpace ~
34854 \InsetSpace ~
34855 \InsetSpace ~
34856 \InsetSpace ~
34857 \InsetSpace ~
34858 \InsetSpace ~
34859 \InsetSpace ~
34860 \InsetSpace ~
34861 \InsetSpace ~
34862  70 ;\InsetSpace ~
34863  hob.c 10
34864 \newline
34865 001B E5*01\InsetSpace ~
34866 \InsetSpace ~
34867 \InsetSpace ~
34868 \InsetSpace ~
34869 \InsetSpace ~
34870 \InsetSpace ~
34871 \InsetSpace ~
34872 \InsetSpace ~
34873 \InsetSpace ~
34874 \InsetSpace ~
34875 \InsetSpace ~
34876 \InsetSpace ~
34877 \InsetSpace ~
34878 \InsetSpace ~
34879 \InsetSpace ~
34880  71\InsetSpace ~
34881 \InsetSpace ~
34882 \InsetSpace ~
34883 \InsetSpace ~
34884 \InsetSpace ~
34885 \InsetSpace ~
34886 \InsetSpace ~
34887 \InsetSpace ~
34888  mov\InsetSpace ~
34889 \InsetSpace ~
34890  a,(_gint + 1)
34891 \newline
34892 001D 03\InsetSpace ~
34893 \InsetSpace ~
34894 \InsetSpace ~
34895 \InsetSpace ~
34896 \InsetSpace ~
34897 \InsetSpace ~
34898 \InsetSpace ~
34899 \InsetSpace ~
34900 \InsetSpace ~
34901 \InsetSpace ~
34902 \InsetSpace ~
34903 \InsetSpace ~
34904 \InsetSpace ~
34905 \InsetSpace ~
34906 \InsetSpace ~
34907 \InsetSpace ~
34908 \InsetSpace ~
34909 \InsetSpace ~
34910  72\InsetSpace ~
34911 \InsetSpace ~
34912 \InsetSpace ~
34913 \InsetSpace ~
34914 \InsetSpace ~
34915 \InsetSpace ~
34916 \InsetSpace ~
34917 \InsetSpace ~
34918  rr\InsetSpace ~
34919 \InsetSpace ~
34920 \InsetSpace ~
34921  a
34922 \newline
34923 001E 54 01\InsetSpace ~
34924 \InsetSpace ~
34925 \InsetSpace ~
34926 \InsetSpace ~
34927 \InsetSpace ~
34928 \InsetSpace ~
34929 \InsetSpace ~
34930 \InsetSpace ~
34931 \InsetSpace ~
34932 \InsetSpace ~
34933 \InsetSpace ~
34934 \InsetSpace ~
34935 \InsetSpace ~
34936 \InsetSpace ~
34937 \InsetSpace ~
34938
34939  73\InsetSpace ~
34940 \InsetSpace ~
34941 \InsetSpace ~
34942 \InsetSpace ~
34943 \InsetSpace ~
34944 \InsetSpace ~
34945 \InsetSpace ~
34946 \InsetSpace ~
34947  anl\InsetSpace ~
34948 \InsetSpace ~
34949  a,#0x01
34950 \newline
34951 0020 F5*03\InsetSpace ~
34952 \InsetSpace ~
34953 \InsetSpace ~
34954 \InsetSpace ~
34955 \InsetSpace ~
34956 \InsetSpace ~
34957 \InsetSpace ~
34958 \InsetSpace ~
34959 \InsetSpace ~
34960 \InsetSpace ~
34961 \InsetSpace ~
34962 \InsetSpace ~
34963 \InsetSpace ~
34964 \InsetSpace ~
34965 \InsetSpace ~
34966  74\InsetSpace ~
34967 \InsetSpace ~
34968 \InsetSpace ~
34969 \InsetSpace ~
34970 \InsetSpace ~
34971 \InsetSpace ~
34972 \InsetSpace ~
34973 \InsetSpace ~
34974  mov\InsetSpace ~
34975 \InsetSpace ~
34976  _foo_aob1_1_1,a
34977 \newline
34978 \InsetSpace ~
34979 \InsetSpace ~
34980 \InsetSpace ~
34981 \InsetSpace ~
34982 \InsetSpace ~
34983 \InsetSpace ~
34984 \InsetSpace ~
34985 \InsetSpace ~
34986 \InsetSpace ~
34987 \InsetSpace ~
34988 \InsetSpace ~
34989 \InsetSpace ~
34990 \InsetSpace ~
34991 \InsetSpace ~
34992 \InsetSpace ~
34993 \InsetSpace ~
34994 \InsetSpace ~
34995 \InsetSpace ~
34996 \InsetSpace ~
34997 \InsetSpace ~
34998 \InsetSpace ~
34999 \InsetSpace ~
35000 \InsetSpace ~
35001 \InsetSpace ~
35002 \InsetSpace ~
35003  75 ;\InsetSpace ~
35004  hob.c 11
35005 \newline
35006 0022 E5*01\InsetSpace ~
35007 \InsetSpace ~
35008 \InsetSpace ~
35009 \InsetSpace ~
35010 \InsetSpace ~
35011 \InsetSpace ~
35012 \InsetSpace ~
35013 \InsetSpace ~
35014 \InsetSpace ~
35015 \InsetSpace ~
35016 \InsetSpace ~
35017 \InsetSpace ~
35018 \InsetSpace ~
35019 \InsetSpace ~
35020 \InsetSpace ~
35021
35022  76\InsetSpace ~
35023 \InsetSpace ~
35024 \InsetSpace ~
35025 \InsetSpace ~
35026 \InsetSpace ~
35027 \InsetSpace ~
35028 \InsetSpace ~
35029 \InsetSpace ~
35030  mov\InsetSpace ~
35031 \InsetSpace ~
35032  a,(_gint + 1)
35033 \newline
35034 0024 13\InsetSpace ~
35035 \InsetSpace ~
35036 \InsetSpace ~
35037 \InsetSpace ~
35038 \InsetSpace ~
35039 \InsetSpace ~
35040 \InsetSpace ~
35041 \InsetSpace ~
35042 \InsetSpace ~
35043 \InsetSpace ~
35044 \InsetSpace ~
35045 \InsetSpace ~
35046 \InsetSpace ~
35047 \InsetSpace ~
35048 \InsetSpace ~
35049 \InsetSpace ~
35050 \InsetSpace ~
35051 \InsetSpace ~
35052  77\InsetSpace ~
35053 \InsetSpace ~
35054 \InsetSpace ~
35055 \InsetSpace ~
35056 \InsetSpace ~
35057 \InsetSpace ~
35058 \InsetSpace ~
35059 \InsetSpace ~
35060  rrc\InsetSpace ~
35061 \InsetSpace ~
35062  a
35063 \newline
35064 0025 92*02\InsetSpace ~
35065 \InsetSpace ~
35066 \InsetSpace ~
35067 \InsetSpace ~
35068 \InsetSpace ~
35069 \InsetSpace ~
35070 \InsetSpace ~
35071 \InsetSpace ~
35072 \InsetSpace ~
35073 \InsetSpace ~
35074 \InsetSpace ~
35075 \InsetSpace ~
35076 \InsetSpace ~
35077 \InsetSpace ~
35078 \InsetSpace ~
35079  78\InsetSpace ~
35080 \InsetSpace ~
35081 \InsetSpace ~
35082 \InsetSpace ~
35083 \InsetSpace ~
35084 \InsetSpace ~
35085 \InsetSpace ~
35086 \InsetSpace ~
35087  mov\InsetSpace ~
35088 \InsetSpace ~
35089  _foo_aob2_1_1,c
35090 \newline
35091 \InsetSpace ~
35092 \InsetSpace ~
35093 \InsetSpace ~
35094 \InsetSpace ~
35095 \InsetSpace ~
35096 \InsetSpace ~
35097 \InsetSpace ~
35098 \InsetSpace ~
35099 \InsetSpace ~
35100 \InsetSpace ~
35101 \InsetSpace ~
35102 \InsetSpace ~
35103 \InsetSpace ~
35104 \InsetSpace ~
35105 \InsetSpace ~
35106 \InsetSpace ~
35107 \InsetSpace ~
35108 \InsetSpace ~
35109 \InsetSpace ~
35110 \InsetSpace ~
35111 \InsetSpace ~
35112 \InsetSpace ~
35113 \InsetSpace ~
35114 \InsetSpace ~
35115 \InsetSpace ~
35116  79
35117  ;\InsetSpace ~
35118  hob.c 12
35119 \newline
35120 0027 E5*01\InsetSpace ~
35121 \InsetSpace ~
35122 \InsetSpace ~
35123 \InsetSpace ~
35124 \InsetSpace ~
35125 \InsetSpace ~
35126 \InsetSpace ~
35127 \InsetSpace ~
35128 \InsetSpace ~
35129 \InsetSpace ~
35130 \InsetSpace ~
35131 \InsetSpace ~
35132 \InsetSpace ~
35133 \InsetSpace ~
35134 \InsetSpace ~
35135  80\InsetSpace ~
35136 \InsetSpace ~
35137 \InsetSpace ~
35138 \InsetSpace ~
35139 \InsetSpace ~
35140 \InsetSpace ~
35141 \InsetSpace ~
35142 \InsetSpace ~
35143  mov\InsetSpace ~
35144 \InsetSpace ~
35145  a,(_gint + 1)
35146 \newline
35147 0029 A2 E3\InsetSpace ~
35148 \InsetSpace ~
35149 \InsetSpace ~
35150 \InsetSpace ~
35151 \InsetSpace ~
35152 \InsetSpace ~
35153 \InsetSpace ~
35154 \InsetSpace ~
35155 \InsetSpace ~
35156 \InsetSpace ~
35157 \InsetSpace ~
35158 \InsetSpace ~
35159 \InsetSpace ~
35160 \InsetSpace ~
35161 \InsetSpace ~
35162  81\InsetSpace ~
35163 \InsetSpace ~
35164 \InsetSpace ~
35165 \InsetSpace ~
35166 \InsetSpace ~
35167 \InsetSpace ~
35168 \InsetSpace ~
35169 \InsetSpace ~
35170  mov\InsetSpace ~
35171 \InsetSpace ~
35172  c,acc[3]
35173 \newline
35174 002B
35175  92*03\InsetSpace ~
35176 \InsetSpace ~
35177 \InsetSpace ~
35178 \InsetSpace ~
35179 \InsetSpace ~
35180 \InsetSpace ~
35181 \InsetSpace ~
35182 \InsetSpace ~
35183 \InsetSpace ~
35184 \InsetSpace ~
35185 \InsetSpace ~
35186 \InsetSpace ~
35187 \InsetSpace ~
35188 \InsetSpace ~
35189 \InsetSpace ~
35190  82\InsetSpace ~
35191 \InsetSpace ~
35192 \InsetSpace ~
35193 \InsetSpace ~
35194 \InsetSpace ~
35195 \InsetSpace ~
35196 \InsetSpace ~
35197 \InsetSpace ~
35198  mov\InsetSpace ~
35199 \InsetSpace ~
35200  _foo_aob3_1_1,c
35201 \end_layout
35202
35203 \begin_layout Standard
35204 Other variations of these cases however will
35205 \emph on
35206 not
35207 \emph default
35208  be recognized.
35209  They are standard C expressions, so I heartily recommend these be the only
35210  way to get the highest order bit, (it is portable).
35211  Of course it will be recognized even if it is embedded in other expressions,
35212  e.g.:
35213 \end_layout
35214
35215 \begin_layout Verse
35216
35217 \family typewriter
35218 xyz = gint + ((gint >> 15) & 1);
35219 \end_layout
35220
35221 \begin_layout Standard
35222 will still be recognized.
35223 \end_layout
35224
35225 \begin_layout Subsection
35226 Higher Order Byte
35227 \begin_inset LatexCommand \index{Higher Order Byte}
35228
35229 \end_inset
35230
35231  / Higher Order Word
35232 \begin_inset LatexCommand \index{Higher Order Word}
35233
35234 \end_inset
35235
35236
35237 \end_layout
35238
35239 \begin_layout Standard
35240 It is also frequently required to obtain a higher order byte or word of
35241  a larger integral type (long, int or short types).
35242  SDCC recognizes the following expressions to yield the higher order byte
35243  or word and generates optimized code for it, e.g.:
35244 \end_layout
35245
35246 \begin_layout Verse
35247
35248 \family typewriter
35249 unsigned int gint;
35250 \newline
35251 unsigned long int glong;
35252 \newline
35253
35254 \newline
35255 foo () {
35256 \newline
35257 \InsetSpace ~
35258 \InsetSpace ~
35259 unsigned char hob1, hob2;
35260 \newline
35261 \InsetSpace ~
35262 \InsetSpace ~
35263 unsig
35264 ned int how1, how2;
35265 \newline
35266 \InsetSpace ~
35267 \InsetSpace ~
35268 ...
35269 \newline
35270 \InsetSpace ~
35271 \InsetSpace ~
35272 hob1 = (gint >> 8) & 0xFF;
35273 \newline
35274 \InsetSpace ~
35275 \InsetSpace ~
35276 hob2 = glong >> 24;
35277 \newline
35278 \InsetSpace ~
35279 \InsetSpace ~
35280 how1 = (glong
35281  >> 16) & 0xFFFF;
35282 \newline
35283 \InsetSpace ~
35284 \InsetSpace ~
35285 how2 = glong >> 8;
35286 \newline
35287 \InsetSpace ~
35288 \InsetSpace ~
35289 ..
35290 \newline
35291 }
35292 \end_layout
35293
35294 \begin_layout Standard
35295 will generate the following code:
35296 \end_layout
35297
35298 \begin_layout Verse
35299
35300 \family typewriter
35301 \InsetSpace ~
35302 \InsetSpace ~
35303 \InsetSpace ~
35304 \InsetSpace ~
35305 \InsetSpace ~
35306 \InsetSpace ~
35307 \InsetSpace ~
35308 \InsetSpace ~
35309 \InsetSpace ~
35310 \InsetSpace ~
35311 \InsetSpace ~
35312 \InsetSpace ~
35313 \InsetSpace ~
35314 \InsetSpace ~
35315 \InsetSpace ~
35316 \InsetSpace ~
35317 \InsetSpace ~
35318 \InsetSpace ~
35319 \InsetSpace ~
35320 \InsetSpace ~
35321 \InsetSpace ~
35322 \InsetSpace ~
35323 \InsetSpace ~
35324 \InsetSpace ~
35325 \InsetSpace ~
35326  91 ;\InsetSpace ~
35327  hob.c 15
35328 \newline
35329 0037 85*01*06\InsetSpace ~
35330 \InsetSpace ~
35331 \InsetSpace ~
35332 \InsetSpace ~
35333 \InsetSpace ~
35334 \InsetSpace ~
35335 \InsetSpace ~
35336 \InsetSpace ~
35337 \InsetSpace ~
35338 \InsetSpace ~
35339 \InsetSpace ~
35340 \InsetSpace ~
35341  92\InsetSpace ~
35342 \InsetSpace ~
35343 \InsetSpace ~
35344 \InsetSpace ~
35345 \InsetSpace ~
35346 \InsetSpace ~
35347 \InsetSpace ~
35348 \InsetSpace ~
35349  mov\InsetSpace ~
35350 \InsetSpace ~
35351  _foo_hob1_1_1,(_gint + 1)
35352 \newline
35353 \InsetSpace ~
35354 \InsetSpace ~
35355 \InsetSpace ~
35356 \InsetSpace ~
35357 \InsetSpace ~
35358 \InsetSpace ~
35359 \InsetSpace ~
35360 \InsetSpace ~
35361 \InsetSpace ~
35362 \InsetSpace ~
35363 \InsetSpace ~
35364 \InsetSpace ~
35365 \InsetSpace ~
35366 \InsetSpace ~
35367 \InsetSpace ~
35368 \InsetSpace ~
35369 \InsetSpace ~
35370 \InsetSpace ~
35371 \InsetSpace ~
35372 \InsetSpace ~
35373 \InsetSpace ~
35374 \InsetSpace ~
35375 \InsetSpace ~
35376 \InsetSpace ~
35377 \InsetSpace ~
35378  93 ;\InsetSpace ~
35379  hob.c 16
35380 \newline
35381 003A
35382  85*05*07\InsetSpace ~
35383 \InsetSpace ~
35384 \InsetSpace ~
35385 \InsetSpace ~
35386 \InsetSpace ~
35387 \InsetSpace ~
35388 \InsetSpace ~
35389 \InsetSpace ~
35390 \InsetSpace ~
35391 \InsetSpace ~
35392 \InsetSpace ~
35393 \InsetSpace ~
35394  94\InsetSpace ~
35395 \InsetSpace ~
35396 \InsetSpace ~
35397 \InsetSpace ~
35398 \InsetSpace ~
35399 \InsetSpace ~
35400 \InsetSpace ~
35401 \InsetSpace ~
35402  mov\InsetSpace ~
35403 \InsetSpace ~
35404  _foo_hob2_1_1,(_glong + 3)
35405 \newline
35406 \InsetSpace ~
35407 \InsetSpace ~
35408 \InsetSpace ~
35409 \InsetSpace ~
35410 \InsetSpace ~
35411 \InsetSpace ~
35412 \InsetSpace ~
35413 \InsetSpace ~
35414 \InsetSpace ~
35415 \InsetSpace ~
35416 \InsetSpace ~
35417 \InsetSpace ~
35418 \InsetSpace ~
35419 \InsetSpace ~
35420 \InsetSpace ~
35421 \InsetSpace ~
35422 \InsetSpace ~
35423 \InsetSpace ~
35424 \InsetSpace ~
35425 \InsetSpace ~
35426 \InsetSpace ~
35427 \InsetSpace ~
35428 \InsetSpace ~
35429 \InsetSpace ~
35430 \InsetSpace ~
35431  95 ;\InsetSpace ~
35432  hob.c 17
35433 \newline
35434 003D 85*04*08\InsetSpace ~
35435 \InsetSpace ~
35436 \InsetSpace ~
35437 \InsetSpace ~
35438 \InsetSpace ~
35439 \InsetSpace ~
35440 \InsetSpace ~
35441 \InsetSpace ~
35442 \InsetSpace ~
35443 \InsetSpace ~
35444 \InsetSpace ~
35445 \InsetSpace ~
35446  96\InsetSpace ~
35447 \InsetSpace ~
35448 \InsetSpace ~
35449 \InsetSpace ~
35450 \InsetSpace ~
35451 \InsetSpace ~
35452 \InsetSpace ~
35453 \InsetSpace ~
35454
35455  mov\InsetSpace ~
35456 \InsetSpace ~
35457  _foo_how1_1_1,(_glong + 2)
35458 \newline
35459 0040 85*05*09\InsetSpace ~
35460 \InsetSpace ~
35461 \InsetSpace ~
35462 \InsetSpace ~
35463 \InsetSpace ~
35464 \InsetSpace ~
35465 \InsetSpace ~
35466 \InsetSpace ~
35467 \InsetSpace ~
35468 \InsetSpace ~
35469 \InsetSpace ~
35470 \InsetSpace ~
35471  97\InsetSpace ~
35472 \InsetSpace ~
35473 \InsetSpace ~
35474 \InsetSpace ~
35475 \InsetSpace ~
35476 \InsetSpace ~
35477 \InsetSpace ~
35478 \InsetSpace ~
35479  mov\InsetSpace ~
35480 \InsetSpace ~
35481  (_foo_how1_1_1 + 1),(_glong
35482  + 3)
35483 \newline
35484 0043 85*03*0A\InsetSpace ~
35485 \InsetSpace ~
35486 \InsetSpace ~
35487 \InsetSpace ~
35488 \InsetSpace ~
35489 \InsetSpace ~
35490 \InsetSpace ~
35491 \InsetSpace ~
35492 \InsetSpace ~
35493 \InsetSpace ~
35494 \InsetSpace ~
35495 \InsetSpace ~
35496  98\InsetSpace ~
35497 \InsetSpace ~
35498 \InsetSpace ~
35499 \InsetSpace ~
35500 \InsetSpace ~
35501 \InsetSpace ~
35502 \InsetSpace ~
35503 \InsetSpace ~
35504  mov\InsetSpace ~
35505 \InsetSpace ~
35506  _foo_how2_1_1,(_glong + 1)
35507 \newline
35508 0046 85*04*0B\InsetSpace ~
35509 \InsetSpace ~
35510 \InsetSpace ~
35511 \InsetSpace ~
35512 \InsetSpace ~
35513 \InsetSpace ~
35514 \InsetSpace ~
35515 \InsetSpace ~
35516 \InsetSpace ~
35517 \InsetSpace ~
35518 \InsetSpace ~
35519 \InsetSpace ~
35520  99\InsetSpace ~
35521 \InsetSpace ~
35522 \InsetSpace ~
35523 \InsetSpace ~
35524 \InsetSpace ~
35525 \InsetSpace ~
35526 \InsetSpace ~
35527 \InsetSpace ~
35528  mov\InsetSpace ~
35529 \InsetSpace ~
35530
35531  (_foo_how2_1_1 + 1),(_glong + 2)
35532 \end_layout
35533
35534 \begin_layout Standard
35535 Again, variations of these cases may
35536 \emph on
35537 not
35538 \emph default
35539  be recognized.
35540  They are standard C expressions, so I heartily recommend these be the only
35541  way to get the higher order byte/word, (it is portable).
35542  Of course it will be recognized even if it is embedded in other expressions,
35543  e.g.:
35544 \end_layout
35545
35546 \begin_layout Verse
35547
35548 \family typewriter
35549 xyz = gint + ((gint >> 8) & 0xFF);
35550 \end_layout
35551
35552 \begin_layout Standard
35553 will still be recognized.
35554 \end_layout
35555
35556 \begin_layout Subsection
35557 Peephole Optimizer
35558 \begin_inset LatexCommand \label{sub:Peephole-Optimizer}
35559
35560 \end_inset
35561
35562
35563 \begin_inset LatexCommand \index{Peephole optimizer}
35564
35565 \end_inset
35566
35567
35568 \end_layout
35569
35570 \begin_layout Standard
35571 The compiler uses a rule based, pattern matching and re-writing mechanism
35572  for peep-hole optimization.
35573  It is inspired by
35574 \emph on
35575 copt
35576 \emph default
35577  a peep-hole optimizer by Christopher W.
35578  Fraser (cwfraser\InsetSpace ~
35579 @\InsetSpace ~
35580 microsoft.com).
35581  A default set of rules are compiled into the compiler, additional rules
35582  may be added with the
35583 \emph on
35584 -
35585 \begin_inset ERT
35586 status collapsed
35587
35588 \begin_layout Standard
35589
35590
35591 \backslash
35592 /
35593 \end_layout
35594
35595 \end_inset
35596
35597 -peep-file
35598 \begin_inset LatexCommand \index{-\/-peep-file}
35599
35600 \end_inset
35601
35602  <filename>
35603 \emph default
35604  option.
35605  The rule language is best illustrated with examples.
35606 \end_layout
35607
35608 \begin_layout Verse
35609
35610 \family typewriter
35611 replace {
35612 \newline
35613 \InsetSpace ~
35614 \InsetSpace ~
35615 mov %1,a
35616 \newline
35617 \InsetSpace ~
35618 \InsetSpace ~
35619 mov a,%1
35620 \newline
35621 } by {
35622 \newline
35623 \InsetSpace ~
35624 \InsetSpace ~
35625 mov %1,a
35626 \newline
35627 }
35628 \end_layout
35629
35630 \begin_layout Standard
35631 The above rule will change the following assembly
35632 \begin_inset LatexCommand \index{Assembler routines}
35633
35634 \end_inset
35635
35636  sequence:
35637 \end_layout
35638
35639 \begin_layout Verse
35640
35641 \family typewriter
35642 mov r1,a
35643 \newline
35644 mov a,r1
35645 \end_layout
35646
35647 \begin_layout Standard
35648 to
35649 \end_layout
35650
35651 \begin_layout Verse
35652
35653 \family typewriter
35654 mov r1,a
35655 \end_layout
35656
35657 \begin_layout Standard
35658 Note: All occurrences of a
35659 \emph on
35660 %n
35661 \emph default
35662  (pattern variable) must denote the same string.
35663  With the above rule, the assembly sequence:
35664 \end_layout
35665
35666 \begin_layout Verse
35667
35668 \family typewriter
35669 mov r1,a
35670 \newline
35671 mov a,r2
35672 \end_layout
35673
35674 \begin_layout Standard
35675 will remain unmodified.
35676 \newline
35677
35678 \newline
35679 Other special case optimizations may be added by the
35680  user (via
35681 \emph on
35682 -
35683 \begin_inset ERT
35684 status collapsed
35685
35686 \begin_layout Standard
35687
35688
35689 \backslash
35690 /
35691 \end_layout
35692
35693 \end_inset
35694
35695 -peep-file option
35696 \emph default
35697 ).
35698  E.g.
35699  some variants of the 8051 MCU
35700 \begin_inset LatexCommand \index{MCS51 variants}
35701
35702 \end_inset
35703
35704  allow only
35705 \family typewriter
35706 ajmp
35707 \family default
35708  and
35709 \family typewriter
35710 acall
35711 \family default
35712 .
35713  The following two rules will change all
35714 \family typewriter
35715 ljmp
35716 \family default
35717  and
35718 \family typewriter
35719 lcall
35720 \family default
35721  to
35722 \family typewriter
35723 ajmp
35724 \family default
35725  and
35726 \family typewriter
35727 acall
35728 \end_layout
35729
35730 \begin_layout Verse
35731
35732 \family typewriter
35733 replace { lcall %1 } by { acall %1 }
35734 \newline
35735 replace { ljmp %1 } by { ajmp %1 }
35736 \end_layout
35737
35738 \begin_layout Standard
35739 (NOTE: from version 2.7.3 on, you can use option -
35740 \emph on
35741
35742 \begin_inset ERT
35743 status collapsed
35744
35745 \begin_layout Standard
35746
35747
35748 \backslash
35749 /
35750 \end_layout
35751
35752 \end_inset
35753
35754
35755 \emph default
35756 -acall-ajmp
35757 \begin_inset LatexCommand \index{-\/-acall-ajmp}
35758
35759 \end_inset
35760
35761 , which also takes care of aligning the interrupt vectors properly.)
35762 \newline
35763
35764 \end_layout
35765
35766 \begin_layout Standard
35767 The
35768 \emph on
35769 inline-assembler code
35770 \emph default
35771  is also passed through the peep hole optimizer, thus the peephole optimizer
35772  can also be used as an assembly level macro expander.
35773  The rules themselves are MCU dependent whereas the rule language infra-structur
35774 e is MCU independent.
35775  Peephole optimization rules for other MCU can be easily programmed using
35776  the rule language.
35777 \newline
35778
35779 \newline
35780 The syntax for a rule is as follows:
35781 \end_layout
35782
35783 \begin_layout Verse
35784
35785 \family typewriter
35786 rule := replace [ restart ] '{' <assembly sequence> '
35787 \backslash
35788 n'
35789 \newline
35790 \InsetSpace ~
35791  \InsetSpace ~
35792  \InsetSpace ~
35793  \InsetSpace ~
35794  \InsetSpace ~
35795  \InsetSpace ~
35796  \InsetSpace ~
35797  \InsetSpace ~
35798  \InsetSpace ~
35799  \InsetSpace ~
35800  \InsetSpace ~
35801  \InsetSpace ~
35802  \InsetSpace ~
35803  \InsetSpace ~
35804  '}' by '{' '
35805 \backslash
35806 n'
35807 \newline
35808 \InsetSpace ~
35809  \InsetSpace ~
35810  \InsetSpace ~
35811  \InsetSpace ~
35812  \InsetSpace ~
35813  \InsetSpace ~
35814  \InsetSpace ~
35815  \InsetSpace ~
35816  \InsetSpace ~
35817  \InsetSpace ~
35818  \InsetSpace ~
35819  \InsetSpace ~
35820  \InsetSpace ~
35821  \InsetSpace ~
35822  \InsetSpace ~
35823  \InsetSpace ~
35824  <assembly sequence> '
35825 \backslash
35826 n'
35827 \newline
35828 \InsetSpace ~
35829  \InsetSpace ~
35830  \InsetSpace ~
35831  \InsetSpace ~
35832  \InsetSpace ~
35833  \InsetSpace ~
35834  \InsetSpace ~
35835  \InsetSpace ~
35836  \InsetSpace ~
35837  \InsetSpace ~
35838  \InsetSpace ~
35839  \InsetSpace ~
35840  \InsetSpace ~
35841  \InsetSpace ~
35842  '}' [if <functionName> ] '
35843 \backslash
35844 n'
35845 \end_layout
35846
35847 \begin_layout Standard
35848 <assembly sequence> := assembly instruction (each instruction including
35849  labels must be on a separate line).
35850 \newline
35851
35852 \newline
35853 The optimizer will apply to the rules
35854  one by one from the top in the sequence of their appearance, it will terminate
35855  when all rules are exhausted.
35856  If the 'restart' option is specified, then the optimizer will start matching
35857  the rules again from the top, this option for a rule is expensive (performance)
35858 , it is intended to be used in situations where a transformation will trigger
35859  the same rule again.
35860  An example of this (not a good one, it has side effects) is the following
35861  rule:
35862 \end_layout
35863
35864 \begin_layout Verse
35865
35866 \family typewriter
35867 replace restart {
35868 \newline
35869 \InsetSpace ~
35870 \InsetSpace ~
35871 pop %1
35872 \newline
35873 \InsetSpace ~
35874 \InsetSpace ~
35875 push %1 } by {
35876 \newline
35877 \InsetSpace ~
35878 \InsetSpace ~
35879 ; nop
35880 \newline
35881 }
35882 \end_layout
35883
35884 \begin_layout Standard
35885 Note that the replace pattern cannot be a blank, but can be a comment line.
35886  Without the 'restart' option only the innermost 'pop' 'push' pair would
35887  be eliminated, i.e.:
35888 \end_layout
35889
35890 \begin_layout Verse
35891
35892 \family typewriter
35893 pop ar1
35894 \newline
35895 pop ar2
35896 \newline
35897 push ar2
35898 \newline
35899 push ar1
35900 \end_layout
35901
35902 \begin_layout Standard
35903 would result in:
35904 \end_layout
35905
35906 \begin_layout Verse
35907
35908 \family typewriter
35909 pop ar1
35910 \newline
35911 ; nop
35912 \newline
35913 push ar1
35914 \end_layout
35915
35916 \begin_layout Standard
35917
35918 \emph on
35919 with
35920 \emph default
35921  the restart option the rule will be applied again to the resulting code
35922  and then all the pop-push pairs will be eliminated to yield:
35923 \end_layout
35924
35925 \begin_layout Verse
35926
35927 \family typewriter
35928 ; nop
35929 \newline
35930 ; nop
35931 \end_layout
35932
35933 \begin_layout Standard
35934 A conditional function can be attached to a rule.
35935  Attaching rules are somewhat more involved, let me illustrate this with
35936  an example.
35937 \end_layout
35938
35939 \begin_layout Verse
35940
35941 \family typewriter
35942 replace {
35943 \newline
35944 \InsetSpace ~
35945  \InsetSpace ~
35946  \InsetSpace ~
35947 ljmp %5
35948 \newline
35949 %2:
35950 \newline
35951 } by {
35952 \newline
35953 \InsetSpace ~
35954  \InsetSpace ~
35955  \InsetSpace ~
35956 sjmp %5
35957 \newline
35958 %2:
35959 \newline
35960 } if labelInRange
35961 \end_layout
35962
35963 \begin_layout Standard
35964 The optimizer does a look-up of a function name table defined in function
35965 \emph on
35966 callFuncByName
35967 \emph default
35968  in the source file SDCCpeeph.c, with the name
35969 \emph on
35970 labelInRange
35971 \emph default
35972 .
35973  If it finds a corresponding entry the function is called.
35974  Note there can be no parameters specified for these functions, in this
35975  case the use of
35976 \emph on
35977 %5
35978 \emph default
35979  is crucial, since the function
35980 \emph on
35981 labelInRange
35982 \emph default
35983  expects to find the label in that particular variable (the hash table containin
35984 g the variable bindings is passed as a parameter).
35985  If you want to code more such functions, take a close look at the function
35986  labelInRange and the calling mechanism in source file SDCCpeeph.c.
35987  Currently implemented are
35988 \emph on
35989 labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
35990  24bitMode, portIsDS390, 24bitModeAndPortDS390
35991 \emph default
35992 and
35993 \emph on
35994  notVolatile
35995 \emph default
35996 .
35997 \end_layout
35998
35999 \begin_layout Standard
36000 I know this whole thing is a little kludgey, but maybe some day we will
36001  have some better means.
36002  If you are looking at this file, you will see the default rules that are
36003  compiled into the compiler, you can add your own rules in the default set
36004  there if you get tired of specifying the -
36005 \begin_inset ERT
36006 status collapsed
36007
36008 \begin_layout Standard
36009
36010
36011 \backslash
36012 /
36013 \end_layout
36014
36015 \end_inset
36016
36017 -peep-file option.
36018 \end_layout
36019
36020 \begin_layout Section
36021 ANSI-Compliance
36022 \begin_inset LatexCommand \index{ANSI-compliance}
36023
36024 \end_inset
36025
36026
36027 \begin_inset LatexCommand \label{sub:ANSI-Compliance}
36028
36029 \end_inset
36030
36031
36032 \end_layout
36033
36034 \begin_layout Standard
36035 The latest publically available version of the standard
36036 \emph on
36037  ISO/IEC 9899 - Programming languages - C
36038 \emph default
36039  should be available at:
36040 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
36041
36042 \end_inset
36043
36044 .
36045 \newline
36046
36047 \end_layout
36048
36049 \begin_layout Standard
36050 Deviations from the compliance:
36051 \end_layout
36052
36053 \begin_layout Itemize
36054 functions are not reentrant
36055 \begin_inset LatexCommand \index{reentrant}
36056
36057 \end_inset
36058
36059  unless explicitly declared as such or the
36060 \series bold
36061 -
36062 \begin_inset ERT
36063 status collapsed
36064
36065 \begin_layout Standard
36066
36067
36068 \backslash
36069 /
36070 \end_layout
36071
36072 \end_inset
36073
36074 -stack-auto
36075 \begin_inset LatexCommand \index{-\/-stack-auto}
36076
36077 \end_inset
36078
36079
36080 \series default
36081  command line option is specified.
36082 \end_layout
36083
36084 \begin_layout Itemize
36085 structures
36086 \begin_inset LatexCommand \index{struct}
36087
36088 \end_inset
36089
36090  and unions
36091 \begin_inset LatexCommand \index{union}
36092
36093 \end_inset
36094
36095  cannot be assigned values directly, cannot be passed as function parameters
36096  or assigned to each other and cannot be a return value
36097 \begin_inset LatexCommand \index{return value}
36098
36099 \end_inset
36100
36101  from a function, e.g.:
36102 \end_layout
36103
36104 \begin_deeper
36105 \begin_layout Verse
36106
36107 \family typewriter
36108 struct s { ...
36109  };
36110 \newline
36111 struct s s1, s2;
36112 \newline
36113 foo()
36114 \newline
36115 {
36116 \newline
36117 \InsetSpace ~
36118 \InsetSpace ~
36119 \InsetSpace ~
36120 \InsetSpace ~
36121 ...
36122 \newline
36123 \InsetSpace ~
36124 \InsetSpace ~
36125 \InsetSpace ~
36126 \InsetSpace ~
36127 s1 = s2 ; /* is invalid in SDCC although allowed
36128  in ANSI */
36129 \newline
36130 \InsetSpace ~
36131 \InsetSpace ~
36132 \InsetSpace ~
36133 \InsetSpace ~
36134 ...
36135 \newline
36136 }
36137 \newline
36138
36139 \series bold
36140 struct
36141 \series default
36142  s foo1 (
36143 \series bold
36144 struct
36145 \series default
36146  s parms) /* invalid in SDCC although allowed in ANSI */
36147 \newline
36148 {
36149 \newline
36150 \InsetSpace ~
36151 \InsetSpace ~
36152 \InsetSpace ~
36153 \InsetSpace ~
36154 struct s rets;
36155 \newline
36156 \InsetSpace ~
36157 \InsetSpace ~
36158 \InsetSpace ~
36159 \InsetSpace ~
36160 ...
36161 \newline
36162 \InsetSpace ~
36163 \InsetSpace ~
36164 \InsetSpace ~
36165 \InsetSpace ~
36166 return
36167  rets; /* is invalid in SDCC although allowed in ANSI */
36168 \newline
36169 }
36170 \end_layout
36171
36172 \end_deeper
36173 \begin_layout Itemize
36174 initialization of structure arrays must be fully braced.
36175 \end_layout
36176
36177 \begin_deeper
36178 \begin_layout Verse
36179
36180 \family typewriter
36181 struct s { char x } a[] = {1, 2};\InsetSpace ~
36182 \InsetSpace ~
36183 \InsetSpace ~
36184 \InsetSpace ~
36185 \InsetSpace ~
36186 /* invalid in SDCC */
36187 \newline
36188 struct s { char x
36189  } a[] = {{1}, {2}}; /* OK */
36190 \end_layout
36191
36192 \end_deeper
36193 \begin_layout Itemize
36194 'long long
36195 \begin_inset LatexCommand \index{long long (not supported)}
36196
36197 \end_inset
36198
36199 ' (64 bit integers
36200 \begin_inset LatexCommand \index{int (64 bit) (not supported)}
36201
36202 \end_inset
36203
36204 ) not supported.
36205 \end_layout
36206
36207 \begin_layout Itemize
36208 'double
36209 \begin_inset LatexCommand \index{double (not supported)}
36210
36211 \end_inset
36212
36213 ' precision floating point
36214 \begin_inset LatexCommand \index{Floating point support}
36215
36216 \end_inset
36217
36218 not supported.
36219 \end_layout
36220
36221 \begin_layout Itemize
36222 Old K&R style
36223 \begin_inset LatexCommand \index{K\&R style}
36224
36225 \end_inset
36226
36227  function declarations are NOT allowed.
36228 \end_layout
36229
36230 \begin_deeper
36231 \begin_layout Verse
36232
36233 \family typewriter
36234 foo(i,j) /* this old style of function declarations */
36235 \newline
36236 int i,j; /* is valid
36237  in ANSI but not valid in SDCC */
36238 \newline
36239 {
36240 \newline
36241 \InsetSpace ~
36242 \InsetSpace ~
36243 \InsetSpace ~
36244 \InsetSpace ~
36245 ...
36246 \newline
36247 }
36248 \end_layout
36249
36250 \end_deeper
36251 \begin_layout Itemize
36252 Most enhancements in C99 are not supported, e.g.:
36253 \end_layout
36254
36255 \begin_deeper
36256 \begin_layout Verse
36257
36258 \family typewriter
36259 for (
36260 \series bold
36261 int
36262 \series default
36263  i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
36264 \end_layout
36265
36266 \end_deeper
36267 \begin_layout Itemize
36268 But some have been added recently in SDCC 2.7.0.
36269  They must be considered alpha quality however.
36270 \end_layout
36271
36272 \begin_deeper
36273 \begin_layout Verse
36274
36275 \family typewriter
36276 \series bold
36277 inline
36278 \begin_inset LatexCommand \index{inline (not supported)}
36279
36280 \end_inset
36281
36282
36283 \series default
36284  int increment (int a) { return a+1; } /* inlines the increment without
36285  function call overhead */
36286 \newline
36287 int *
36288 \series bold
36289 restrict
36290 \begin_inset LatexCommand \index{inline (not supported)}
36291
36292 \end_inset
36293
36294
36295 \series default
36296  p; /* accepted but ignored */
36297 \end_layout
36298
36299 \end_deeper
36300 \begin_layout Itemize
36301 Certain words that are valid identifiers in the standard may be reserved
36302  words in SDCC unless the
36303 \series bold
36304  -
36305 \begin_inset ERT
36306 status collapsed
36307
36308 \begin_layout Standard
36309
36310
36311 \backslash
36312 /
36313 \end_layout
36314
36315 \end_inset
36316
36317 -std-c89
36318 \begin_inset LatexCommand \index{-\/-std-c89}
36319
36320 \end_inset
36321
36322  or -
36323 \begin_inset ERT
36324 status collapsed
36325
36326 \begin_layout Standard
36327
36328
36329 \backslash
36330 /
36331 \end_layout
36332
36333 \end_inset
36334
36335 -std-c99
36336 \begin_inset LatexCommand \index{-\/-std-c99}
36337
36338 \end_inset
36339
36340
36341 \series default
36342  command line options are used.
36343  These may include (depending on the selected processor): 'at', 'banked',
36344  'bit', 'code', 'critical', 'data', 'eeprom', 'far', 'flash', 'idata', 'interrup
36345 t', 'near', 'nonbanked', 'pdata', 'reentrant', 'sbit', 'sfr', 'shadowregs',
36346  'sram', 'using', 'wparam', 'xdata', '_overlay', '_asm', '_endasm', and
36347  '_naked'.
36348  Compliant equivalents of these keywords are always available in a form
36349  that begin with two underscores
36350 \begin_inset LatexCommand \index{\_\_ (prefix for extended keywords)}
36351
36352 \end_inset
36353
36354 , f.e.
36355  '__data' instead of 'data'.
36356 \end_layout
36357
36358 \begin_layout Itemize
36359 integer promotion of variable arguments is not performed if the argument
36360  is explicitly taypecasted unless the
36361 \series bold
36362  -
36363 \begin_inset ERT
36364 status collapsed
36365
36366 \begin_layout Standard
36367
36368
36369 \backslash
36370 /
36371 \end_layout
36372
36373 \end_inset
36374
36375 -std-c89
36376 \begin_inset LatexCommand \index{-\/-std-c89}
36377
36378 \end_inset
36379
36380  or -
36381 \begin_inset ERT
36382 status collapsed
36383
36384 \begin_layout Standard
36385
36386
36387 \backslash
36388 /
36389 \end_layout
36390
36391 \end_inset
36392
36393 -std-c99
36394 \begin_inset LatexCommand \index{-\/-std-c99}
36395
36396 \end_inset
36397
36398
36399 \series default
36400  command line options are used.
36401 \end_layout
36402
36403 \begin_deeper
36404 \begin_layout Verse
36405
36406 \family typewriter
36407 void vararg_func (char *str, ...) { atr; }
36408 \newline
36409
36410 \newline
36411 void main (void)
36412 \newline
36413 {
36414 \newline
36415 \InsetSpace ~
36416 \InsetSpace ~
36417 char c = 10;
36418 \newline
36419
36420 \newline
36421 \InsetSpace ~
36422 \InsetSpace ~
36423 /* argument
36424  u is promoted to int before
36425 \newline
36426 \InsetSpace ~
36427 \InsetSpace ~
36428 \InsetSpace ~
36429 * passing to function */
36430 \newline
36431 \InsetSpace ~
36432 \InsetSpace ~
36433 vararg_func (
36434 \begin_inset Quotes sld
36435 \end_inset
36436
36437 %c
36438 \begin_inset Quotes srd
36439 \end_inset
36440
36441 , c);
36442 \newline
36443
36444 \newline
36445 \InsetSpace ~
36446 \InsetSpace ~
36447 /* argument u is not promoted to int,
36448 \newline
36449 \InsetSpace ~
36450 \InsetSpace ~
36451 \InsetSpace ~
36452 * it is passed as char to function
36453 \newline
36454 \InsetSpace ~
36455 \InsetSpace ~
36456 \InsetSpace ~
36457 *
36458  if --std-cXX is not defined;
36459 \newline
36460 \InsetSpace ~
36461 \InsetSpace ~
36462 \InsetSpace ~
36463 * is promoted to int before passing
36464 \newline
36465 \InsetSpace ~
36466 \InsetSpace ~
36467 \InsetSpace ~
36468 * to function
36469  if --std-cXX is defined */
36470 \newline
36471 \InsetSpace ~
36472 \InsetSpace ~
36473 vararg_func (
36474 \begin_inset Quotes sld
36475 \end_inset
36476
36477 %bc
36478 \begin_inset Quotes srd
36479 \end_inset
36480
36481 , (char)u);
36482 \newline
36483 }
36484 \end_layout
36485
36486 \end_deeper
36487 \begin_layout Section
36488 Cyclomatic Complexity
36489 \begin_inset LatexCommand \index{Cyclomatic complexity}
36490
36491 \end_inset
36492
36493
36494 \end_layout
36495
36496 \begin_layout Standard
36497 Cyclomatic complexity of a function is defined as the number of independent
36498  paths the program can take during execution of the function.
36499  This is an important number since it defines the number test cases you
36500  have to generate to validate the function.
36501  The accepted industry standard for complexity number is 10, if the cyclomatic
36502  complexity reported by SDCC exceeds 10 you should think about simplification
36503  of the function logic.
36504  Note that the complexity level is not related to the number of lines of
36505  code in a function.
36506  Large functions can have low complexity, and small functions can have large
36507  complexity levels.
36508 \newline
36509
36510 \newline
36511 SDCC uses the following formula to compute the complexity:
36512 \newline
36513
36514 \end_layout
36515
36516 \begin_layout Standard
36517 complexity = (number of edges in control flow graph) - (number of nodes
36518  in control flow graph) + 2;
36519 \newline
36520
36521 \newline
36522 Having said that the industry standard is 10,
36523  you should be aware that in some cases it be may unavoidable to have a
36524  complexity level of less than 10.
36525  For example if you have switch statement with more than 10 case labels,
36526  each case label adds one to the complexity level.
36527  The complexity level is by no means an absolute measure of the algorithmic
36528  complexity of the function, it does however provide a good starting point
36529  for which functions you might look at for further optimization.
36530 \end_layout
36531
36532 \begin_layout Section
36533 Retargetting for other Processors
36534 \end_layout
36535
36536 \begin_layout Standard
36537 The issues for retargetting the compiler are far too numerous to be covered
36538  by this document.
36539  What follows is a brief description of each of the seven phases of the
36540  compiler and its MCU dependency.
36541 \end_layout
36542
36543 \begin_layout Itemize
36544 Parsing the source and building the annotated parse tree.
36545  This phase is largely MCU independent (except for the language extensions).
36546  Syntax & semantic checks are also done in this phase, along with some initial
36547  optimizations like back patching labels and the pattern matching optimizations
36548  like bit-rotation etc.
36549 \end_layout
36550
36551 \begin_layout Itemize
36552 The second phase involves generating an intermediate code which can be easy
36553  manipulated during the later phases.
36554  This phase is entirely MCU independent.
36555  The intermediate code generation assumes the target machine has unlimited
36556  number of registers, and designates them with the name iTemp.
36557  The compiler can be made to dump a human readable form of the code generated
36558  by using the -
36559 \begin_inset ERT
36560 status collapsed
36561
36562 \begin_layout Standard
36563
36564
36565 \backslash
36566 /
36567 \end_layout
36568
36569 \end_inset
36570
36571 -dumpraw option.
36572 \end_layout
36573
36574 \begin_layout Itemize
36575 This phase does the bulk of the standard optimizations and is also MCU independe
36576 nt.
36577  This phase can be broken down into several sub-phases:
36578 \newline
36579
36580 \newline
36581 Break down intermediate
36582  code (iCode) into basic blocks.
36583 \newline
36584 Do control flow & data flow analysis on the
36585  basic blocks.
36586 \newline
36587 Do local common subexpression elimination, then global subexpressio
36588 n elimination
36589 \newline
36590 Dead code elimination
36591 \newline
36592 Loop optimizations
36593 \newline
36594 If loop optimizations
36595  caused any changes then do 'global subexpression elimination' and 'dead
36596  code elimination' again.
36597 \end_layout
36598
36599 \begin_layout Itemize
36600 This phase determines the live-ranges; by live range I mean those iTemp
36601  variables defined by the compiler that still survive after all the optimization
36602 s.
36603  Live range analysis
36604 \begin_inset LatexCommand \index{Live range analysis}
36605
36606 \end_inset
36607
36608  is essential for register allocation, since these computation determines
36609  which of these iTemps will be assigned to registers, and for how long.
36610 \end_layout
36611
36612 \begin_layout Itemize
36613 Phase five is register allocation.
36614  There are two parts to this process.
36615 \newline
36616
36617 \newline
36618 The first part I call 'register packing'
36619  (for lack of a better term).
36620  In this case several MCU specific expression folding is done to reduce
36621  register pressure.
36622 \newline
36623
36624 \newline
36625 The second part is more MCU independent and deals with
36626  allocating registers to the remaining live ranges.
36627  A lot of MCU specific code does creep into this phase because of the limited
36628  number of index registers available in the 8051.
36629 \end_layout
36630
36631 \begin_layout Itemize
36632 The Code generation phase is (unhappily), entirely MCU dependent and very
36633  little (if any at all) of this code can be reused for other MCU.
36634  However the scheme for allocating a homogenized assembler operand for each
36635  iCode operand may be reused.
36636 \end_layout
36637
36638 \begin_layout Itemize
36639 As mentioned in the optimization section the peep-hole optimizer is rule
36640  based system, which can reprogrammed for other MCUs.
36641 \end_layout
36642
36643 \begin_layout Standard
36644 More information is available on SDCC Wiki
36645 \begin_inset LatexCommand \index{wiki}
36646
36647 \end_inset
36648
36649  (preliminary link
36650 \begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/SDCC+internals+and+porting}
36651
36652 \end_inset
36653
36654 ) and in the thread
36655 \begin_inset LatexCommand \url{http://sf.net/mailarchive/message.php?msg_id=13954144}
36656
36657 \end_inset
36658
36659  .
36660 \end_layout
36661
36662 \begin_layout Chapter
36663 Compiler internals
36664 \begin_inset LatexCommand \index{Compiler internals}
36665
36666 \end_inset
36667
36668
36669 \end_layout
36670
36671 \begin_layout Section
36672 The anatomy of the compiler
36673 \begin_inset LatexCommand \label{sub:The-anatomy-of}
36674
36675 \end_inset
36676
36677
36678 \end_layout
36679
36680 \begin_layout Standard
36681
36682 \shape italic
36683 This is an excerpt from an article published in Circuit Cellar Magazine
36684  in
36685 \series bold
36686 August 2000
36687 \series default
36688 .
36689  It's a little outdated (the compiler is much more efficient now and user/develo
36690 per friendly), but pretty well exposes the guts of it all.
36691 \shape default
36692
36693 \newline
36694
36695 \newline
36696 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
36697  It is fairly easy to retarget for other 8-bit MCU.
36698  Here we take a look at some of the internals of the compiler.
36699 \end_layout
36700
36701 \begin_layout Paragraph*
36702 Parsing
36703 \begin_inset LatexCommand \index{Parsing}
36704
36705 \end_inset
36706
36707
36708 \end_layout
36709
36710 \begin_layout Standard
36711 Parsing the input source file and creating an AST (Annotated Syntax Tree
36712 \begin_inset LatexCommand \index{Annotated syntax tree}
36713
36714 \end_inset
36715
36716 ).
36717  This phase also involves propagating types (annotating each node of the
36718  parse tree with type information) and semantic analysis.
36719  There are some MCU specific parsing rules.
36720  For example the storage classes, the extended storage classes are MCU specific
36721  while there may be a xdata storage class for 8051 there is no such storage
36722  class for z80 or Atmel AVR.
36723  SDCC allows MCU specific storage class extensions, i.e.
36724  xdata will be treated as a storage class specifier when parsing 8051 C
36725  code but will be treated as a C identifier when parsing z80 or ATMEL AVR
36726  C code.
36727 \end_layout
36728
36729 \begin_layout Paragraph*
36730 Generating iCode
36731 \begin_inset LatexCommand \index{iCode}
36732
36733 \end_inset
36734
36735
36736 \end_layout
36737
36738 \begin_layout Standard
36739 Intermediate code generation.
36740  In this phase the AST is broken down into three-operand form (iCode).
36741  These three operand forms are represented as doubly linked lists.
36742  ICode is the term given to the intermediate form generated by the compiler.
36743  ICode example section shows some examples of iCode generated for some simple
36744  C source functions.
36745 \end_layout
36746
36747 \begin_layout Paragraph*
36748 Optimizations
36749 \begin_inset LatexCommand \index{Optimizations}
36750
36751 \end_inset
36752
36753 .
36754 \end_layout
36755
36756 \begin_layout Standard
36757 Bulk of the target independent optimizations is performed in this phase.
36758  The optimizations include constant propagation, common sub-expression eliminati
36759 on, loop invariant code movement, strength reduction of loop induction variables
36760  and dead-code elimination.
36761 \end_layout
36762
36763 \begin_layout Paragraph*
36764 Live range analysis
36765 \begin_inset LatexCommand \index{Live range analysis}
36766
36767 \end_inset
36768
36769
36770 \end_layout
36771
36772 \begin_layout Standard
36773 During intermediate code generation phase, the compiler assumes the target
36774  machine has infinite number of registers and generates a lot of temporary
36775  variables.
36776  The live range computation determines the lifetime of each of these compiler-ge
36777 nerated temporaries.
36778  A picture speaks a thousand words.
36779  ICode example sections show the live range annotations for each of the
36780  operand.
36781  It is important to note here, each iCode is assigned a number in the order
36782  of its execution in the function.
36783  The live ranges are computed in terms of these numbers.
36784  The from number is the number of the iCode which first defines the operand
36785  and the to number signifies the iCode which uses this operand last.
36786 \end_layout
36787
36788 \begin_layout Paragraph*
36789 Register Allocation
36790 \begin_inset LatexCommand \index{Register allocation}
36791
36792 \end_inset
36793
36794
36795 \end_layout
36796
36797 \begin_layout Standard
36798 The register allocation determines the type and number of registers needed
36799  by each operand.
36800  In most MCUs only a few registers can be used for indirect addressing.
36801  In case of 8051 for example the registers R0 & R1 can be used to indirectly
36802  address the internal ram and DPTR to indirectly address the external ram.
36803  The compiler will try to allocate the appropriate register to pointer variables
36804  if it can.
36805  ICode example section shows the operands annotated with the registers assigned
36806  to them.
36807  The compiler will try to keep operands in registers as much as possible;
36808  there are several schemes the compiler uses to do achieve this.
36809  When the compiler runs out of registers the compiler will check to see
36810  if there are any live operands which is not used or defined in the current
36811  basic block being processed, if there are any found then it will push that
36812  operand and use the registers in this block, the operand will then be popped
36813  at the end of the basic block.
36814 \end_layout
36815
36816 \begin_layout Standard
36817 There are other MCU specific considerations in this phase.
36818  Some MCUs have an accumulator; very short-lived operands could be assigned
36819  to the accumulator instead of a general-purpose register.
36820 \end_layout
36821
36822 \begin_layout Paragraph*
36823 Code generation
36824 \end_layout
36825
36826 \begin_layout Standard
36827 Figure II gives a table of iCode
36828 \begin_inset LatexCommand \index{iCode}
36829
36830 \end_inset
36831
36832  operations supported by the compiler.
36833  The code generation involves translating these operations into corresponding
36834  assembly code for the processor.
36835  This sounds overly simple but that is the essence of code generation.
36836  Some of the iCode operations are generated on a MCU specific manner for
36837  example, the z80 port does not use registers to pass parameters so the
36838  SEND and RECV iCode operations will not be generated, and it also does
36839  not support JUMPTABLES.
36840 \newline
36841
36842 \end_layout
36843
36844 \begin_layout Standard
36845
36846 \size footnotesize
36847 Figure II
36848 \begin_inset Tabular
36849 <lyxtabular version="3" rows="39" columns="4">
36850 <features islongtable="true" headBottomDL="true">
36851 <column alignment="block" valignment="top" leftline="true" width="13col%">
36852 <column alignment="left" valignment="top" leftline="true" width="13col%">
36853 <column alignment="block" valignment="top" leftline="true" width="22col%">
36854 <column alignment="block" valignment="top" leftline="true" rightline="true" width="40col%">
36855 <row topline="true" bottomline="true" endhead="true">
36856 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36857 \begin_inset Text
36858
36859 \begin_layout Standard
36860
36861 \series bold
36862 iCode
36863 \series default
36864
36865 \begin_inset LatexCommand \index{iCode}
36866
36867 \end_inset
36868
36869
36870 \end_layout
36871
36872 \end_inset
36873 </cell>
36874 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36875 \begin_inset Text
36876
36877 \begin_layout Standard
36878
36879 \series bold
36880 Operands
36881 \end_layout
36882
36883 \end_inset
36884 </cell>
36885 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36886 \begin_inset Text
36887
36888 \begin_layout Standard
36889
36890 \series bold
36891 Description
36892 \end_layout
36893
36894 \end_inset
36895 </cell>
36896 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
36897 \begin_inset Text
36898
36899 \begin_layout Standard
36900
36901 \series bold
36902 C Equivalent
36903 \end_layout
36904
36905 \end_inset
36906 </cell>
36907 </row>
36908 <row topline="true">
36909 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36910 \begin_inset Text
36911
36912 \begin_layout Standard
36913
36914 \size footnotesize
36915 '!'
36916 \end_layout
36917
36918 \end_inset
36919 </cell>
36920 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36921 \begin_inset Text
36922
36923 \begin_layout Standard
36924
36925 \size footnotesize
36926 IC_LEFT() IC_RESULT()
36927 \end_layout
36928
36929 \end_inset
36930 </cell>
36931 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36932 \begin_inset Text
36933
36934 \begin_layout Standard
36935
36936 \size footnotesize
36937 NOT operation
36938 \end_layout
36939
36940 \end_inset
36941 </cell>
36942 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
36943 \begin_inset Text
36944
36945 \begin_layout Standard
36946
36947 \size footnotesize
36948 IC_RESULT = ! IC_LEFT;
36949 \end_layout
36950
36951 \end_inset
36952 </cell>
36953 </row>
36954 <row topline="true">
36955 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36956 \begin_inset Text
36957
36958 \begin_layout Standard
36959
36960 \size footnotesize
36961 '~'
36962 \end_layout
36963
36964 \end_inset
36965 </cell>
36966 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36967 \begin_inset Text
36968
36969 \begin_layout Standard
36970
36971 \size footnotesize
36972 IC_LEFT() IC_RESULT()
36973 \end_layout
36974
36975 \end_inset
36976 </cell>
36977 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36978 \begin_inset Text
36979
36980 \begin_layout Standard
36981
36982 \size footnotesize
36983 Bitwise complement of
36984 \end_layout
36985
36986 \end_inset
36987 </cell>
36988 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
36989 \begin_inset Text
36990
36991 \begin_layout Standard
36992
36993 \size footnotesize
36994 IC_RESULT = ~IC_LEFT;
36995 \end_layout
36996
36997 \end_inset
36998 </cell>
36999 </row>
37000 <row topline="true">
37001 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37002 \begin_inset Text
37003
37004 \begin_layout Standard
37005
37006 \size footnotesize
37007 RRC
37008 \end_layout
37009
37010 \end_inset
37011 </cell>
37012 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37013 \begin_inset Text
37014
37015 \begin_layout Standard
37016
37017 \size footnotesize
37018 IC_LEFT() IC_RESULT()
37019 \end_layout
37020
37021 \end_inset
37022 </cell>
37023 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37024 \begin_inset Text
37025
37026 \begin_layout Standard
37027
37028 \size footnotesize
37029 Rotate right with carry
37030 \end_layout
37031
37032 \end_inset
37033 </cell>
37034 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37035 \begin_inset Text
37036
37037 \begin_layout Standard
37038
37039 \size footnotesize
37040 IC_RESULT = (IC_LEFT << 1) | (IC_LEFT >> (sizeof(IC_LEFT)*8-1));
37041 \end_layout
37042
37043 \end_inset
37044 </cell>
37045 </row>
37046 <row topline="true">
37047 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37048 \begin_inset Text
37049
37050 \begin_layout Standard
37051
37052 \size footnotesize
37053 RLC
37054 \end_layout
37055
37056 \end_inset
37057 </cell>
37058 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37059 \begin_inset Text
37060
37061 \begin_layout Standard
37062
37063 \size footnotesize
37064 IC_LEFT() IC_RESULT()
37065 \end_layout
37066
37067 \end_inset
37068 </cell>
37069 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37070 \begin_inset Text
37071
37072 \begin_layout Standard
37073
37074 \size footnotesize
37075 Rotate left with carry
37076 \end_layout
37077
37078 \end_inset
37079 </cell>
37080 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37081 \begin_inset Text
37082
37083 \begin_layout Standard
37084
37085 \size footnotesize
37086 IC_RESULT = (IC_LEFT << (sizeof(LC_LEFT)*8-1) ) | (IC_LEFT >> 1);
37087 \end_layout
37088
37089 \end_inset
37090 </cell>
37091 </row>
37092 <row topline="true">
37093 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37094 \begin_inset Text
37095
37096 \begin_layout Standard
37097
37098 \size footnotesize
37099 GETHBIT
37100 \end_layout
37101
37102 \end_inset
37103 </cell>
37104 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37105 \begin_inset Text
37106
37107 \begin_layout Standard
37108
37109 \size footnotesize
37110 IC_LEFT() IC_RESULT()
37111 \end_layout
37112
37113 \end_inset
37114 </cell>
37115 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37116 \begin_inset Text
37117
37118 \begin_layout Standard
37119
37120 \size footnotesize
37121 Get the highest order bit of IC_LEFT
37122 \end_layout
37123
37124 \end_inset
37125 </cell>
37126 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37127 \begin_inset Text
37128
37129 \begin_layout Standard
37130
37131 \size footnotesize
37132 IC_RESULT = (IC_LEFT >> (sizeof(IC_LEFT)*8 -1));
37133 \end_layout
37134
37135 \end_inset
37136 </cell>
37137 </row>
37138 <row topline="true">
37139 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37140 \begin_inset Text
37141
37142 \begin_layout Standard
37143
37144 \size footnotesize
37145 UNARYMINUS
37146 \end_layout
37147
37148 \end_inset
37149 </cell>
37150 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37151 \begin_inset Text
37152
37153 \begin_layout Standard
37154
37155 \size footnotesize
37156 IC_LEFT() IC_RESULT()
37157 \end_layout
37158
37159 \end_inset
37160 </cell>
37161 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37162 \begin_inset Text
37163
37164 \begin_layout Standard
37165
37166 \size footnotesize
37167 Unary minus
37168 \end_layout
37169
37170 \end_inset
37171 </cell>
37172 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37173 \begin_inset Text
37174
37175 \begin_layout Standard
37176
37177 \size footnotesize
37178 IC_RESULT = - IC_LEFT;
37179 \end_layout
37180
37181 \end_inset
37182 </cell>
37183 </row>
37184 <row topline="true">
37185 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37186 \begin_inset Text
37187
37188 \begin_layout Standard
37189
37190 \size footnotesize
37191 IPUSH
37192 \end_layout
37193
37194 \end_inset
37195 </cell>
37196 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37197 \begin_inset Text
37198
37199 \begin_layout Standard
37200
37201 \size footnotesize
37202 IC_LEFT()
37203 \end_layout
37204
37205 \end_inset
37206 </cell>
37207 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37208 \begin_inset Text
37209
37210 \begin_layout Standard
37211
37212 \size footnotesize
37213 Push the operand into stack
37214 \end_layout
37215
37216 \end_inset
37217 </cell>
37218 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37219 \begin_inset Text
37220
37221 \begin_layout Standard
37222
37223 \size footnotesize
37224 NONE
37225 \end_layout
37226
37227 \end_inset
37228 </cell>
37229 </row>
37230 <row topline="true">
37231 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37232 \begin_inset Text
37233
37234 \begin_layout Standard
37235
37236 \size footnotesize
37237 IPOP
37238 \end_layout
37239
37240 \end_inset
37241 </cell>
37242 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37243 \begin_inset Text
37244
37245 \begin_layout Standard
37246
37247 \size footnotesize
37248 IC_LEFT()
37249 \end_layout
37250
37251 \end_inset
37252 </cell>
37253 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37254 \begin_inset Text
37255
37256 \begin_layout Standard
37257
37258 \size footnotesize
37259 Pop the operand from the stack
37260 \end_layout
37261
37262 \end_inset
37263 </cell>
37264 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37265 \begin_inset Text
37266
37267 \begin_layout Standard
37268
37269 \size footnotesize
37270 NONE
37271 \end_layout
37272
37273 \end_inset
37274 </cell>
37275 </row>
37276 <row topline="true">
37277 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37278 \begin_inset Text
37279
37280 \begin_layout Standard
37281
37282 \size footnotesize
37283 CALL
37284 \end_layout
37285
37286 \end_inset
37287 </cell>
37288 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37289 \begin_inset Text
37290
37291 \begin_layout Standard
37292
37293 \size footnotesize
37294 IC_LEFT() IC_RESULT()
37295 \end_layout
37296
37297 \end_inset
37298 </cell>
37299 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37300 \begin_inset Text
37301
37302 \begin_layout Standard
37303
37304 \size footnotesize
37305 Call the function represented by IC_LEFT
37306 \end_layout
37307
37308 \end_inset
37309 </cell>
37310 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37311 \begin_inset Text
37312
37313 \begin_layout Standard
37314
37315 \size footnotesize
37316 IC_RESULT = IC_LEFT();
37317 \end_layout
37318
37319 \end_inset
37320 </cell>
37321 </row>
37322 <row topline="true">
37323 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37324 \begin_inset Text
37325
37326 \begin_layout Standard
37327
37328 \size footnotesize
37329 PCALL
37330 \end_layout
37331
37332 \end_inset
37333 </cell>
37334 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37335 \begin_inset Text
37336
37337 \begin_layout Standard
37338
37339 \size footnotesize
37340 IC_LEFT() IC_RESULT()
37341 \end_layout
37342
37343 \end_inset
37344 </cell>
37345 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37346 \begin_inset Text
37347
37348 \begin_layout Standard
37349
37350 \size footnotesize
37351 Call via function pointer
37352 \end_layout
37353
37354 \end_inset
37355 </cell>
37356 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37357 \begin_inset Text
37358
37359 \begin_layout Standard
37360
37361 \size footnotesize
37362 IC_RESULT = (*IC_LEFT)();
37363 \end_layout
37364
37365 \end_inset
37366 </cell>
37367 </row>
37368 <row topline="true">
37369 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37370 \begin_inset Text
37371
37372 \begin_layout Standard
37373
37374 \size footnotesize
37375 RETURN
37376 \end_layout
37377
37378 \end_inset
37379 </cell>
37380 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37381 \begin_inset Text
37382
37383 \begin_layout Standard
37384
37385 \size footnotesize
37386 IC_LEFT()
37387 \end_layout
37388
37389 \end_inset
37390 </cell>
37391 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37392 \begin_inset Text
37393
37394 \begin_layout Standard
37395
37396 \size footnotesize
37397 Return the value in operand IC_LEFT
37398 \end_layout
37399
37400 \end_inset
37401 </cell>
37402 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37403 \begin_inset Text
37404
37405 \begin_layout Standard
37406
37407 \size footnotesize
37408 return IC_LEFT;
37409 \end_layout
37410
37411 \end_inset
37412 </cell>
37413 </row>
37414 <row topline="true">
37415 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37416 \begin_inset Text
37417
37418 \begin_layout Standard
37419
37420 \size footnotesize
37421 LABEL
37422 \end_layout
37423
37424 \end_inset
37425 </cell>
37426 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37427 \begin_inset Text
37428
37429 \begin_layout Standard
37430
37431 \size footnotesize
37432 IC_LABEL()
37433 \end_layout
37434
37435 \end_inset
37436 </cell>
37437 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37438 \begin_inset Text
37439
37440 \begin_layout Standard
37441
37442 \size footnotesize
37443 Label
37444 \end_layout
37445
37446 \end_inset
37447 </cell>
37448 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37449 \begin_inset Text
37450
37451 \begin_layout Standard
37452
37453 \size footnotesize
37454 IC_LABEL:
37455 \end_layout
37456
37457 \end_inset
37458 </cell>
37459 </row>
37460 <row topline="true">
37461 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37462 \begin_inset Text
37463
37464 \begin_layout Standard
37465
37466 \size footnotesize
37467 GOTO
37468 \end_layout
37469
37470 \end_inset
37471 </cell>
37472 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37473 \begin_inset Text
37474
37475 \begin_layout Standard
37476
37477 \size footnotesize
37478 IC_LABEL()
37479 \end_layout
37480
37481 \end_inset
37482 </cell>
37483 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37484 \begin_inset Text
37485
37486 \begin_layout Standard
37487
37488 \size footnotesize
37489 Goto label
37490 \end_layout
37491
37492 \end_inset
37493 </cell>
37494 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37495 \begin_inset Text
37496
37497 \begin_layout Standard
37498
37499 \size footnotesize
37500 goto IC_LABEL();
37501 \end_layout
37502
37503 \end_inset
37504 </cell>
37505 </row>
37506 <row topline="true">
37507 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37508 \begin_inset Text
37509
37510 \begin_layout Standard
37511
37512 \size footnotesize
37513 '+'
37514 \end_layout
37515
37516 \end_inset
37517 </cell>
37518 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37519 \begin_inset Text
37520
37521 \begin_layout Standard
37522
37523 \size footnotesize
37524 IC_LEFT() IC_RIGHT() IC_RESULT()
37525 \end_layout
37526
37527 \end_inset
37528 </cell>
37529 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37530 \begin_inset Text
37531
37532 \begin_layout Standard
37533
37534 \size footnotesize
37535 Addition
37536 \end_layout
37537
37538 \end_inset
37539 </cell>
37540 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37541 \begin_inset Text
37542
37543 \begin_layout Standard
37544
37545 \size footnotesize
37546 IC_RESULT = IC_LEFT + IC_RIGHT
37547 \end_layout
37548
37549 \end_inset
37550 </cell>
37551 </row>
37552 <row topline="true">
37553 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37554 \begin_inset Text
37555
37556 \begin_layout Standard
37557
37558 \size footnotesize
37559 '-'
37560 \end_layout
37561
37562 \end_inset
37563 </cell>
37564 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37565 \begin_inset Text
37566
37567 \begin_layout Standard
37568
37569 \size footnotesize
37570 IC_LEFT() IC_RIGHT() IC_RESULT()
37571 \end_layout
37572
37573 \end_inset
37574 </cell>
37575 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37576 \begin_inset Text
37577
37578 \begin_layout Standard
37579
37580 \size footnotesize
37581 Subtraction
37582 \end_layout
37583
37584 \end_inset
37585 </cell>
37586 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37587 \begin_inset Text
37588
37589 \begin_layout Standard
37590
37591 \size footnotesize
37592 IC_RESULT = IC_LEFT - IC_RIGHT
37593 \end_layout
37594
37595 \end_inset
37596 </cell>
37597 </row>
37598 <row topline="true">
37599 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37600 \begin_inset Text
37601
37602 \begin_layout Standard
37603
37604 \size footnotesize
37605 '*'
37606 \end_layout
37607
37608 \end_inset
37609 </cell>
37610 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37611 \begin_inset Text
37612
37613 \begin_layout Standard
37614
37615 \size footnotesize
37616 IC_LEFT() IC_RIGHT() IC_RESULT()
37617 \end_layout
37618
37619 \end_inset
37620 </cell>
37621 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37622 \begin_inset Text
37623
37624 \begin_layout Standard
37625
37626 \size footnotesize
37627 Multiplication
37628 \end_layout
37629
37630 \end_inset
37631 </cell>
37632 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37633 \begin_inset Text
37634
37635 \begin_layout Standard
37636
37637 \size footnotesize
37638 IC_RESULT = IC_LEFT * IC_RIGHT;
37639 \end_layout
37640
37641 \end_inset
37642 </cell>
37643 </row>
37644 <row topline="true">
37645 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37646 \begin_inset Text
37647
37648 \begin_layout Standard
37649
37650 \size footnotesize
37651 '/'
37652 \end_layout
37653
37654 \end_inset
37655 </cell>
37656 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37657 \begin_inset Text
37658
37659 \begin_layout Standard
37660
37661 \size footnotesize
37662 IC_LEFT() IC_RIGHT() IC_RESULT()
37663 \end_layout
37664
37665 \end_inset
37666 </cell>
37667 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37668 \begin_inset Text
37669
37670 \begin_layout Standard
37671
37672 \size footnotesize
37673 Division
37674 \end_layout
37675
37676 \end_inset
37677 </cell>
37678 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37679 \begin_inset Text
37680
37681 \begin_layout Standard
37682
37683 \size footnotesize
37684 IC_RESULT = IC_LEFT / IC_RIGHT;
37685 \end_layout
37686
37687 \end_inset
37688 </cell>
37689 </row>
37690 <row topline="true">
37691 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37692 \begin_inset Text
37693
37694 \begin_layout Standard
37695
37696 \size footnotesize
37697 '%'
37698 \end_layout
37699
37700 \end_inset
37701 </cell>
37702 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37703 \begin_inset Text
37704
37705 \begin_layout Standard
37706
37707 \size footnotesize
37708 IC_LEFT() IC_RIGHT() IC_RESULT()
37709 \end_layout
37710
37711 \end_inset
37712 </cell>
37713 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37714 \begin_inset Text
37715
37716 \begin_layout Standard
37717
37718 \size footnotesize
37719 Modulus
37720 \end_layout
37721
37722 \end_inset
37723 </cell>
37724 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37725 \begin_inset Text
37726
37727 \begin_layout Standard
37728
37729 \size footnotesize
37730 IC_RESULT = IC_LEFT % IC_RIGHT;
37731 \end_layout
37732
37733 \end_inset
37734 </cell>
37735 </row>
37736 <row topline="true">
37737 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37738 \begin_inset Text
37739
37740 \begin_layout Standard
37741
37742 \size footnotesize
37743 '<'
37744 \end_layout
37745
37746 \end_inset
37747 </cell>
37748 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37749 \begin_inset Text
37750
37751 \begin_layout Standard
37752
37753 \size footnotesize
37754 IC_LEFT() IC_RIGHT() IC_RESULT()
37755 \end_layout
37756
37757 \end_inset
37758 </cell>
37759 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37760 \begin_inset Text
37761
37762 \begin_layout Standard
37763
37764 \size footnotesize
37765 Less than
37766 \end_layout
37767
37768 \end_inset
37769 </cell>
37770 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37771 \begin_inset Text
37772
37773 \begin_layout Standard
37774
37775 \size footnotesize
37776 IC_RESULT = IC_LEFT < IC_RIGHT;
37777 \end_layout
37778
37779 \end_inset
37780 </cell>
37781 </row>
37782 <row topline="true">
37783 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37784 \begin_inset Text
37785
37786 \begin_layout Standard
37787
37788 \size footnotesize
37789 '>'
37790 \end_layout
37791
37792 \end_inset
37793 </cell>
37794 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37795 \begin_inset Text
37796
37797 \begin_layout Standard
37798
37799 \size footnotesize
37800 IC_LEFT() IC_RIGHT() IC_RESULT()
37801 \end_layout
37802
37803 \end_inset
37804 </cell>
37805 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37806 \begin_inset Text
37807
37808 \begin_layout Standard
37809
37810 \size footnotesize
37811 Greater than
37812 \end_layout
37813
37814 \end_inset
37815 </cell>
37816 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37817 \begin_inset Text
37818
37819 \begin_layout Standard
37820
37821 \size footnotesize
37822 IC_RESULT = IC_LEFT > IC_RIGHT;
37823 \end_layout
37824
37825 \end_inset
37826 </cell>
37827 </row>
37828 <row topline="true">
37829 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37830 \begin_inset Text
37831
37832 \begin_layout Standard
37833
37834 \size footnotesize
37835 EQ_OP
37836 \end_layout
37837
37838 \end_inset
37839 </cell>
37840 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37841 \begin_inset Text
37842
37843 \begin_layout Standard
37844
37845 \size footnotesize
37846 IC_LEFT() IC_RIGHT() IC_RESULT()
37847 \end_layout
37848
37849 \end_inset
37850 </cell>
37851 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37852 \begin_inset Text
37853
37854 \begin_layout Standard
37855
37856 \size footnotesize
37857 Equal to
37858 \end_layout
37859
37860 \end_inset
37861 </cell>
37862 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37863 \begin_inset Text
37864
37865 \begin_layout Standard
37866
37867 \size footnotesize
37868 IC_RESULT = IC_LEFT == IC_RIGHT;
37869 \end_layout
37870
37871 \end_inset
37872 </cell>
37873 </row>
37874 <row topline="true">
37875 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37876 \begin_inset Text
37877
37878 \begin_layout Standard
37879
37880 \size footnotesize
37881 AND_OP
37882 \end_layout
37883
37884 \end_inset
37885 </cell>
37886 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37887 \begin_inset Text
37888
37889 \begin_layout Standard
37890
37891 \size footnotesize
37892 IC_LEFT() IC_RIGHT() IC_RESULT()
37893 \end_layout
37894
37895 \end_inset
37896 </cell>
37897 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37898 \begin_inset Text
37899
37900 \begin_layout Standard
37901
37902 \size footnotesize
37903 Logical and operation
37904 \end_layout
37905
37906 \end_inset
37907 </cell>
37908 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37909 \begin_inset Text
37910
37911 \begin_layout Standard
37912
37913 \size footnotesize
37914 IC_RESULT = IC_LEFT && IC_RIGHT;
37915 \end_layout
37916
37917 \end_inset
37918 </cell>
37919 </row>
37920 <row topline="true">
37921 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37922 \begin_inset Text
37923
37924 \begin_layout Standard
37925
37926 \size footnotesize
37927 OR_OP
37928 \end_layout
37929
37930 \end_inset
37931 </cell>
37932 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37933 \begin_inset Text
37934
37935 \begin_layout Standard
37936
37937 \size footnotesize
37938 IC_LEFT() IC_RIGHT() IC_RESULT()
37939 \end_layout
37940
37941 \end_inset
37942 </cell>
37943 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37944 \begin_inset Text
37945
37946 \begin_layout Standard
37947
37948 \size footnotesize
37949 Logical or operation
37950 \end_layout
37951
37952 \end_inset
37953 </cell>
37954 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37955 \begin_inset Text
37956
37957 \begin_layout Standard
37958
37959 \size footnotesize
37960 IC_RESULT = IC_LEFT || IC_RIGHT;
37961 \end_layout
37962
37963 \end_inset
37964 </cell>
37965 </row>
37966 <row topline="true">
37967 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37968 \begin_inset Text
37969
37970 \begin_layout Standard
37971
37972 \size footnotesize
37973 '^'
37974 \end_layout
37975
37976 \end_inset
37977 </cell>
37978 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37979 \begin_inset Text
37980
37981 \begin_layout Standard
37982
37983 \size footnotesize
37984 IC_LEFT() IC_RIGHT() IC_RESULT()
37985 \end_layout
37986
37987 \end_inset
37988 </cell>
37989 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37990 \begin_inset Text
37991
37992 \begin_layout Standard
37993
37994 \size footnotesize
37995 Exclusive OR
37996 \end_layout
37997
37998 \end_inset
37999 </cell>
38000 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38001 \begin_inset Text
38002
38003 \begin_layout Standard
38004
38005 \size footnotesize
38006 IC_RESULT = IC_LEFT ^ IC_RIGHT;
38007 \end_layout
38008
38009 \end_inset
38010 </cell>
38011 </row>
38012 <row topline="true">
38013 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38014 \begin_inset Text
38015
38016 \begin_layout Standard
38017
38018 \size footnotesize
38019 '|'
38020 \end_layout
38021
38022 \end_inset
38023 </cell>
38024 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38025 \begin_inset Text
38026
38027 \begin_layout Standard
38028
38029 \size footnotesize
38030 IC_LEFT() IC_RIGHT() IC_RESULT()
38031 \end_layout
38032
38033 \end_inset
38034 </cell>
38035 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38036 \begin_inset Text
38037
38038 \begin_layout Standard
38039
38040 \size footnotesize
38041 Bitwise OR
38042 \end_layout
38043
38044 \end_inset
38045 </cell>
38046 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38047 \begin_inset Text
38048
38049 \begin_layout Standard
38050
38051 \size footnotesize
38052 IC_RESULT = IC_LEFT | IC_RIGHT;
38053 \end_layout
38054
38055 \end_inset
38056 </cell>
38057 </row>
38058 <row topline="true">
38059 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38060 \begin_inset Text
38061
38062 \begin_layout Standard
38063
38064 \size footnotesize
38065 BITWISEAND
38066 \end_layout
38067
38068 \end_inset
38069 </cell>
38070 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38071 \begin_inset Text
38072
38073 \begin_layout Standard
38074
38075 \size footnotesize
38076 IC_LEFT() IC_RIGHT() IC_RESULT()
38077 \end_layout
38078
38079 \end_inset
38080 </cell>
38081 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38082 \begin_inset Text
38083
38084 \begin_layout Standard
38085
38086 \size footnotesize
38087 Bitwise AND
38088 \end_layout
38089
38090 \end_inset
38091 </cell>
38092 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38093 \begin_inset Text
38094
38095 \begin_layout Standard
38096
38097 \size footnotesize
38098 IC_RESULT = IC_LEFT & IC_RIGHT;
38099 \end_layout
38100
38101 \end_inset
38102 </cell>
38103 </row>
38104 <row topline="true">
38105 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38106 \begin_inset Text
38107
38108 \begin_layout Standard
38109
38110 \size footnotesize
38111 LEFT_OP
38112 \end_layout
38113
38114 \end_inset
38115 </cell>
38116 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38117 \begin_inset Text
38118
38119 \begin_layout Standard
38120
38121 \size footnotesize
38122 IC_LEFT() IC_RIGHT() IC_RESULT()
38123 \end_layout
38124
38125 \end_inset
38126 </cell>
38127 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38128 \begin_inset Text
38129
38130 \begin_layout Standard
38131
38132 \size footnotesize
38133 Left shift
38134 \end_layout
38135
38136 \end_inset
38137 </cell>
38138 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38139 \begin_inset Text
38140
38141 \begin_layout Standard
38142
38143 \size footnotesize
38144 IC_RESULT = IC_LEFT << IC_RIGHT
38145 \end_layout
38146
38147 \end_inset
38148 </cell>
38149 </row>
38150 <row topline="true">
38151 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38152 \begin_inset Text
38153
38154 \begin_layout Standard
38155
38156 \size footnotesize
38157 RIGHT_OP
38158 \end_layout
38159
38160 \end_inset
38161 </cell>
38162 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38163 \begin_inset Text
38164
38165 \begin_layout Standard
38166
38167 \size footnotesize
38168 IC_LEFT() IC_RIGHT() IC_RESULT()
38169 \end_layout
38170
38171 \end_inset
38172 </cell>
38173 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38174 \begin_inset Text
38175
38176 \begin_layout Standard
38177
38178 \size footnotesize
38179 Right shift
38180 \end_layout
38181
38182 \end_inset
38183 </cell>
38184 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38185 \begin_inset Text
38186
38187 \begin_layout Standard
38188
38189 \size footnotesize
38190 IC_RESULT = IC_LEFT >> IC_RIGHT
38191 \end_layout
38192
38193 \end_inset
38194 </cell>
38195 </row>
38196 <row topline="true">
38197 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38198 \begin_inset Text
38199
38200 \begin_layout Standard
38201
38202 \size footnotesize
38203 GET_VALUE_
38204 \newline
38205 AT_ ADDRESS
38206 \end_layout
38207
38208 \end_inset
38209 </cell>
38210 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38211 \begin_inset Text
38212
38213 \begin_layout Standard
38214
38215 \size footnotesize
38216 IC_LEFT() IC_RESULT()
38217 \end_layout
38218
38219 \end_inset
38220 </cell>
38221 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38222 \begin_inset Text
38223
38224 \begin_layout Standard
38225
38226 \size footnotesize
38227 Indirect fetch
38228 \end_layout
38229
38230 \end_inset
38231 </cell>
38232 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38233 \begin_inset Text
38234
38235 \begin_layout Standard
38236
38237 \size footnotesize
38238 IC_RESULT = (*IC_LEFT);
38239 \end_layout
38240
38241 \end_inset
38242 </cell>
38243 </row>
38244 <row topline="true">
38245 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38246 \begin_inset Text
38247
38248 \begin_layout Standard
38249
38250 \size footnotesize
38251 POINTER_SET
38252 \end_layout
38253
38254 \end_inset
38255 </cell>
38256 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38257 \begin_inset Text
38258
38259 \begin_layout Standard
38260
38261 \size footnotesize
38262 IC_RIGHT() IC_RESULT()
38263 \end_layout
38264
38265 \end_inset
38266 </cell>
38267 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38268 \begin_inset Text
38269
38270 \begin_layout Standard
38271
38272 \size footnotesize
38273 Indirect set
38274 \end_layout
38275
38276 \end_inset
38277 </cell>
38278 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38279 \begin_inset Text
38280
38281 \begin_layout Standard
38282
38283 \size footnotesize
38284 (*IC_RESULT) = IC_RIGHT;
38285 \end_layout
38286
38287 \end_inset
38288 </cell>
38289 </row>
38290 <row topline="true">
38291 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38292 \begin_inset Text
38293
38294 \begin_layout Standard
38295
38296 \size footnotesize
38297 '='
38298 \end_layout
38299
38300 \end_inset
38301 </cell>
38302 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38303 \begin_inset Text
38304
38305 \begin_layout Standard
38306
38307 \size footnotesize
38308 IC_RIGHT() IC_RESULT()
38309 \end_layout
38310
38311 \end_inset
38312 </cell>
38313 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38314 \begin_inset Text
38315
38316 \begin_layout Standard
38317
38318 \size footnotesize
38319 Assignment
38320 \end_layout
38321
38322 \end_inset
38323 </cell>
38324 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38325 \begin_inset Text
38326
38327 \begin_layout Standard
38328
38329 \size footnotesize
38330 IC_RESULT = IC_RIGHT;
38331 \end_layout
38332
38333 \end_inset
38334 </cell>
38335 </row>
38336 <row topline="true">
38337 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38338 \begin_inset Text
38339
38340 \begin_layout Standard
38341
38342 \size footnotesize
38343 IFX
38344 \end_layout
38345
38346 \end_inset
38347 </cell>
38348 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38349 \begin_inset Text
38350
38351 \begin_layout Standard
38352
38353 \size footnotesize
38354 IC_COND IC_TRUE IC_LABEL
38355 \end_layout
38356
38357 \end_inset
38358 </cell>
38359 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38360 \begin_inset Text
38361
38362 \begin_layout Standard
38363
38364 \size footnotesize
38365 Conditional jump.
38366  If true label is present then jump to true label if condition is true else
38367  jump to false label if condition is false
38368 \end_layout
38369
38370 \end_inset
38371 </cell>
38372 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38373 \begin_inset Text
38374
38375 \begin_layout Standard
38376
38377 \size footnotesize
38378 if (IC_COND) goto IC_TRUE;
38379 \newline
38380 \InsetSpace ~
38381 \InsetSpace ~
38382 Or
38383 \newline
38384 If (!IC_COND) goto IC_FALSE;
38385 \end_layout
38386
38387 \end_inset
38388 </cell>
38389 </row>
38390 <row topline="true">
38391 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38392 \begin_inset Text
38393
38394 \begin_layout Standard
38395
38396 \size footnotesize
38397 ADDRESS_OF
38398 \end_layout
38399
38400 \end_inset
38401 </cell>
38402 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38403 \begin_inset Text
38404
38405 \begin_layout Standard
38406
38407 \size footnotesize
38408 IC_LEFT() IC_RESULT()
38409 \end_layout
38410
38411 \end_inset
38412 </cell>
38413 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38414 \begin_inset Text
38415
38416 \begin_layout Standard
38417
38418 \size footnotesize
38419 Address of
38420 \end_layout
38421
38422 \end_inset
38423 </cell>
38424 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38425 \begin_inset Text
38426
38427 \begin_layout Standard
38428
38429 \size footnotesize
38430 IC_RESULT = &IC_LEFT();
38431 \end_layout
38432
38433 \end_inset
38434 </cell>
38435 </row>
38436 <row topline="true">
38437 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38438 \begin_inset Text
38439
38440 \begin_layout Standard
38441
38442 \size footnotesize
38443 JUMPTABLE
38444 \end_layout
38445
38446 \end_inset
38447 </cell>
38448 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38449 \begin_inset Text
38450
38451 \begin_layout Standard
38452
38453 \size footnotesize
38454 IC_JTCOND IC_JTLABELS
38455 \end_layout
38456
38457 \end_inset
38458 </cell>
38459 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38460 \begin_inset Text
38461
38462 \begin_layout Standard
38463
38464 \size footnotesize
38465 Jump to list of labels depending on the value of JTCOND
38466 \end_layout
38467
38468 \end_inset
38469 </cell>
38470 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38471 \begin_inset Text
38472
38473 \begin_layout Standard
38474
38475 \size footnotesize
38476 Switch statement
38477 \end_layout
38478
38479 \end_inset
38480 </cell>
38481 </row>
38482 <row topline="true">
38483 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38484 \begin_inset Text
38485
38486 \begin_layout Standard
38487
38488 \size footnotesize
38489 CAST
38490 \end_layout
38491
38492 \end_inset
38493 </cell>
38494 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38495 \begin_inset Text
38496
38497 \begin_layout Standard
38498
38499 \size footnotesize
38500 IC_RIGHT() IC_LEFT() IC_RESULT()
38501 \end_layout
38502
38503 \end_inset
38504 </cell>
38505 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38506 \begin_inset Text
38507
38508 \begin_layout Standard
38509
38510 \size footnotesize
38511 Cast types
38512 \end_layout
38513
38514 \end_inset
38515 </cell>
38516 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38517 \begin_inset Text
38518
38519 \begin_layout Standard
38520
38521 \size footnotesize
38522 IC_RESULT = (typeof IC_LEFT) IC_RIGHT;
38523 \end_layout
38524
38525 \end_inset
38526 </cell>
38527 </row>
38528 <row topline="true">
38529 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38530 \begin_inset Text
38531
38532 \begin_layout Standard
38533
38534 \size footnotesize
38535 SEND
38536 \end_layout
38537
38538 \end_inset
38539 </cell>
38540 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38541 \begin_inset Text
38542
38543 \begin_layout Standard
38544
38545 \size footnotesize
38546 IC_LEFT()
38547 \end_layout
38548
38549 \end_inset
38550 </cell>
38551 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38552 \begin_inset Text
38553
38554 \begin_layout Standard
38555
38556 \size footnotesize
38557 This is used for passing parameters in registers;
38558 \newline
38559 move IC_LEFT to the next
38560  available parameter register.
38561 \end_layout
38562
38563 \end_inset
38564 </cell>
38565 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38566 \begin_inset Text
38567
38568 \begin_layout Standard
38569
38570 \size footnotesize
38571 None
38572 \end_layout
38573
38574 \end_inset
38575 </cell>
38576 </row>
38577 <row topline="true">
38578 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38579 \begin_inset Text
38580
38581 \begin_layout Standard
38582
38583 \size footnotesize
38584 RECV
38585 \end_layout
38586
38587 \end_inset
38588 </cell>
38589 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38590 \begin_inset Text
38591
38592 \begin_layout Standard
38593
38594 \size footnotesize
38595 IC_RESULT()
38596 \end_layout
38597
38598 \end_inset
38599 </cell>
38600 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38601 \begin_inset Text
38602
38603 \begin_layout Standard
38604
38605 \size footnotesize
38606 This is used for receiving parameters passed in registers;
38607 \newline
38608 Move the values
38609  in the next parameter register to IC_RESULT
38610 \end_layout
38611
38612 \end_inset
38613 </cell>
38614 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38615 \begin_inset Text
38616
38617 \begin_layout Standard
38618
38619 \size footnotesize
38620 None
38621 \end_layout
38622
38623 \end_inset
38624 </cell>
38625 </row>
38626 <row topline="true" bottomline="true">
38627 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38628 \begin_inset Text
38629
38630 \begin_layout Standard
38631
38632 \shape slanted
38633 \size footnotesize
38634 (some more have been added)
38635 \end_layout
38636
38637 \end_inset
38638 </cell>
38639 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38640 \begin_inset Text
38641
38642 \begin_layout Standard
38643
38644 \end_layout
38645
38646 \end_inset
38647 </cell>
38648 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38649 \begin_inset Text
38650
38651 \begin_layout Standard
38652
38653 \end_layout
38654
38655 \end_inset
38656 </cell>
38657 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38658 \begin_inset Text
38659
38660 \begin_layout Standard
38661
38662 \shape slanted
38663 \size footnotesize
38664 see f.e.
38665 \family typewriter
38666 gen51Code()
38667 \family default
38668  in
38669 \family typewriter
38670 src/mcs51/gen.c
38671 \end_layout
38672
38673 \end_inset
38674 </cell>
38675 </row>
38676 </lyxtabular>
38677
38678 \end_inset
38679
38680
38681 \end_layout
38682
38683 \begin_layout Standard
38684 \begin_inset Note Note
38685 status collapsed
38686
38687 \begin_layout Standard
38688 In the original article Figure II was announced to be downloadable on
38689 \shape italic
38690 Circuit Cellar
38691 \shape default
38692 's web site.
38693  ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2000/121/dutta.ZIP
38694 \end_layout
38695
38696 \end_inset
38697
38698
38699 \end_layout
38700
38701 \begin_layout Paragraph*
38702 ICode Example
38703 \begin_inset LatexCommand \index{iCode}
38704
38705 \end_inset
38706
38707
38708 \end_layout
38709
38710 \begin_layout Standard
38711 This section shows some details of iCode.
38712  The example C code does not do anything useful; it is used as an example
38713  to illustrate the intermediate code generated by the compiler.
38714 \end_layout
38715
38716 \begin_layout Verse
38717
38718 \family typewriter
38719 1.\InsetSpace ~
38720 xdata int * p;
38721 \newline
38722 2.\InsetSpace ~
38723 int gint;
38724 \newline
38725 3.\InsetSpace ~
38726 /* This function does nothing useful.
38727  It is used
38728 \newline
38729 4.\InsetSpace ~
38730 \InsetSpace ~
38731 \InsetSpace ~
38732 \InsetSpace ~
38733 for the purpose of explaining iCode */
38734 \newline
38735 5.\InsetSpace ~
38736 short function (data
38737  int *x)
38738 \newline
38739 6.\InsetSpace ~
38740 {
38741 \newline
38742 7.\InsetSpace ~
38743 \InsetSpace ~
38744 \InsetSpace ~
38745 short i=10; \InsetSpace ~
38746 \InsetSpace ~
38747 /* dead initialization eliminated */
38748 \newline
38749 8.\InsetSpace ~
38750 \InsetSpace ~
38751 \InsetSpace ~
38752 short sum=10;
38753  /* dead initialization eliminated */
38754 \newline
38755 9.\InsetSpace ~
38756 \InsetSpace ~
38757 \InsetSpace ~
38758 short mul;
38759 \newline
38760 10.\InsetSpace ~
38761 \InsetSpace ~
38762 int j ;
38763 \newline
38764 11.\InsetSpace ~
38765 \InsetSpace ~
38766 while (*x) *x++
38767  = *p++;
38768 \newline
38769 12.\InsetSpace ~
38770 \InsetSpace ~
38771 \InsetSpace ~
38772 \InsetSpace ~
38773 sum = 0 ;
38774 \newline
38775 13.\InsetSpace ~
38776 \InsetSpace ~
38777 mul = 0;
38778 \newline
38779 14.\InsetSpace ~
38780 \InsetSpace ~
38781 /* compiler detects i,j to be induction variables
38782  */
38783 \newline
38784 15.\InsetSpace ~
38785 \InsetSpace ~
38786 for (i = 0, j = 10 ; i < 10 ; i++, j
38787 \family default
38788 -
38789 \begin_inset ERT
38790 status collapsed
38791
38792 \begin_layout Standard
38793
38794
38795 \backslash
38796 /
38797 \end_layout
38798
38799 \end_inset
38800
38801 -
38802 \family typewriter
38803 ) {
38804 \newline
38805 16.\InsetSpace ~
38806 \InsetSpace ~
38807 \InsetSpace ~
38808 \InsetSpace ~
38809 sum += i;
38810 \newline
38811 17.\InsetSpace ~
38812 \InsetSpace ~
38813 \InsetSpace ~
38814 \InsetSpace ~
38815 mul += i * 3; \InsetSpace ~
38816 \InsetSpace ~
38817 /* this multiplication remains */
38818 \newline
38819 18.\InsetSpace ~
38820 \InsetSpace ~
38821 \InsetSpace ~
38822 \InsetSpace ~
38823 gint +=
38824  j * 3;\InsetSpace ~
38825 \InsetSpace ~
38826 /* this multiplication changed to addition */
38827 \newline
38828 19.\InsetSpace ~
38829 \InsetSpace ~
38830 }
38831 \newline
38832 20.\InsetSpace ~
38833 \InsetSpace ~
38834 return sum+mul;
38835 \newline
38836 21.\InsetSpace ~
38837 }
38838 \end_layout
38839
38840 \begin_layout Standard
38841 In addition to the operands each iCode contains information about the filename
38842  and line it corresponds to in the source file.
38843  The first field in the listing should be interpreted as follows:
38844 \newline
38845
38846 \shape italic
38847 \size footnotesize
38848 Filename(linenumber: iCode Execution sequence number : ICode hash table
38849  key : loop depth of the iCode).
38850 \shape default
38851 \size default
38852
38853 \newline
38854 Then follows the human readable form of the ICode operation.
38855  Each operand of this triplet form can be of three basic types a) compiler
38856  generated temporary b) user defined variable c) a constant value.
38857  Note that local variables and parameters are replaced by compiler generated
38858  temporaries.
38859  Live ranges
38860 \begin_inset LatexCommand \index{Live range analysis}
38861
38862 \end_inset
38863
38864  are computed only for temporaries (i.e.
38865  live ranges are not computed for global variables).
38866  Registers
38867 \begin_inset LatexCommand \index{Register allocation}
38868
38869 \end_inset
38870
38871  are allocated for temporaries only.
38872  Operands are formatted in the following manner:
38873 \newline
38874
38875 \shape italic
38876 \size footnotesize
38877 Operand Name [lr live-from : live-to ] { type information } [ registers
38878  allocated ].
38879 \shape default
38880 \size default
38881
38882 \newline
38883 As mentioned earlier the live ranges are computed in terms of the execution
38884  sequence number of the iCodes, for example
38885 \newline
38886 the iTemp0 is live from (i.e.
38887  first defined in iCode with execution sequence number 3, and is last used
38888  in the iCode with sequence number 5).
38889  For induction variables such as iTemp21 the live range computation extends
38890  the lifetime from the start to the end of the loop.
38891 \newline
38892 The register allocator
38893  used the live range information to allocate registers, the same registers
38894  may be used for different temporaries if their live ranges do not overlap,
38895  for example r0 is allocated to both iTemp6 and to iTemp17 since their live
38896  ranges do not overlap.
38897  In addition the allocator also takes into consideration the type and usage
38898  of a temporary, for example itemp6 is a pointer to near space and is used
38899  as to fetch data from (i.e.
38900  used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer register (r0).
38901  Some short lived temporaries are allocated to special registers which have
38902  meaning to the code generator e.g.
38903  iTemp13 is allocated to a pseudo register CC which tells the back end that
38904  the temporary is used only for a conditional jump the code generation makes
38905  use of this information to optimize a compare and jump ICode.
38906 \newline
38907 There are several
38908  loop optimizations
38909 \begin_inset LatexCommand \index{Loop optimization}
38910
38911 \end_inset
38912
38913  performed by the compiler.
38914  It can detect induction variables iTemp21(i) and iTemp23(j).
38915  Also note the compiler does selective strength reduction
38916 \begin_inset LatexCommand \index{Strength reduction}
38917
38918 \end_inset
38919
38920 , i.e.
38921  the multiplication of an induction variable in line 18 (gint = j * 3) is
38922  changed to addition, a new temporary iTemp17 is allocated and assigned
38923  a initial value, a constant 3 is then added for each iteration of the loop.
38924  The compiler does not change the multiplication
38925 \begin_inset LatexCommand \index{Multiplication}
38926
38927 \end_inset
38928
38929  in line 17 however since the processor does support an 8 * 8 bit multiplication.
38930 \newline
38931
38932 Note the dead code elimination
38933 \begin_inset LatexCommand \index{Dead-code elimination}
38934
38935 \end_inset
38936
38937  optimization eliminated the dead assignments in line 7 & 8 to I and sum
38938  respectively.
38939 \newline
38940
38941 \end_layout
38942
38943 \begin_layout Standard
38944
38945 \size footnotesize
38946 Sample.c (5:1:0:0) _entry($9) :
38947 \end_layout
38948
38949 \begin_layout Standard
38950
38951 \size footnotesize
38952 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
38953 \end_layout
38954
38955 \begin_layout Standard
38956
38957 \size footnotesize
38958 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv
38959 \end_layout
38960
38961 \begin_layout Standard
38962
38963 \size footnotesize
38964 Sample.c(11:4:53:0) preHeaderLbl0($11) :
38965 \end_layout
38966
38967 \begin_layout Standard
38968
38969 \size footnotesize
38970 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
38971  * int}[r2]
38972 \end_layout
38973
38974 \begin_layout Standard
38975
38976 \size footnotesize
38977 Sample.c(11:6:5:1) _whilecontinue_0($1) :
38978 \end_layout
38979
38980 \begin_layout Standard
38981
38982 \size footnotesize
38983 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
38984  int}[r0]]
38985 \end_layout
38986
38987 \begin_layout Standard
38988
38989 \size footnotesize
38990 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
38991 \end_layout
38992
38993 \begin_layout Standard
38994
38995 \size footnotesize
38996 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
38997  * int}
38998 \end_layout
38999
39000 \begin_layout Standard
39001
39002 \size footnotesize
39003 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
39004  {short}
39005 \end_layout
39006
39007 \begin_layout Standard
39008
39009 \size footnotesize
39010 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
39011  * int}[DPTR]]
39012 \end_layout
39013
39014 \begin_layout Standard
39015
39016 \size footnotesize
39017 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
39018 }[r2 r3]
39019 \end_layout
39020
39021 \begin_layout Standard
39022
39023 \size footnotesize
39024 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
39025  * int}[r0] + 0x2 {short}
39026 \end_layout
39027
39028 \begin_layout Standard
39029
39030 \size footnotesize
39031 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
39032 \end_layout
39033
39034 \begin_layout Standard
39035
39036 \size footnotesize
39037 Sample.c(11:17:21:0)_whilebreak_0($3) :
39038 \end_layout
39039
39040 \begin_layout Standard
39041
39042 \size footnotesize
39043 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
39044 \end_layout
39045
39046 \begin_layout Standard
39047
39048 \size footnotesize
39049 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
39050 \end_layout
39051
39052 \begin_layout Standard
39053
39054 \size footnotesize
39055 Sample.c(15:20:54:0)preHeaderLbl1($13) :
39056 \end_layout
39057
39058 \begin_layout Standard
39059
39060 \size footnotesize
39061 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
39062 \end_layout
39063
39064 \begin_layout Standard
39065
39066 \size footnotesize
39067 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
39068 \end_layout
39069
39070 \begin_layout Standard
39071
39072 \size footnotesize
39073 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
39074 \end_layout
39075
39076 \begin_layout Standard
39077
39078 \size footnotesize
39079 Sample.c(15:24:26:1)_forcond_0($4) :
39080 \end_layout
39081
39082 \begin_layout Standard
39083
39084 \size footnotesize
39085 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
39086  < 0xa {short}
39087 \end_layout
39088
39089 \begin_layout Standard
39090
39091 \size footnotesize
39092 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
39093 \end_layout
39094
39095 \begin_layout Standard
39096
39097 \size footnotesize
39098 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
39099  + ITemp21 [lr21:38]{short}[r4]
39100 \end_layout
39101
39102 \begin_layout Standard
39103
39104 \size footnotesize
39105 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
39106  * 0x3 {short}
39107 \end_layout
39108
39109 \begin_layout Standard
39110
39111 \size footnotesize
39112 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
39113  + iTemp15 [lr29:30]{short}[r1]
39114 \end_layout
39115
39116 \begin_layout Standard
39117
39118 \size footnotesize
39119 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
39120  r0]- 0x3 {short}
39121 \end_layout
39122
39123 \begin_layout Standard
39124
39125 \size footnotesize
39126 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
39127 int}[r7 r0]
39128 \end_layout
39129
39130 \begin_layout Standard
39131
39132 \size footnotesize
39133 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
39134  + 0x1 {short}
39135 \end_layout
39136
39137 \begin_layout Standard
39138
39139 \size footnotesize
39140 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
39141  r6]- 0x1 {short}
39142 \end_layout
39143
39144 \begin_layout Standard
39145
39146 \size footnotesize
39147 Sample.c(19:38:47:1) goto _forcond_0($4)
39148 \end_layout
39149
39150 \begin_layout Standard
39151
39152 \size footnotesize
39153 Sample.c(19:39:48:0)_forbreak_0($7) :
39154 \end_layout
39155
39156 \begin_layout Standard
39157
39158 \size footnotesize
39159 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
39160  + ITemp11 [lr19:40]{short}[r3]
39161 \end_layout
39162
39163 \begin_layout Standard
39164
39165 \size footnotesize
39166 Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
39167 \end_layout
39168
39169 \begin_layout Standard
39170
39171 \size footnotesize
39172 Sample.c(20:42:51:0)_return($8) :
39173 \end_layout
39174
39175 \begin_layout Standard
39176
39177 \size footnotesize
39178 Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
39179 \size default
39180
39181 \newline
39182
39183 \newline
39184 Finally the code generated for this function:
39185 \newline
39186
39187 \end_layout
39188
39189 \begin_layout Standard
39190
39191 \size footnotesize
39192 .area DSEG (DATA)
39193 \end_layout
39194
39195 \begin_layout Standard
39196
39197 \size footnotesize
39198 _p::
39199 \end_layout
39200
39201 \begin_layout Standard
39202
39203 \size footnotesize
39204 \InsetSpace ~
39205 \InsetSpace ~
39206 .ds 2
39207 \end_layout
39208
39209 \begin_layout Standard
39210
39211 \size footnotesize
39212 _gint::
39213 \end_layout
39214
39215 \begin_layout Standard
39216
39217 \size footnotesize
39218 \InsetSpace ~
39219 \InsetSpace ~
39220 .ds 2
39221 \end_layout
39222
39223 \begin_layout Standard
39224
39225 \size footnotesize
39226 ; sample.c 5
39227 \end_layout
39228
39229 \begin_layout Standard
39230
39231 \size footnotesize
39232 ; ----------------------------------------------
39233 \end_layout
39234
39235 \begin_layout Standard
39236
39237 \size footnotesize
39238 ; function function
39239 \end_layout
39240
39241 \begin_layout Standard
39242
39243 \size footnotesize
39244 ; ----------------------------------------------
39245 \end_layout
39246
39247 \begin_layout Standard
39248
39249 \size footnotesize
39250 _function:
39251 \end_layout
39252
39253 \begin_layout Standard
39254
39255 \size footnotesize
39256 ; iTemp0 [lr3:5]{_near * int}[r2] = recv
39257 \end_layout
39258
39259 \begin_layout Standard
39260
39261 \size footnotesize
39262 \InsetSpace ~
39263 \InsetSpace ~
39264 mov r2,dpl
39265 \end_layout
39266
39267 \begin_layout Standard
39268
39269 \size footnotesize
39270 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
39271 \end_layout
39272
39273 \begin_layout Standard
39274
39275 \size footnotesize
39276 \InsetSpace ~
39277 \InsetSpace ~
39278 mov ar0,r2
39279 \end_layout
39280
39281 \begin_layout Standard
39282
39283 \size footnotesize
39284 ;_whilecontinue_0($1) :
39285 \end_layout
39286
39287 \begin_layout Standard
39288
39289 \size footnotesize
39290 00101$:
39291 \end_layout
39292
39293 \begin_layout Standard
39294
39295 \size footnotesize
39296 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
39297 \end_layout
39298
39299 \begin_layout Standard
39300
39301 \size footnotesize
39302 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
39303 \end_layout
39304
39305 \begin_layout Standard
39306
39307 \size footnotesize
39308 \InsetSpace ~
39309 \InsetSpace ~
39310 mov ar2,@r0
39311 \end_layout
39312
39313 \begin_layout Standard
39314
39315 \size footnotesize
39316 \InsetSpace ~
39317 \InsetSpace ~
39318 inc r0
39319 \end_layout
39320
39321 \begin_layout Standard
39322
39323 \size footnotesize
39324 \InsetSpace ~
39325 \InsetSpace ~
39326 mov ar3,@r0
39327 \end_layout
39328
39329 \begin_layout Standard
39330
39331 \size footnotesize
39332 \InsetSpace ~
39333 \InsetSpace ~
39334 dec r0
39335 \end_layout
39336
39337 \begin_layout Standard
39338
39339 \size footnotesize
39340 \InsetSpace ~
39341 \InsetSpace ~
39342 mov a,r2
39343 \end_layout
39344
39345 \begin_layout Standard
39346
39347 \size footnotesize
39348 \InsetSpace ~
39349 \InsetSpace ~
39350 orl a,r3
39351 \end_layout
39352
39353 \begin_layout Standard
39354
39355 \size footnotesize
39356 \InsetSpace ~
39357 \InsetSpace ~
39358 jz 00103$
39359 \end_layout
39360
39361 \begin_layout Standard
39362
39363 \size footnotesize
39364 00114$:
39365 \end_layout
39366
39367 \begin_layout Standard
39368
39369 \size footnotesize
39370 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
39371 \end_layout
39372
39373 \begin_layout Standard
39374
39375 \size footnotesize
39376 \InsetSpace ~
39377 \InsetSpace ~
39378 mov dpl,_p
39379 \end_layout
39380
39381 \begin_layout Standard
39382
39383 \size footnotesize
39384 \InsetSpace ~
39385 \InsetSpace ~
39386 mov dph,(_p + 1)
39387 \end_layout
39388
39389 \begin_layout Standard
39390
39391 \size footnotesize
39392 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
39393 \end_layout
39394
39395 \begin_layout Standard
39396
39397 \size footnotesize
39398 \InsetSpace ~
39399 \InsetSpace ~
39400 mov a,#0x02
39401 \end_layout
39402
39403 \begin_layout Standard
39404
39405 \size footnotesize
39406 \InsetSpace ~
39407 \InsetSpace ~
39408 add a,_p
39409 \end_layout
39410
39411 \begin_layout Standard
39412
39413 \size footnotesize
39414 \InsetSpace ~
39415 \InsetSpace ~
39416 mov _p,a
39417 \end_layout
39418
39419 \begin_layout Standard
39420
39421 \size footnotesize
39422 \InsetSpace ~
39423 \InsetSpace ~
39424 clr a
39425 \end_layout
39426
39427 \begin_layout Standard
39428
39429 \size footnotesize
39430 \InsetSpace ~
39431 \InsetSpace ~
39432 addc a,(_p + 1)
39433 \end_layout
39434
39435 \begin_layout Standard
39436
39437 \size footnotesize
39438 \InsetSpace ~
39439 \InsetSpace ~
39440 mov (_p + 1),a
39441 \end_layout
39442
39443 \begin_layout Standard
39444
39445 \size footnotesize
39446 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
39447 \end_layout
39448
39449 \begin_layout Standard
39450
39451 \size footnotesize
39452 \InsetSpace ~
39453 \InsetSpace ~
39454 movx a,@dptr
39455 \end_layout
39456
39457 \begin_layout Standard
39458
39459 \size footnotesize
39460 \InsetSpace ~
39461 \InsetSpace ~
39462 mov r2,a
39463 \end_layout
39464
39465 \begin_layout Standard
39466
39467 \size footnotesize
39468 \InsetSpace ~
39469 \InsetSpace ~
39470 inc dptr
39471 \end_layout
39472
39473 \begin_layout Standard
39474
39475 \size footnotesize
39476 \InsetSpace ~
39477 \InsetSpace ~
39478 movx a,@dptr
39479 \end_layout
39480
39481 \begin_layout Standard
39482
39483 \size footnotesize
39484 \InsetSpace ~
39485 \InsetSpace ~
39486 mov r3,a
39487 \end_layout
39488
39489 \begin_layout Standard
39490
39491 \size footnotesize
39492 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
39493 \end_layout
39494
39495 \begin_layout Standard
39496
39497 \size footnotesize
39498 \InsetSpace ~
39499 \InsetSpace ~
39500 mov @r0,ar2
39501 \end_layout
39502
39503 \begin_layout Standard
39504
39505 \size footnotesize
39506 \InsetSpace ~
39507 \InsetSpace ~
39508 inc r0
39509 \end_layout
39510
39511 \begin_layout Standard
39512
39513 \size footnotesize
39514 \InsetSpace ~
39515 \InsetSpace ~
39516 mov @r0,ar3
39517 \end_layout
39518
39519 \begin_layout Standard
39520
39521 \size footnotesize
39522 ; iTemp6 [lr5:16]{_near * int}[r0] =
39523 \end_layout
39524
39525 \begin_layout Standard
39526
39527 \size footnotesize
39528 ; iTemp6 [lr5:16]{_near * int}[r0] +
39529 \end_layout
39530
39531 \begin_layout Standard
39532
39533 \size footnotesize
39534 ; 0x2 {short}
39535 \end_layout
39536
39537 \begin_layout Standard
39538
39539 \size footnotesize
39540 \InsetSpace ~
39541 \InsetSpace ~
39542 inc r0
39543 \end_layout
39544
39545 \begin_layout Standard
39546
39547 \size footnotesize
39548 ; goto _whilecontinue_0($1)
39549 \end_layout
39550
39551 \begin_layout Standard
39552
39553 \size footnotesize
39554 \InsetSpace ~
39555 \InsetSpace ~
39556 sjmp 00101$
39557 \end_layout
39558
39559 \begin_layout Standard
39560
39561 \size footnotesize
39562 ; _whilebreak_0($3) :
39563 \end_layout
39564
39565 \begin_layout Standard
39566
39567 \size footnotesize
39568 00103$:
39569 \end_layout
39570
39571 \begin_layout Standard
39572
39573 \size footnotesize
39574 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
39575 \end_layout
39576
39577 \begin_layout Standard
39578
39579 \size footnotesize
39580 \InsetSpace ~
39581 \InsetSpace ~
39582 mov r2,#0x00
39583 \end_layout
39584
39585 \begin_layout Standard
39586
39587 \size footnotesize
39588 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
39589 \end_layout
39590
39591 \begin_layout Standard
39592
39593 \size footnotesize
39594 \InsetSpace ~
39595 \InsetSpace ~
39596 mov r3,#0x00
39597 \end_layout
39598
39599 \begin_layout Standard
39600
39601 \size footnotesize
39602 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
39603 \end_layout
39604
39605 \begin_layout Standard
39606
39607 \size footnotesize
39608 \InsetSpace ~
39609 \InsetSpace ~
39610 mov r4,#0x00
39611 \end_layout
39612
39613 \begin_layout Standard
39614
39615 \size footnotesize
39616 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
39617 \end_layout
39618
39619 \begin_layout Standard
39620
39621 \size footnotesize
39622 \InsetSpace ~
39623 \InsetSpace ~
39624 mov r5,#0x0A
39625 \end_layout
39626
39627 \begin_layout Standard
39628
39629 \size footnotesize
39630 \InsetSpace ~
39631 \InsetSpace ~
39632 mov r6,#0x00
39633 \end_layout
39634
39635 \begin_layout Standard
39636
39637 \size footnotesize
39638 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
39639 \end_layout
39640
39641 \begin_layout Standard
39642
39643 \size footnotesize
39644 \InsetSpace ~
39645 \InsetSpace ~
39646 mov r7,#0x1E
39647 \end_layout
39648
39649 \begin_layout Standard
39650
39651 \size footnotesize
39652 \InsetSpace ~
39653 \InsetSpace ~
39654 mov r0,#0x00
39655 \end_layout
39656
39657 \begin_layout Standard
39658
39659 \size footnotesize
39660 ; _forcond_0($4) :
39661 \end_layout
39662
39663 \begin_layout Standard
39664
39665 \size footnotesize
39666 00104$:
39667 \end_layout
39668
39669 \begin_layout Standard
39670
39671 \size footnotesize
39672 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
39673 \end_layout
39674
39675 \begin_layout Standard
39676
39677 \size footnotesize
39678 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
39679 \end_layout
39680
39681 \begin_layout Standard
39682
39683 \size footnotesize
39684 \InsetSpace ~
39685 \InsetSpace ~
39686 clr c
39687 \end_layout
39688
39689 \begin_layout Standard
39690
39691 \size footnotesize
39692 \InsetSpace ~
39693 \InsetSpace ~
39694 mov a,r4
39695 \end_layout
39696
39697 \begin_layout Standard
39698
39699 \size footnotesize
39700 \InsetSpace ~
39701 \InsetSpace ~
39702 xrl a,#0x80
39703 \end_layout
39704
39705 \begin_layout Standard
39706
39707 \size footnotesize
39708 \InsetSpace ~
39709 \InsetSpace ~
39710 subb a,#0x8a
39711 \end_layout
39712
39713 \begin_layout Standard
39714
39715 \size footnotesize
39716 \InsetSpace ~
39717 \InsetSpace ~
39718 jnc 00107$
39719 \end_layout
39720
39721 \begin_layout Standard
39722
39723 \size footnotesize
39724 00115$:
39725 \end_layout
39726
39727 \begin_layout Standard
39728
39729 \size footnotesize
39730 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] +
39731 \end_layout
39732
39733 \begin_layout Standard
39734
39735 \size footnotesize
39736 ; iTemp21 [lr21:38]{short}[r4]
39737 \end_layout
39738
39739 \begin_layout Standard
39740
39741 \size footnotesize
39742 \InsetSpace ~
39743 \InsetSpace ~
39744 mov a,r4
39745 \end_layout
39746
39747 \begin_layout Standard
39748
39749 \size footnotesize
39750 \InsetSpace ~
39751 \InsetSpace ~
39752 add a,r2
39753 \end_layout
39754
39755 \begin_layout Standard
39756
39757 \size footnotesize
39758 \InsetSpace ~
39759 \InsetSpace ~
39760 mov r2,a
39761 \end_layout
39762
39763 \begin_layout Standard
39764
39765 \size footnotesize
39766 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
39767 \end_layout
39768
39769 \begin_layout Standard
39770
39771 \size footnotesize
39772 \InsetSpace ~
39773 \InsetSpace ~
39774 mov b,#0x03
39775 \end_layout
39776
39777 \begin_layout Standard
39778
39779 \size footnotesize
39780 \InsetSpace ~
39781 \InsetSpace ~
39782 mov a,r4
39783 \end_layout
39784
39785 \begin_layout Standard
39786
39787 \size footnotesize
39788 \InsetSpace ~
39789 \InsetSpace ~
39790 mul ab
39791 \end_layout
39792
39793 \begin_layout Standard
39794
39795 \size footnotesize
39796 \InsetSpace ~
39797 \InsetSpace ~
39798 mov r1,a
39799 \end_layout
39800
39801 \begin_layout Standard
39802
39803 \size footnotesize
39804 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] +
39805 \end_layout
39806
39807 \begin_layout Standard
39808
39809 \size footnotesize
39810 ; iTemp15 [lr29:30]{short}[r1]
39811 \end_layout
39812
39813 \begin_layout Standard
39814
39815 \size footnotesize
39816 \InsetSpace ~
39817 \InsetSpace ~
39818 add a,r3
39819 \end_layout
39820
39821 \begin_layout Standard
39822
39823 \size footnotesize
39824 \InsetSpace ~
39825 \InsetSpace ~
39826 mov r3,a
39827 \end_layout
39828
39829 \begin_layout Standard
39830
39831 \size footnotesize
39832 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
39833 \end_layout
39834
39835 \begin_layout Standard
39836
39837 \size footnotesize
39838 \InsetSpace ~
39839 \InsetSpace ~
39840 mov a,r7
39841 \end_layout
39842
39843 \begin_layout Standard
39844
39845 \size footnotesize
39846 \InsetSpace ~
39847 \InsetSpace ~
39848 add a,#0xfd
39849 \end_layout
39850
39851 \begin_layout Standard
39852
39853 \size footnotesize
39854 \InsetSpace ~
39855 \InsetSpace ~
39856 mov r7,a
39857 \end_layout
39858
39859 \begin_layout Standard
39860
39861 \size footnotesize
39862 \InsetSpace ~
39863 \InsetSpace ~
39864 mov a,r0
39865 \end_layout
39866
39867 \begin_layout Standard
39868
39869 \size footnotesize
39870 \InsetSpace ~
39871 \InsetSpace ~
39872 addc a,#0xff
39873 \end_layout
39874
39875 \begin_layout Standard
39876
39877 \size footnotesize
39878 \InsetSpace ~
39879 \InsetSpace ~
39880 mov r0,a
39881 \end_layout
39882
39883 \begin_layout Standard
39884
39885 \size footnotesize
39886 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
39887 \end_layout
39888
39889 \begin_layout Standard
39890
39891 \size footnotesize
39892 \InsetSpace ~
39893 \InsetSpace ~
39894 mov a,r7
39895 \end_layout
39896
39897 \begin_layout Standard
39898
39899 \size footnotesize
39900 \InsetSpace ~
39901 \InsetSpace ~
39902 add a,_gint
39903 \end_layout
39904
39905 \begin_layout Standard
39906
39907 \size footnotesize
39908 \InsetSpace ~
39909 \InsetSpace ~
39910 mov _gint,a
39911 \end_layout
39912
39913 \begin_layout Standard
39914
39915 \size footnotesize
39916 \InsetSpace ~
39917 \InsetSpace ~
39918 mov a,r0
39919 \end_layout
39920
39921 \begin_layout Standard
39922
39923 \size footnotesize
39924 \InsetSpace ~
39925 \InsetSpace ~
39926 addc a,(_gint + 1)
39927 \end_layout
39928
39929 \begin_layout Standard
39930
39931 \size footnotesize
39932 \InsetSpace ~
39933 \InsetSpace ~
39934 mov (_gint + 1),a
39935 \end_layout
39936
39937 \begin_layout Standard
39938
39939 \size footnotesize
39940 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
39941 \end_layout
39942
39943 \begin_layout Standard
39944
39945 \size footnotesize
39946 \InsetSpace ~
39947 \InsetSpace ~
39948 inc r4
39949 \end_layout
39950
39951 \begin_layout Standard
39952
39953 \size footnotesize
39954 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
39955 \end_layout
39956
39957 \begin_layout Standard
39958
39959 \size footnotesize
39960 \InsetSpace ~
39961 \InsetSpace ~
39962 dec r5
39963 \end_layout
39964
39965 \begin_layout Standard
39966
39967 \size footnotesize
39968 \InsetSpace ~
39969 \InsetSpace ~
39970 cjne r5,#0xff,00104$
39971 \end_layout
39972
39973 \begin_layout Standard
39974
39975 \size footnotesize
39976 \InsetSpace ~
39977 \InsetSpace ~
39978 dec r6
39979 \end_layout
39980
39981 \begin_layout Standard
39982
39983 \size footnotesize
39984 ; goto _forcond_0($4)
39985 \end_layout
39986
39987 \begin_layout Standard
39988
39989 \size footnotesize
39990 \InsetSpace ~
39991 \InsetSpace ~
39992 sjmp 00104$
39993 \end_layout
39994
39995 \begin_layout Standard
39996
39997 \size footnotesize
39998 ; _forbreak_0($7) :
39999 \end_layout
40000
40001 \begin_layout Standard
40002
40003 \size footnotesize
40004 00107$:
40005 \end_layout
40006
40007 \begin_layout Standard
40008
40009 \size footnotesize
40010 ; ret iTemp24 [lr40:41]{short}
40011 \end_layout
40012
40013 \begin_layout Standard
40014
40015 \size footnotesize
40016 \InsetSpace ~
40017 \InsetSpace ~
40018 mov a,r3
40019 \end_layout
40020
40021 \begin_layout Standard
40022
40023 \size footnotesize
40024 \InsetSpace ~
40025 \InsetSpace ~
40026 add a,r2
40027 \end_layout
40028
40029 \begin_layout Standard
40030
40031 \size footnotesize
40032 \InsetSpace ~
40033 \InsetSpace ~
40034 mov dpl,a
40035 \end_layout
40036
40037 \begin_layout Standard
40038
40039 \size footnotesize
40040 ; _return($8) :
40041 \end_layout
40042
40043 \begin_layout Standard
40044
40045 \size footnotesize
40046 00108$:
40047 \end_layout
40048
40049 \begin_layout Standard
40050
40051 \size footnotesize
40052 \InsetSpace ~
40053 \InsetSpace ~
40054 ret
40055 \newline
40056
40057 \end_layout
40058
40059 \begin_layout Section
40060 A few words about basic block successors, predecessors and dominators
40061 \end_layout
40062
40063 \begin_layout Standard
40064 Successors are basic blocks
40065 \begin_inset LatexCommand \index{Basic blocks}
40066
40067 \end_inset
40068
40069  that might execute after this basic block.
40070 \newline
40071 Predecessors are basic blocks
40072  that might execute before reaching this basic block.
40073 \newline
40074 Dominators are basic
40075  blocks that WILL execute before reaching this basic block.
40076 \newline
40077
40078 \end_layout
40079
40080 \begin_layout Standard
40081 [basic block 1]
40082 \end_layout
40083
40084 \begin_layout Standard
40085 if (something)
40086 \end_layout
40087
40088 \begin_layout Standard
40089 \InsetSpace ~
40090 \InsetSpace ~
40091 \InsetSpace ~
40092 \InsetSpace ~
40093 [basic block 2]
40094 \end_layout
40095
40096 \begin_layout Standard
40097 else
40098 \end_layout
40099
40100 \begin_layout Standard
40101 \InsetSpace ~
40102 \InsetSpace ~
40103 \InsetSpace ~
40104 \InsetSpace ~
40105 [basic block 3]
40106 \end_layout
40107
40108 \begin_layout Standard
40109 [basic block 4]
40110 \newline
40111
40112 \end_layout
40113
40114 \begin_layout Standard
40115 a) succList of [BB2] = [BB4], of [BB3] = [BB4], of [BB1] = [BB2,BB3]
40116 \end_layout
40117
40118 \begin_layout Standard
40119 b) predList of [BB2] = [BB1], of [BB3] = [BB1], of [BB4] = [BB2,BB3]
40120 \end_layout
40121
40122 \begin_layout Standard
40123 c) domVect of [BB4] = BB1 ...
40124  here we are not sure if BB2 or BB3 was executed but we are SURE that BB1
40125  was executed.
40126 \end_layout
40127
40128 \begin_layout Chapter
40129 Acknowledgments
40130 \end_layout
40131
40132 \begin_layout Standard
40133 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net#Who}
40134
40135 \end_inset
40136
40137
40138 \newline
40139
40140 \newline
40141
40142 \emph on
40143 Thanks to all the other volunteer developers who have helped with coding,
40144  testing, web-page creation, distribution sets, etc.
40145  You know who you are :-)
40146 \emph default
40147
40148 \newline
40149
40150 \newline
40151
40152 \emph on
40153 Thanks to Sourceforge
40154 \begin_inset LatexCommand \url{http://www.sf.net}
40155
40156 \end_inset
40157
40158  which has hosted the project since 1999 and donates significant download
40159  bandwidth.
40160 \emph default
40161
40162 \newline
40163
40164 \newline
40165
40166 \emph on
40167 Also thanks to all SDCC Distributed Compile Farm members for donating CPU
40168  cycles and bandwidth for snapshot builds.
40169 \newline
40170
40171 \end_layout
40172
40173 \begin_layout Standard
40174 This document was initially written by Sandeep Dutta
40175 \end_layout
40176
40177 \begin_layout Standard
40178 All product names mentioned herein may be trademarks
40179 \begin_inset LatexCommand \index{Trademarks}
40180
40181 \end_inset
40182
40183  of their respective companies.
40184 \end_layout
40185
40186 \begin_layout Section*
40187 Alphabetical index
40188 \end_layout
40189
40190 \begin_layout Standard
40191 To avoid confusion, the installation and building options for SDCC itself
40192  (chapter 2) are not part of the index.
40193 \end_layout
40194
40195 \begin_layout Standard
40196 \begin_inset LatexCommand \printindex{}
40197
40198 \end_inset
40199
40200
40201 \end_layout
40202
40203 \end_body
40204 \end_document