* configure.in, Makefile.common.in: add support for ccache,
[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.8.3
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 C
161 \emph default
162  
163 \emph on
164 C
165 \emph default
166 ompiler) is free open source, retargettable, optimizing ANSI-C compiler
167  by 
168 \series bold
169 Sandeep Dutta
170 \series default
171  designed for 8 bit Microprocessors.
172  The current version targets Intel MCS51 based Microprocessors (8031, 8032,
173  8051, 8052
174 \begin_inset LatexCommand \index{8031, 8032, 8051, 8052, mcs51 CPU}
175
176 \end_inset
177
178 , etc.), Dallas DS80C390 variants, Freescale (formerly Motorola) HC08 and
179  Zilog Z80 based MCUs.
180  It can be retargeted for other microprocessors, support for Microchip PIC,
181  Atmel AVR is under development.
182  The entire source code for the compiler is distributed under GPL.
183  SDCC uses ASXXXX
184 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
185
186 \end_inset
187
188  & ASLINK
189 \begin_inset LatexCommand \index{aslink}
190
191 \end_inset
192
193 , an open source retargetable assembler & linker.
194  SDCC has extensive language extensions suitable for utilizing various microcont
195 rollers and underlying hardware effectively.
196  
197 \newline
198
199 \newline
200 In addition to the MCU specific optimizations SDCC also does a host of
201  standard optimizations like:
202 \end_layout
203
204 \begin_layout Itemize
205 global sub expression elimination, 
206 \end_layout
207
208 \begin_layout Itemize
209 loop optimizations (loop invariant, strength reduction of induction variables
210  and loop reversing), 
211 \end_layout
212
213 \begin_layout Itemize
214 constant folding & propagation, 
215 \end_layout
216
217 \begin_layout Itemize
218 copy propagation, 
219 \end_layout
220
221 \begin_layout Itemize
222 dead code elimination 
223 \end_layout
224
225 \begin_layout Itemize
226 jump tables for 
227 \emph on
228 switch
229 \emph default
230  statements.
231 \end_layout
232
233 \begin_layout Standard
234 For the back-end SDCC uses a global register allocation scheme which should
235  be well suited for other 8 bit MCUs.
236  
237 \newline
238
239 \newline
240 The peep hole optimizer uses a rule based substitution mechanism which
241  is MCU independent.
242  
243 \newline
244
245 \newline
246 Supported data-types are:
247 \end_layout
248
249 \begin_layout Standard
250 \begin_inset Tabular
251 <lyxtabular version="3" rows="8" columns="5">
252 <features>
253 <column alignment="center" valignment="top" leftline="true" width="0">
254 <column alignment="center" valignment="top" leftline="true" width="0">
255 <column alignment="center" valignment="top" leftline="true" width="0">
256 <column alignment="center" valignment="top" leftline="true" width="0">
257 <column alignment="block" valignment="top" leftline="true" rightline="true" width="20text%">
258 <row topline="true" bottomline="true">
259 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
260 \begin_inset Text
261
262 \begin_layout Standard
263 type
264 \end_layout
265
266 \end_inset
267 </cell>
268 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
269 \begin_inset Text
270
271 \begin_layout Standard
272 width
273 \end_layout
274
275 \end_inset
276 </cell>
277 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
278 \begin_inset Text
279
280 \begin_layout Standard
281 default
282 \end_layout
283
284 \end_inset
285 </cell>
286 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
287 \begin_inset Text
288
289 \begin_layout Standard
290 signed range
291 \end_layout
292
293 \end_inset
294 </cell>
295 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
296 \begin_inset Text
297
298 \begin_layout Standard
299 unsigned range
300 \end_layout
301
302 \end_inset
303 </cell>
304 </row>
305 <row topline="true">
306 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
307 \begin_inset Text
308
309 \begin_layout Standard
310 bool
311 \end_layout
312
313 \end_inset
314 </cell>
315 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
316 \begin_inset Text
317
318 \begin_layout Standard
319 1 bit
320 \end_layout
321
322 \end_inset
323 </cell>
324 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
325 \begin_inset Text
326
327 \begin_layout Standard
328 unsigned
329 \end_layout
330
331 \end_inset
332 </cell>
333 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
334 \begin_inset Text
335
336 \begin_layout Standard
337 -
338 \end_layout
339
340 \end_inset
341 </cell>
342 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
343 \begin_inset Text
344
345 \begin_layout Standard
346 0, 1
347 \end_layout
348
349 \end_inset
350 </cell>
351 </row>
352 <row topline="true">
353 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
354 \begin_inset Text
355
356 \begin_layout Standard
357 char
358 \end_layout
359
360 \end_inset
361 </cell>
362 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
363 \begin_inset Text
364
365 \begin_layout Standard
366 8 bits, 1 byte
367 \end_layout
368
369 \end_inset
370 </cell>
371 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
372 \begin_inset Text
373
374 \begin_layout Standard
375 signed
376 \end_layout
377
378 \end_inset
379 </cell>
380 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
381 \begin_inset Text
382
383 \begin_layout Standard
384 -128, +127
385 \end_layout
386
387 \end_inset
388 </cell>
389 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
390 \begin_inset Text
391
392 \begin_layout Standard
393 0, +255
394 \end_layout
395
396 \end_inset
397 </cell>
398 </row>
399 <row topline="true">
400 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
401 \begin_inset Text
402
403 \begin_layout Standard
404 short
405 \end_layout
406
407 \end_inset
408 </cell>
409 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
410 \begin_inset Text
411
412 \begin_layout Standard
413 16 bits, 2 bytes
414 \end_layout
415
416 \end_inset
417 </cell>
418 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
419 \begin_inset Text
420
421 \begin_layout Standard
422 signed
423 \end_layout
424
425 \end_inset
426 </cell>
427 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
428 \begin_inset Text
429
430 \begin_layout Standard
431 -32.768, +32.767
432 \end_layout
433
434 \end_inset
435 </cell>
436 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
437 \begin_inset Text
438
439 \begin_layout Standard
440 0, +65.535
441 \end_layout
442
443 \end_inset
444 </cell>
445 </row>
446 <row topline="true">
447 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
448 \begin_inset Text
449
450 \begin_layout Standard
451 int
452 \end_layout
453
454 \end_inset
455 </cell>
456 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
457 \begin_inset Text
458
459 \begin_layout Standard
460 16 bits, 2 bytes
461 \end_layout
462
463 \end_inset
464 </cell>
465 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
466 \begin_inset Text
467
468 \begin_layout Standard
469 signed
470 \end_layout
471
472 \end_inset
473 </cell>
474 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
475 \begin_inset Text
476
477 \begin_layout Standard
478 -32.768, +32.767
479 \end_layout
480
481 \end_inset
482 </cell>
483 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
484 \begin_inset Text
485
486 \begin_layout Standard
487 0, +65.535
488 \end_layout
489
490 \end_inset
491 </cell>
492 </row>
493 <row topline="true" bottomline="true">
494 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
495 \begin_inset Text
496
497 \begin_layout Standard
498 long
499 \end_layout
500
501 \end_inset
502 </cell>
503 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
504 \begin_inset Text
505
506 \begin_layout Standard
507 32 bits, 4 bytes
508 \end_layout
509
510 \end_inset
511 </cell>
512 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
513 \begin_inset Text
514
515 \begin_layout Standard
516 signed
517 \end_layout
518
519 \end_inset
520 </cell>
521 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
522 \begin_inset Text
523
524 \begin_layout Standard
525 -2.147.483.648, +2.147.483.647
526 \end_layout
527
528 \end_inset
529 </cell>
530 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
531 \begin_inset Text
532
533 \begin_layout Standard
534 0, +4.294.967.295
535 \end_layout
536
537 \end_inset
538 </cell>
539 </row>
540 <row topline="true" bottomline="true">
541 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
542 \begin_inset Text
543
544 \begin_layout Standard
545 float
546 \end_layout
547
548 \end_inset
549 </cell>
550 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
551 \begin_inset Text
552
553 \begin_layout Standard
554 4 bytes IEEE 754
555 \end_layout
556
557 \end_inset
558 </cell>
559 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
560 \begin_inset Text
561
562 \begin_layout Standard
563 signed
564 \end_layout
565
566 \end_inset
567 </cell>
568 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
569 \begin_inset Text
570
571 \begin_layout Standard
572
573 \end_layout
574
575 \end_inset
576 </cell>
577 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
578 \begin_inset Text
579
580 \begin_layout Standard
581 1.175494351E-38, 
582 \family roman
583 \series medium
584 \shape up
585 \size normal
586 \emph off
587 \bar no
588 \noun off
589 \color none
590 3.402823466E+38
591 \end_layout
592
593 \end_inset
594 </cell>
595 </row>
596 <row topline="true" bottomline="true">
597 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
598 \begin_inset Text
599
600 \begin_layout Standard
601 pointer
602 \end_layout
603
604 \end_inset
605 </cell>
606 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
607 \begin_inset Text
608
609 \begin_layout Standard
610 1, 2, 3 or 4 bytes
611 \end_layout
612
613 \end_inset
614 </cell>
615 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
616 \begin_inset Text
617
618 \begin_layout Standard
619 generic
620 \end_layout
621
622 \end_inset
623 </cell>
624 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
625 \begin_inset Text
626
627 \begin_layout Standard
628
629 \end_layout
630
631 \end_inset
632 </cell>
633 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
634 \begin_inset Text
635
636 \begin_layout Standard
637
638 \end_layout
639
640 \end_inset
641 </cell>
642 </row>
643 </lyxtabular>
644
645 \end_inset
646
647
648 \newline
649 The compiler also allows 
650 \emph on
651 inline assembler code
652 \emph default
653  to be embedded anywhere in a function.
654  In addition, routines developed in assembly can also be called.
655 \newline
656
657 \newline
658 SDCC also
659  provides an option (-
660 \begin_inset ERT
661 status collapsed
662
663 \begin_layout Standard
664
665
666 \backslash
667 /
668 \end_layout
669
670 \end_inset
671
672 -cyclomatic) to report the relative complexity of a function.
673  These functions can then be further optimized, or hand coded in assembly
674  if needed.
675  
676 \newline
677
678 \newline
679 SDCC also comes with a companion source level debugger SDCDB.
680  The debugger currently uses ucSim, a free open source simulator for 8051
681  and other micro-controllers.
682 \newline
683
684 \newline
685 The latest SDCC version can be downloaded from
686  
687 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
688
689 \end_inset
690
691 .
692
693 \series bold
694  
695 \series default
696 \emph on
697 Please note: the compiler will probably always be some steps ahead of this
698  documentation
699 \series bold
700 \emph default
701
702 \begin_inset LatexCommand \index{Status of documentation}
703
704 \end_inset
705
706
707 \begin_inset Foot
708 status open
709
710 \begin_layout Standard
711 Obviously this has pros and cons
712 \end_layout
713
714 \end_inset
715
716 .
717 \end_layout
718
719 \begin_layout Section
720 Open Source
721 \end_layout
722
723 \begin_layout Standard
724 All packages used in this compiler system are 
725 \emph on
726 open source
727 \emph default
728  and 
729 \emph on
730 freeware
731 \emph default
732 ; source code for all the sub-packages (pre-processor, assemblers, linkers
733  etc.) is distributed with the package.
734  This documentation is maintained using a free open source word processor
735  (LyX).
736 \newline
737 This program is free software; you can redistribute it and/or modify
738  it under the terms of the GNU General Public License
739 \begin_inset LatexCommand \index{GNU General Public License, GPL}
740
741 \end_inset
742
743  as published by the Free Software Foundation; either version 2, or (at
744  your option) any later version.
745  This program is distributed in the hope that it will be useful, but WITHOUT
746  ANY WARRANTY; without even the implied warranty
747 \begin_inset LatexCommand \index{warranty}
748
749 \end_inset
750
751  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
752  See the GNU General Public License for more details.
753  You should have received a copy of the GNU General Public License along
754  with this program; if not, write to the Free Software Foundation, 59 Temple
755  Place - Suite 330, Boston, MA 02111-1307, USA.
756  In other words, you are welcome to use, share and improve this program.
757  You are forbidden to forbid anyone else to use, share and improve what
758  you give them.
759  Help stamp out software-hoarding! 
760 \end_layout
761
762 \begin_layout Section
763 Typographic conventions
764 \begin_inset LatexCommand \index{Typographic conventions}
765
766 \end_inset
767
768
769 \end_layout
770
771 \begin_layout Standard
772 Throughout this manual, we will use the following convention.
773  Commands you have to type in are printed in 
774 \family sans
775 \series bold
776 "sans serif"
777 \series default
778 .
779
780 \family default
781  Code samples are printed in 
782 \family typewriter
783 typewriter font.
784
785 \family default
786  Interesting items and new terms are printed in 
787 \emph on
788 italic.
789 \end_layout
790
791 \begin_layout Section
792 Compatibility
793 \begin_inset LatexCommand \label{sec:Compatibility-with-previous}
794
795 \end_inset
796
797  with previous versions
798 \begin_inset LatexCommand \index{Compatibility with previous versions}
799
800 \end_inset
801
802
803 \end_layout
804
805 \begin_layout Standard
806 Newer versions have usually numerous bug fixes compared with the previous
807  version.
808  But we also sometimes introduce some incompatibilities with older versions.
809  Not just for the fun of it, but to make the compiler more stable, efficient
810  and ANSI compliant
811 \begin_inset LatexCommand \index{ANSI-compliance}
812
813 \end_inset
814
815  (see section 
816 \begin_inset LatexCommand \ref{sub:ANSI-Compliance}
817
818 \end_inset
819
820  for ANSI-Compliance).
821  
822 \begin_inset Note Note
823 status collapsed
824
825 \begin_layout Standard
826 It would be fine to add to each item, in which version was it changed.
827 \end_layout
828
829 \end_inset
830
831
832 \newline
833
834 \end_layout
835
836 \begin_layout Itemize
837 short is now equivalent to int (16 bits), it used to be equivalent to char
838  (8 bits) which is not ANSI compliant.
839  To maintain compatibility, old programs may be compiled using the -
840 \begin_inset ERT
841 status collapsed
842
843 \begin_layout Standard
844
845
846 \backslash
847 /
848 \end_layout
849
850 \end_inset
851
852 -short-is-8bits commandline option (see 
853 \begin_inset LatexCommand \vref{lyx:--short-is-8bits}
854
855 \end_inset
856
857 ).
858 \end_layout
859
860 \begin_layout Itemize
861 the default directory for gcc-builds where include, library and documentation
862  files are stored is now in /usr/local/share.
863 \end_layout
864
865 \begin_layout Itemize
866 char type parameters to vararg
867 \begin_inset LatexCommand \index{vararg, va\_arg}
868
869 \end_inset
870
871  functions are casted to int unless explicitly casted and 
872 \series bold
873 -
874 \begin_inset ERT
875 status collapsed
876
877 \begin_layout Standard
878
879
880 \backslash
881 /
882 \end_layout
883
884 \end_inset
885
886 -std-c89
887 \begin_inset LatexCommand \index{-\/-std-c89}
888
889 \end_inset
890
891  
892 \series default
893 and
894 \series bold
895  -
896 \begin_inset ERT
897 status collapsed
898
899 \begin_layout Standard
900
901
902 \backslash
903 /
904 \end_layout
905
906 \end_inset
907
908 -std-c99
909 \begin_inset LatexCommand \index{-\/-std-c99}
910
911 \end_inset
912
913
914 \series default
915  command line option are not defined 
916 \begin_inset Marginal
917 status collapsed
918
919 \begin_layout Standard
920
921 \series bold
922 \InsetSpace ~
923 !
924 \end_layout
925
926 \end_inset
927
928 , e.g.: 
929 \newline
930
931 \family typewriter
932 \InsetSpace ~
933 \InsetSpace ~
934 char a=3;
935 \newline
936 \InsetSpace ~
937 \InsetSpace ~
938 printf ("%d %c
939 \backslash
940 n", a, (char)a);
941 \family default
942
943 \newline
944  will push a as an int and as a char resp if
945 \series bold
946  -
947 \begin_inset ERT
948 status collapsed
949
950 \begin_layout Standard
951
952
953 \backslash
954 /
955 \end_layout
956
957 \end_inset
958
959 -std-c89
960 \begin_inset LatexCommand \index{-\/-std-c89}
961
962 \end_inset
963
964  
965 \series default
966 and
967 \series bold
968  -
969 \begin_inset ERT
970 status collapsed
971
972 \begin_layout Standard
973
974
975 \backslash
976 /
977 \end_layout
978
979 \end_inset
980
981 -std-c99
982 \begin_inset LatexCommand \index{-\/-std-c99}
983
984 \end_inset
985
986
987 \series default
988  command line options are not defined,
989 \newline
990  will push a as two ints if
991 \series bold
992  -
993 \begin_inset ERT
994 status collapsed
995
996 \begin_layout Standard
997
998
999 \backslash
1000 /
1001 \end_layout
1002
1003 \end_inset
1004
1005 -std-c89
1006 \begin_inset LatexCommand \index{-\/-std-c89}
1007
1008 \end_inset
1009
1010  
1011 \series default
1012 or
1013 \series bold
1014  -
1015 \begin_inset ERT
1016 status collapsed
1017
1018 \begin_layout Standard
1019
1020
1021 \backslash
1022 /
1023 \end_layout
1024
1025 \end_inset
1026
1027 -std-c99
1028 \begin_inset LatexCommand \index{-\/-std-c99}
1029
1030 \end_inset
1031
1032
1033 \series default
1034  command line option is defined.
1035 \end_layout
1036
1037 \begin_layout Itemize
1038 option -
1039 \begin_inset ERT
1040 status collapsed
1041
1042 \begin_layout Standard
1043
1044
1045 \backslash
1046 /
1047 \end_layout
1048
1049 \end_inset
1050
1051 -regextend has been removed.
1052 \end_layout
1053
1054 \begin_layout Itemize
1055 option -
1056 \begin_inset ERT
1057 status collapsed
1058
1059 \begin_layout Standard
1060
1061
1062 \backslash
1063 /
1064 \end_layout
1065
1066 \end_inset
1067
1068 -noregparms has been removed.
1069 \end_layout
1070
1071 \begin_layout Itemize
1072 option -
1073 \begin_inset ERT
1074 status collapsed
1075
1076 \begin_layout Standard
1077
1078
1079 \backslash
1080 /
1081 \end_layout
1082
1083 \end_inset
1084
1085 -stack-after-data has been removed.
1086 \end_layout
1087
1088 \begin_layout Itemize
1089 bit
1090 \begin_inset LatexCommand \index{bit}
1091
1092 \end_inset
1093
1094  and sbit
1095 \begin_inset LatexCommand \index{sbit}
1096
1097 \end_inset
1098
1099
1100 \begin_inset LatexCommand \index{\_\_sbit}
1101
1102 \end_inset
1103
1104  types now consistently behave like the C99 _Bool type with respect to type
1105  conversion
1106 \begin_inset LatexCommand \index{type conversion}
1107
1108 \end_inset
1109
1110
1111 \begin_inset LatexCommand \index{type promotion}
1112
1113 \end_inset
1114
1115 .
1116  The most common incompatibility resulting from this change is related to
1117  bit toggling
1118 \begin_inset LatexCommand \index{Bit toggling}
1119
1120 \end_inset
1121
1122  idioms, e.g.:
1123 \newline
1124
1125 \family typewriter
1126 \InsetSpace ~
1127 \InsetSpace ~
1128 bit b;
1129 \newline
1130 \InsetSpace ~
1131 \InsetSpace ~
1132 b = ~
1133 \begin_inset LatexCommand \index{\~\/ Operator}
1134
1135 \end_inset
1136
1137 b; /* equivalent to b=1 instead of toggling b */
1138 \begin_inset Marginal
1139 status collapsed
1140
1141 \begin_layout Standard
1142
1143 \series bold
1144 \InsetSpace ~
1145 !
1146 \end_layout
1147
1148 \end_inset
1149
1150
1151 \newline
1152 \InsetSpace ~
1153 \InsetSpace ~
1154 b = !b; /* toggles b */
1155 \newline
1156
1157 \family default
1158 In previous versions, both forms would have toggled the bit.
1159 \end_layout
1160
1161 \begin_layout Itemize
1162 in older versions, the preprocessor was always called with -std=c99 regardless
1163  of the --std-xxx setting.
1164  This is no longer true, and can cause compilation failures on code built
1165  with --std-c89 but using c99 preprocessor features, such as one-line (//)
1166  comments
1167 \end_layout
1168
1169 \begin_layout Standard
1170
1171 \emph on
1172 <pending: more incompatibilities?>
1173 \end_layout
1174
1175 \begin_layout Section
1176 System Requirements
1177 \end_layout
1178
1179 \begin_layout Standard
1180 What do you need before you start installation of SDCC? A computer, and
1181  a desire to compute.
1182  The preferred method of installation is to compile SDCC from source using
1183  GNU gcc and make.
1184  For Windows some pre-compiled binary distributions are available for your
1185  convenience.
1186  You should have some experience with command line tools and compiler use.
1187 \end_layout
1188
1189 \begin_layout Section
1190 Other Resources
1191 \end_layout
1192
1193 \begin_layout Standard
1194 The SDCC home page at 
1195 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/}
1196
1197 \end_inset
1198
1199  is a great place to find distribution sets.
1200  You can also find links to the user mailing lists that offer help or discuss
1201  SDCC with other SDCC users.
1202  Web links to other SDCC related sites can also be found here.
1203  This document can be found in the DOC directory of the source package as
1204  a text or HTML file.
1205  A pdf version of this document is available at 
1206 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
1207
1208 \end_inset
1209
1210 .
1211  Some of the other tools (simulator and assembler) included with SDCC contain
1212  their own documentation and can be found in the source distribution.
1213  If you want the latest unreleased software, the complete source package
1214  is available directly from Subversion on https://sdcc.svn.sourceforge.net/svnroot/
1215 sdcc/trunk/sdcc.
1216 \end_layout
1217
1218 \begin_layout Section
1219 Wishes for the future
1220 \end_layout
1221
1222 \begin_layout Standard
1223 There are (and always will be) some things that could be done.
1224  Here are some I can think of:
1225 \newline
1226
1227 \end_layout
1228
1229 \begin_layout Standard
1230
1231 \family typewriter
1232 char KernelFunction3(char p) at 0x340;
1233 \newline
1234
1235 \end_layout
1236
1237 \begin_layout Standard
1238
1239 \family typewriter
1240 better code banking
1241 \begin_inset LatexCommand \index{code banking (limited support)}
1242
1243 \end_inset
1244
1245  support for mcs51
1246 \newline
1247
1248 \newline
1249
1250 \family default
1251 If you can think of some more, please see the section 
1252 \begin_inset LatexCommand \ref{sub:Requesting-Features}
1253
1254 \end_inset
1255
1256  about filing feature requests
1257 \begin_inset LatexCommand \index{Requesting features}
1258
1259 \end_inset
1260
1261
1262 \begin_inset LatexCommand \index{Feature request}
1263
1264 \end_inset
1265
1266 .
1267 \newline
1268
1269 \end_layout
1270
1271 \begin_layout Chapter
1272 Installing SDCC
1273 \begin_inset LatexCommand \index{Installation}
1274
1275 \end_inset
1276
1277
1278 \end_layout
1279
1280 \begin_layout Standard
1281 For most users it is sufficient to skip to either section 
1282 \begin_inset LatexCommand \ref{sub:Building-SDCC-on-Linux}
1283
1284 \end_inset
1285
1286  (Unix) or section 
1287 \begin_inset LatexCommand \ref{sub:Windows-Install}
1288
1289 \end_inset
1290
1291  (Windows).
1292  More detailed instructions follow below.
1293 \end_layout
1294
1295 \begin_layout Section
1296 Configure Options
1297 \begin_inset LatexCommand \index{Options SDCC configuration}
1298
1299 \end_inset
1300
1301
1302 \end_layout
1303
1304 \begin_layout Standard
1305 The install paths, search paths and other options are defined when running
1306  'configure'.
1307  The defaults can be overridden by:
1308 \end_layout
1309
1310 \begin_layout List
1311 \labelwidthstring 00.00.0000
1312 -
1313 \begin_inset ERT
1314 status collapsed
1315
1316 \begin_layout Standard
1317
1318
1319 \backslash
1320 /
1321 \end_layout
1322
1323 \end_inset
1324
1325 -prefix see table below
1326 \end_layout
1327
1328 \begin_layout List
1329 \labelwidthstring 00.00.0000
1330 -
1331 \begin_inset ERT
1332 status collapsed
1333
1334 \begin_layout Standard
1335
1336
1337 \backslash
1338 /
1339 \end_layout
1340
1341 \end_inset
1342
1343 -exec_prefix see table below
1344 \end_layout
1345
1346 \begin_layout List
1347 \labelwidthstring 00.00.0000
1348 -
1349 \begin_inset ERT
1350 status collapsed
1351
1352 \begin_layout Standard
1353
1354
1355 \backslash
1356 /
1357 \end_layout
1358
1359 \end_inset
1360
1361 -bindir see table below
1362 \end_layout
1363
1364 \begin_layout List
1365 \labelwidthstring 00.00.0000
1366 -
1367 \begin_inset ERT
1368 status collapsed
1369
1370 \begin_layout Standard
1371
1372
1373 \backslash
1374 /
1375 \end_layout
1376
1377 \end_inset
1378
1379 -datadir see table below
1380 \end_layout
1381
1382 \begin_layout List
1383 \labelwidthstring 00.00.0000
1384 -
1385 \begin_inset ERT
1386 status collapsed
1387
1388 \begin_layout Standard
1389
1390
1391 \backslash
1392 /
1393 \end_layout
1394
1395 \end_inset
1396
1397 -datarootdir see table below
1398 \newline
1399
1400 \end_layout
1401
1402 \begin_layout List
1403 \labelwidthstring 00.00.0000
1404 \InsetSpace ~
1405 \InsetSpace ~
1406 docdir environment variable, see table below
1407 \end_layout
1408
1409 \begin_layout List
1410 \labelwidthstring 00.00.0000
1411 \InsetSpace ~
1412 \InsetSpace ~
1413 include_dir_suffix environment variable, see table below
1414 \end_layout
1415
1416 \begin_layout List
1417 \labelwidthstring 00.00.0000
1418 \InsetSpace ~
1419 \InsetSpace ~
1420 lib_dir_suffix environment variable, see table below
1421 \end_layout
1422
1423 \begin_layout List
1424 \labelwidthstring 00.00.0000
1425 \InsetSpace ~
1426 \InsetSpace ~
1427 sdccconf_h_dir_separator environment variable, either / or 
1428 \backslash
1429
1430 \backslash
1431  makes sense here.
1432  This character will only be used in sdccconf.h; don't forget it's a C-header,
1433  therefore a double-backslash is needed there.
1434 \newline
1435
1436 \end_layout
1437
1438 \begin_layout List
1439 \labelwidthstring 00.00.0000
1440 -
1441 \begin_inset ERT
1442 status collapsed
1443
1444 \begin_layout Standard
1445
1446
1447 \backslash
1448 /
1449 \end_layout
1450
1451 \end_inset
1452
1453 -disable-mcs51-port Excludes the Intel mcs51 port
1454 \end_layout
1455
1456 \begin_layout List
1457 \labelwidthstring 00.00.0000
1458 -
1459 \begin_inset ERT
1460 status collapsed
1461
1462 \begin_layout Standard
1463
1464
1465 \backslash
1466 /
1467 \end_layout
1468
1469 \end_inset
1470
1471 -disable-gbz80-port Excludes the Gameboy gbz80 port
1472 \end_layout
1473
1474 \begin_layout List
1475 \labelwidthstring 00.00.0000
1476 -
1477 \begin_inset ERT
1478 status collapsed
1479
1480 \begin_layout Standard
1481
1482
1483 \backslash
1484 /
1485 \end_layout
1486
1487 \end_inset
1488
1489 -disable-z80-port Excludes the z80 port
1490 \end_layout
1491
1492 \begin_layout List
1493 \labelwidthstring 00.00.0000
1494 -
1495 \begin_inset ERT
1496 status collapsed
1497
1498 \begin_layout Standard
1499
1500
1501 \backslash
1502 /
1503 \end_layout
1504
1505 \end_inset
1506
1507 -disable-avr-port Excludes the AVR port
1508 \end_layout
1509
1510 \begin_layout List
1511 \labelwidthstring 00.00.0000
1512 -
1513 \begin_inset ERT
1514 status collapsed
1515
1516 \begin_layout Standard
1517
1518
1519 \backslash
1520 /
1521 \end_layout
1522
1523 \end_inset
1524
1525 -disable-ds390-port Excludes the DS390 port
1526 \end_layout
1527
1528 \begin_layout List
1529 \labelwidthstring 00.00.0000
1530 -
1531 \begin_inset ERT
1532 status collapsed
1533
1534 \begin_layout Standard
1535
1536
1537 \backslash
1538 /
1539 \end_layout
1540
1541 \end_inset
1542
1543 -disable-hc08-port Excludes the HC08 port
1544 \end_layout
1545
1546 \begin_layout List
1547 \labelwidthstring 00.00.0000
1548 -
1549 \begin_inset ERT
1550 status collapsed
1551
1552 \begin_layout Standard
1553
1554
1555 \backslash
1556 /
1557 \end_layout
1558
1559 \end_inset
1560
1561 -disable-pic-port Excludes the PIC14 port
1562 \end_layout
1563
1564 \begin_layout List
1565 \labelwidthstring 00.00.0000
1566 -
1567 \begin_inset ERT
1568 status collapsed
1569
1570 \begin_layout Standard
1571
1572
1573 \backslash
1574 /
1575 \end_layout
1576
1577 \end_inset
1578
1579 -disable-pic16-port Excludes the PIC16 port
1580 \end_layout
1581
1582 \begin_layout List
1583 \labelwidthstring 00.00.0000
1584 -
1585 \begin_inset ERT
1586 status collapsed
1587
1588 \begin_layout Standard
1589
1590
1591 \backslash
1592 /
1593 \end_layout
1594
1595 \end_inset
1596
1597 -disable-xa51-port Excludes the XA51 port
1598 \end_layout
1599
1600 \begin_layout List
1601 \labelwidthstring 00.00.0000
1602 -
1603 \begin_inset ERT
1604 status collapsed
1605
1606 \begin_layout Standard
1607
1608
1609 \backslash
1610 /
1611 \end_layout
1612
1613 \end_inset
1614
1615 -disable-ucsim Disables configuring and building of ucsim
1616 \end_layout
1617
1618 \begin_layout List
1619 \labelwidthstring 00.00.0000
1620 -
1621 \begin_inset ERT
1622 status collapsed
1623
1624 \begin_layout Standard
1625
1626
1627 \backslash
1628 /
1629 \end_layout
1630
1631 \end_inset
1632
1633 -disable-device-lib Disables automatically building device libraries
1634 \end_layout
1635
1636 \begin_layout List
1637 \labelwidthstring 00.00.0000
1638 -
1639 \begin_inset ERT
1640 status collapsed
1641
1642 \begin_layout Standard
1643
1644
1645 \backslash
1646 /
1647 \end_layout
1648
1649 \end_inset
1650
1651 -disable-packihx Disables building packihx
1652 \newline
1653
1654 \end_layout
1655
1656 \begin_layout List
1657 \labelwidthstring 00.00.0000
1658 -
1659 \begin_inset ERT
1660 status collapsed
1661
1662 \begin_layout Standard
1663
1664
1665 \backslash
1666 /
1667 \end_layout
1668
1669 \end_inset
1670
1671 -enable-doc Build pdf, html and txt files from the lyx sources
1672 \end_layout
1673
1674 \begin_layout List
1675 \labelwidthstring 00.00.0000
1676 -
1677 \begin_inset ERT
1678 status collapsed
1679
1680 \begin_layout Standard
1681
1682
1683 \backslash
1684 /
1685 \end_layout
1686
1687 \end_inset
1688
1689 -enable-libgc Use the Bohem memory allocator.
1690  Lower runtime footprint.
1691 \end_layout
1692
1693 \begin_layout List
1694 \labelwidthstring 00.00.0000
1695 -
1696 \begin_inset ERT
1697 status collapsed
1698
1699 \begin_layout Standard
1700
1701
1702 \backslash
1703 /
1704 \end_layout
1705
1706 \end_inset
1707
1708 -without-ccache Do not use ccache even if available
1709 \end_layout
1710
1711 \begin_layout Standard
1712 Furthermore the environment variables CC, CFLAGS, ...
1713  the tools and their arguments can be influenced.
1714  Please see `configure -
1715 \begin_inset ERT
1716 status collapsed
1717
1718 \begin_layout Standard
1719
1720
1721 \backslash
1722 /
1723 \end_layout
1724
1725 \end_inset
1726
1727 -help' and the man/info pages of `configure' for details.
1728 \newline
1729
1730 \newline
1731 The names of the
1732  standard libraries STD_LIB, STD_INT_LIB, STD_LONG_LIB, STD_FP_LIB, STD_DS390_LI
1733 B, STD_XA51_LIB and the environment variables SDCC_DIR_NAME, SDCC_INCLUDE_NAME,
1734  SDCC_LIB_NAME are defined by `configure' too.
1735  At the moment it's not possible to change the default settings (it was
1736  simply never required).
1737 \newline
1738
1739 \newline
1740 These configure options are compiled into the binaries,
1741  and can only be changed by rerunning 'configure' and recompiling SDCC.
1742  The configure options are written in 
1743 \emph on
1744 italics
1745 \emph default
1746  to distinguish them from run time environment variables (see section search
1747  paths).
1748 \newline
1749
1750 \newline
1751 The settings for 
1752 \begin_inset Quotes sld
1753 \end_inset
1754
1755 Win32 builds
1756 \begin_inset Quotes srd
1757 \end_inset
1758
1759  are used by the SDCC team to build the official Win32 binaries.
1760  The SDCC team uses Mingw32 to build the official Windows binaries, because
1761  it's
1762 \end_layout
1763
1764 \begin_layout Enumerate
1765 open source, 
1766 \end_layout
1767
1768 \begin_layout Enumerate
1769 a gcc compiler and last but not least
1770 \end_layout
1771
1772 \begin_layout Enumerate
1773 the binaries can be built by cross compiling on SDCC Distributed Compile
1774  Farm.
1775 \end_layout
1776
1777 \begin_layout Standard
1778 See the examples, how to pass the Win32 settings to 'configure'.
1779  The other Win32 builds using Borland, VC or whatever don't use 'configure',
1780  but a header file sdcc_vc_in.h is the same as sdccconf.h built by 'configure'
1781  for Win32.
1782 \newline
1783
1784 \newline
1785 These defaults are:
1786 \newline
1787
1788 \end_layout
1789
1790 \begin_layout Standard
1791 \align center
1792 \begin_inset Tabular
1793 <lyxtabular version="3" rows="9" columns="3">
1794 <features>
1795 <column alignment="block" valignment="top" leftline="true" width="0in">
1796 <column alignment="block" valignment="top" leftline="true" width="0in">
1797 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1798 <row topline="true" bottomline="true">
1799 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1800 \begin_inset Text
1801
1802 \begin_layout Standard
1803 Variable
1804 \end_layout
1805
1806 \end_inset
1807 </cell>
1808 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1809 \begin_inset Text
1810
1811 \begin_layout Standard
1812 default
1813 \end_layout
1814
1815 \end_inset
1816 </cell>
1817 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1818 \begin_inset Text
1819
1820 \begin_layout Standard
1821 Win32 builds
1822 \end_layout
1823
1824 \end_inset
1825 </cell>
1826 </row>
1827 <row topline="true">
1828 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1829 \begin_inset Text
1830
1831 \begin_layout Standard
1832
1833 \emph on
1834 PREFIX
1835 \end_layout
1836
1837 \end_inset
1838 </cell>
1839 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1840 \begin_inset Text
1841
1842 \begin_layout Standard
1843 /usr/local
1844 \end_layout
1845
1846 \end_inset
1847 </cell>
1848 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1849 \begin_inset Text
1850
1851 \begin_layout Standard
1852
1853 \backslash
1854 sdcc
1855 \end_layout
1856
1857 \end_inset
1858 </cell>
1859 </row>
1860 <row topline="true">
1861 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1862 \begin_inset Text
1863
1864 \begin_layout Standard
1865
1866 \emph on
1867 EXEC_PREFIX
1868 \end_layout
1869
1870 \end_inset
1871 </cell>
1872 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1873 \begin_inset Text
1874
1875 \begin_layout Standard
1876
1877 \emph on
1878 $PREFIX
1879 \end_layout
1880
1881 \end_inset
1882 </cell>
1883 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1884 \begin_inset Text
1885
1886 \begin_layout Standard
1887
1888 \emph on
1889 $PREFIX
1890 \end_layout
1891
1892 \end_inset
1893 </cell>
1894 </row>
1895 <row topline="true">
1896 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1897 \begin_inset Text
1898
1899 \begin_layout Standard
1900
1901 \emph on
1902 BINDIR
1903 \end_layout
1904
1905 \end_inset
1906 </cell>
1907 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1908 \begin_inset Text
1909
1910 \begin_layout Standard
1911
1912 \emph on
1913 $EXEC_PREFIX
1914 \emph default
1915 /bin
1916 \end_layout
1917
1918 \end_inset
1919 </cell>
1920 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1921 \begin_inset Text
1922
1923 \begin_layout Standard
1924
1925 \emph on
1926 $EXEC_PREFIX
1927 \emph default
1928
1929 \backslash
1930 bin
1931 \end_layout
1932
1933 \end_inset
1934 </cell>
1935 </row>
1936 <row topline="true">
1937 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1938 \begin_inset Text
1939
1940 \begin_layout Standard
1941
1942 \emph on
1943 DATADIR
1944 \end_layout
1945
1946 \end_inset
1947 </cell>
1948 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1949 \begin_inset Text
1950
1951 \begin_layout Standard
1952
1953 \emph on
1954 $DATAROOTDIR
1955 \end_layout
1956
1957 \end_inset
1958 </cell>
1959 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1960 \begin_inset Text
1961
1962 \begin_layout Standard
1963
1964 \emph on
1965 $DATAROOTDIR
1966 \end_layout
1967
1968 \end_inset
1969 </cell>
1970 </row>
1971 <row topline="true">
1972 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1973 \begin_inset Text
1974
1975 \begin_layout Standard
1976
1977 \emph on
1978 DATAROOTDIR
1979 \end_layout
1980
1981 \end_inset
1982 </cell>
1983 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1984 \begin_inset Text
1985
1986 \begin_layout Standard
1987
1988 \emph on
1989 $PREFIX
1990 \emph default
1991 /share
1992 \end_layout
1993
1994 \end_inset
1995 </cell>
1996 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1997 \begin_inset Text
1998
1999 \begin_layout Standard
2000
2001 \emph on
2002 $PREFIX
2003 \end_layout
2004
2005 \end_inset
2006 </cell>
2007 </row>
2008 <row topline="true">
2009 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2010 \begin_inset Text
2011
2012 \begin_layout Standard
2013
2014 \emph on
2015 DOCDIR
2016 \end_layout
2017
2018 \end_inset
2019 </cell>
2020 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2021 \begin_inset Text
2022
2023 \begin_layout Standard
2024
2025 \emph on
2026 $DATAROOTDIR
2027 \emph default
2028 /sdcc/doc
2029 \end_layout
2030
2031 \end_inset
2032 </cell>
2033 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2034 \begin_inset Text
2035
2036 \begin_layout Standard
2037
2038 \emph on
2039 $DATAROOTDIR
2040 \emph default
2041
2042 \backslash
2043 doc
2044 \end_layout
2045
2046 \end_inset
2047 </cell>
2048 </row>
2049 <row topline="true">
2050 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2051 \begin_inset Text
2052
2053 \begin_layout Standard
2054
2055 \emph on
2056 INCLUDE_DIR_SUFFIX
2057 \end_layout
2058
2059 \end_inset
2060 </cell>
2061 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2062 \begin_inset Text
2063
2064 \begin_layout Standard
2065 sdcc/include
2066 \end_layout
2067
2068 \end_inset
2069 </cell>
2070 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2071 \begin_inset Text
2072
2073 \begin_layout Standard
2074 include
2075 \end_layout
2076
2077 \end_inset
2078 </cell>
2079 </row>
2080 <row topline="true" bottomline="true">
2081 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2082 \begin_inset Text
2083
2084 \begin_layout Standard
2085
2086 \emph on
2087 LIB_DIR_SUFFIX
2088 \end_layout
2089
2090 \end_inset
2091 </cell>
2092 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2093 \begin_inset Text
2094
2095 \begin_layout Standard
2096 sdcc/lib
2097 \end_layout
2098
2099 \end_inset
2100 </cell>
2101 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2102 \begin_inset Text
2103
2104 \begin_layout Standard
2105 lib
2106 \end_layout
2107
2108 \end_inset
2109 </cell>
2110 </row>
2111 </lyxtabular>
2112
2113 \end_inset
2114
2115
2116 \newline
2117
2118 \end_layout
2119
2120 \begin_layout Standard
2121 \noindent
2122 'configure' also computes relative paths.
2123  This is needed for full relocatability of a binary package and to complete
2124  search paths (see section search paths below):
2125 \newline
2126  
2127 \end_layout
2128
2129 \begin_layout Standard
2130 \align center
2131 \begin_inset Tabular
2132 <lyxtabular version="3" rows="4" columns="3">
2133 <features>
2134 <column alignment="block" valignment="top" leftline="true" width="0in">
2135 <column alignment="block" valignment="top" leftline="true" width="0in">
2136 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
2137 <row topline="true" bottomline="true">
2138 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2139 \begin_inset Text
2140
2141 \begin_layout Standard
2142 Variable (computed)
2143 \end_layout
2144
2145 \end_inset
2146 </cell>
2147 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2148 \begin_inset Text
2149
2150 \begin_layout Standard
2151 default
2152 \end_layout
2153
2154 \end_inset
2155 </cell>
2156 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2157 \begin_inset Text
2158
2159 \begin_layout Standard
2160 Win32 builds
2161 \end_layout
2162
2163 \end_inset
2164 </cell>
2165 </row>
2166 <row topline="true" bottomline="true">
2167 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2168 \begin_inset Text
2169
2170 \begin_layout Standard
2171
2172 \emph on
2173 BIN2DATA_DIR
2174 \end_layout
2175
2176 \end_inset
2177 </cell>
2178 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2179 \begin_inset Text
2180
2181 \begin_layout Standard
2182 ../share
2183 \end_layout
2184
2185 \end_inset
2186 </cell>
2187 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2188 \begin_inset Text
2189
2190 \begin_layout Standard
2191 ..
2192 \end_layout
2193
2194 \end_inset
2195 </cell>
2196 </row>
2197 <row bottomline="true">
2198 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2199 \begin_inset Text
2200
2201 \begin_layout Standard
2202
2203 \emph on
2204 PREFIX2BIN_DIR
2205 \end_layout
2206
2207 \end_inset
2208 </cell>
2209 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2210 \begin_inset Text
2211
2212 \begin_layout Standard
2213 bin
2214 \end_layout
2215
2216 \end_inset
2217 </cell>
2218 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2219 \begin_inset Text
2220
2221 \begin_layout Standard
2222 bin
2223 \end_layout
2224
2225 \end_inset
2226 </cell>
2227 </row>
2228 <row bottomline="true">
2229 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2230 \begin_inset Text
2231
2232 \begin_layout Standard
2233
2234 \emph on
2235 PREFIX2DATA_DIR
2236 \end_layout
2237
2238 \end_inset
2239 </cell>
2240 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2241 \begin_inset Text
2242
2243 \begin_layout Standard
2244 share/sdcc
2245 \end_layout
2246
2247 \end_inset
2248 </cell>
2249 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2250 \begin_inset Text
2251
2252 \begin_layout Standard
2253
2254 \end_layout
2255
2256 \end_inset
2257 </cell>
2258 </row>
2259 </lyxtabular>
2260
2261 \end_inset
2262
2263
2264 \newline
2265
2266 \end_layout
2267
2268 \begin_layout Standard
2269 \noindent
2270 Examples:
2271 \end_layout
2272
2273 \begin_layout LyX-Code
2274 ./configure
2275 \newline
2276 ./configure -
2277 \begin_inset ERT
2278 status collapsed
2279
2280 \begin_layout Standard
2281
2282
2283 \backslash
2284 /
2285 \end_layout
2286
2287 \end_inset
2288
2289 -prefix=
2290 \begin_inset Quotes srd
2291 \end_inset
2292
2293 /usr/bin
2294 \begin_inset Quotes srd
2295 \end_inset
2296
2297  -
2298 \begin_inset ERT
2299 status collapsed
2300
2301 \begin_layout Standard
2302
2303
2304 \backslash
2305 /
2306 \end_layout
2307
2308 \end_inset
2309
2310 -datarootdir=
2311 \begin_inset Quotes srd
2312 \end_inset
2313
2314 /usr/share
2315 \begin_inset Quotes srd
2316 \end_inset
2317
2318
2319 \newline
2320 ./configure -
2321 \begin_inset ERT
2322 status collapsed
2323
2324 \begin_layout Standard
2325
2326
2327 \backslash
2328 /
2329 \end_layout
2330
2331 \end_inset
2332
2333 -disable-avr-port -
2334 \begin_inset ERT
2335 status collapsed
2336
2337 \begin_layout Standard
2338
2339
2340 \backslash
2341 /
2342 \end_layout
2343
2344 \end_inset
2345
2346 -disable-xa51-port
2347 \end_layout
2348
2349 \begin_layout Standard
2350 To cross compile on linux for Mingw32 (see also 'sdcc/support/scripts/sdcc_mingw
2351 32'):
2352 \end_layout
2353
2354 \begin_layout LyX-Code
2355 ./configure 
2356 \backslash
2357
2358 \newline
2359 CC=
2360 \begin_inset Quotes srd
2361 \end_inset
2362
2363 i586-mingw32msvc-gcc
2364 \begin_inset Quotes srd
2365 \end_inset
2366
2367  CXX=
2368 \begin_inset Quotes srd
2369 \end_inset
2370
2371 i586-mingw32msvc-g++
2372 \begin_inset Quotes srd
2373 \end_inset
2374
2375  
2376 \backslash
2377  
2378 \newline
2379 RANLIB=
2380 \begin_inset Quotes srd
2381 \end_inset
2382
2383 i586-mingw32msvc-ranlib
2384 \begin_inset Quotes srd
2385 \end_inset
2386
2387  
2388 \backslash
2389
2390 \newline
2391 STRIP=
2392 \begin_inset Quotes srd
2393 \end_inset
2394
2395 i586-mingw32msvc-strip
2396 \begin_inset Quotes srd
2397 \end_inset
2398
2399  
2400 \backslash
2401
2402 \newline
2403 -
2404 \begin_inset ERT
2405 status collapsed
2406
2407 \begin_layout Standard
2408
2409
2410 \backslash
2411 /
2412 \end_layout
2413
2414 \end_inset
2415
2416 -prefix=
2417 \begin_inset Quotes srd
2418 \end_inset
2419
2420 /sdcc
2421 \begin_inset Quotes srd
2422 \end_inset
2423
2424  
2425 \backslash
2426
2427 \newline
2428 -
2429 \begin_inset ERT
2430 status collapsed
2431
2432 \begin_layout Standard
2433
2434
2435 \backslash
2436 /
2437 \end_layout
2438
2439 \end_inset
2440
2441 -datarootdir=
2442 \begin_inset Quotes srd
2443 \end_inset
2444
2445 /sdcc
2446 \begin_inset Quotes srd
2447 \end_inset
2448
2449  
2450 \backslash
2451
2452 \newline
2453 docdir=
2454 \begin_inset Quotes srd
2455 \end_inset
2456
2457
2458 \backslash
2459 ${datarootdir}/doc
2460 \begin_inset Quotes srd
2461 \end_inset
2462
2463  
2464 \backslash
2465
2466 \newline
2467 include_dir_suffix=
2468 \begin_inset Quotes srd
2469 \end_inset
2470
2471 include
2472 \begin_inset Quotes srd
2473 \end_inset
2474
2475  
2476 \backslash
2477
2478 \newline
2479 lib_dir_suffix=
2480 \begin_inset Quotes srd
2481 \end_inset
2482
2483 lib
2484 \begin_inset Quotes srd
2485 \end_inset
2486
2487  
2488 \backslash
2489
2490 \newline
2491 sdccconf_h_dir_separator=
2492 \begin_inset Quotes srd
2493 \end_inset
2494
2495
2496 \backslash
2497
2498 \backslash
2499
2500 \backslash
2501
2502 \backslash
2503
2504 \begin_inset Quotes srd
2505 \end_inset
2506
2507  
2508 \backslash
2509
2510 \newline
2511 -
2512 \begin_inset ERT
2513 status collapsed
2514
2515 \begin_layout Standard
2516
2517
2518 \backslash
2519 /
2520 \end_layout
2521
2522 \end_inset
2523
2524 -disable-device-lib
2525 \backslash
2526
2527 \newline
2528 -
2529 \begin_inset ERT
2530 status collapsed
2531
2532 \begin_layout Standard
2533
2534
2535 \backslash
2536 /
2537 \end_layout
2538
2539 \end_inset
2540
2541 -host=i586-mingw32msvc
2542 \backslash
2543
2544 \newline
2545 -
2546 \begin_inset ERT
2547 status collapsed
2548
2549 \begin_layout Standard
2550
2551
2552 \backslash
2553 /
2554 \end_layout
2555
2556 \end_inset
2557
2558 -build=unknown-unknown-linux-gnu
2559 \end_layout
2560
2561 \begin_layout Standard
2562 To 
2563 \begin_inset Quotes sld
2564 \end_inset
2565
2566 cross
2567 \begin_inset Quotes srd
2568 \end_inset
2569
2570 compile on Cygwin for Mingw32 (see also sdcc/support/scripts/sdcc_cygwin_mingw32
2571 ):
2572 \end_layout
2573
2574 \begin_layout LyX-Code
2575 ./configure -C 
2576 \backslash
2577
2578 \newline
2579 -
2580 \begin_inset ERT
2581 status collapsed
2582
2583 \begin_layout Standard
2584
2585
2586 \backslash
2587 /
2588 \end_layout
2589
2590 \end_inset
2591
2592 -prefix=
2593 \begin_inset Quotes srd
2594 \end_inset
2595
2596 /sdcc
2597 \begin_inset Quotes srd
2598 \end_inset
2599
2600  
2601 \backslash
2602
2603 \newline
2604 -
2605 \begin_inset ERT
2606 status collapsed
2607
2608 \begin_layout Standard
2609
2610
2611 \backslash
2612 /
2613 \end_layout
2614
2615 \end_inset
2616
2617 -datarootdir=
2618 \begin_inset Quotes srd
2619 \end_inset
2620
2621 /sdcc
2622 \begin_inset Quotes srd
2623 \end_inset
2624
2625  
2626 \backslash
2627
2628 \newline
2629 docdir=
2630 \begin_inset Quotes srd
2631 \end_inset
2632
2633
2634 \backslash
2635 ${datarootdir}/doc
2636 \begin_inset Quotes srd
2637 \end_inset
2638
2639  
2640 \backslash
2641  
2642 \newline
2643 include_dir_suffix=
2644 \begin_inset Quotes srd
2645 \end_inset
2646
2647 include
2648 \begin_inset Quotes srd
2649 \end_inset
2650
2651  
2652 \backslash
2653
2654 \newline
2655 lib_dir_suffix=
2656 \begin_inset Quotes srd
2657 \end_inset
2658
2659 lib
2660 \begin_inset Quotes srd
2661 \end_inset
2662
2663  
2664 \backslash
2665
2666 \newline
2667 sdccconf_h_dir_separator=
2668 \begin_inset Quotes srd
2669 \end_inset
2670
2671
2672 \backslash
2673
2674 \backslash
2675
2676 \backslash
2677
2678 \backslash
2679
2680 \begin_inset Quotes srd
2681 \end_inset
2682
2683  
2684 \backslash
2685
2686 \newline
2687 CC=
2688 \begin_inset Quotes srd
2689 \end_inset
2690
2691 gcc -mno-cygwin
2692 \begin_inset Quotes srd
2693 \end_inset
2694
2695  
2696 \backslash
2697
2698 \newline
2699 CXX=
2700 \begin_inset Quotes srd
2701 \end_inset
2702
2703 g++ -mno-cygwin
2704 \begin_inset Quotes srd
2705 \end_inset
2706
2707  
2708 \end_layout
2709
2710 \begin_layout Standard
2711 'configure' is quite slow on Cygwin (at least on windows before Win2000/XP).
2712  The option '-
2713 \begin_inset ERT
2714 status collapsed
2715
2716 \begin_layout Standard
2717
2718
2719 \backslash
2720 /
2721 \end_layout
2722
2723 \end_inset
2724
2725 -C' turns on caching, which gives a little bit extra speed.
2726  However if options are changed, it can be necessary to delete the config.cache
2727  file.
2728 \end_layout
2729
2730 \begin_layout Section
2731 Install paths
2732 \begin_inset LatexCommand \label{sub:Install-paths}
2733
2734 \end_inset
2735
2736
2737 \begin_inset LatexCommand \index{Install paths}
2738
2739 \end_inset
2740
2741
2742 \end_layout
2743
2744 \begin_layout Standard
2745 \begin_inset VSpace medskip
2746 \end_inset
2747
2748
2749 \end_layout
2750
2751 \begin_layout Standard
2752 \align center
2753 \begin_inset Tabular
2754 <lyxtabular version="3" rows="5" columns="4">
2755 <features>
2756 <column alignment="left" valignment="top" leftline="true" width="0">
2757 <column alignment="left" valignment="top" leftline="true" width="0">
2758 <column alignment="left" valignment="top" leftline="true" width="0">
2759 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
2760 <row topline="true" bottomline="true">
2761 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2762 \begin_inset Text
2763
2764 \begin_layout Standard
2765
2766 \series bold
2767 Description
2768 \end_layout
2769
2770 \end_inset
2771 </cell>
2772 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2773 \begin_inset Text
2774
2775 \begin_layout Standard
2776
2777 \series bold
2778 Path
2779 \end_layout
2780
2781 \end_inset
2782 </cell>
2783 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2784 \begin_inset Text
2785
2786 \begin_layout Standard
2787
2788 \series bold
2789 Default
2790 \end_layout
2791
2792 \end_inset
2793 </cell>
2794 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2795 \begin_inset Text
2796
2797 \begin_layout Standard
2798
2799 \series bold
2800 Win32 builds
2801 \end_layout
2802
2803 \end_inset
2804 </cell>
2805 </row>
2806 <row topline="true">
2807 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2808 \begin_inset Text
2809
2810 \begin_layout Standard
2811 Binary files*
2812 \end_layout
2813
2814 \end_inset
2815 </cell>
2816 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2817 \begin_inset Text
2818
2819 \begin_layout Standard
2820
2821 \emph on
2822 $EXEC_PREFIX
2823 \end_layout
2824
2825 \end_inset
2826 </cell>
2827 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2828 \begin_inset Text
2829
2830 \begin_layout Standard
2831 /usr/local/bin
2832 \end_layout
2833
2834 \end_inset
2835 </cell>
2836 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2837 \begin_inset Text
2838
2839 \begin_layout Standard
2840
2841 \backslash
2842 sdcc
2843 \backslash
2844 bin
2845 \end_layout
2846
2847 \end_inset
2848 </cell>
2849 </row>
2850 <row topline="true">
2851 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2852 \begin_inset Text
2853
2854 \begin_layout Standard
2855 Include files
2856 \end_layout
2857
2858 \end_inset
2859 </cell>
2860 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2861 \begin_inset Text
2862
2863 \begin_layout Standard
2864
2865 \emph on
2866 $DATADIR/ $INCLUDE_DIR_SUFFIX
2867 \end_layout
2868
2869 \end_inset
2870 </cell>
2871 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2872 \begin_inset Text
2873
2874 \begin_layout Standard
2875 /usr/local/share/sdcc/include
2876 \end_layout
2877
2878 \end_inset
2879 </cell>
2880 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2881 \begin_inset Text
2882
2883 \begin_layout Standard
2884
2885 \backslash
2886 sdcc
2887 \backslash
2888 include
2889 \end_layout
2890
2891 \end_inset
2892 </cell>
2893 </row>
2894 <row topline="true">
2895 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2896 \begin_inset Text
2897
2898 \begin_layout Standard
2899 Library file**
2900 \end_layout
2901
2902 \end_inset
2903 </cell>
2904 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2905 \begin_inset Text
2906
2907 \begin_layout Standard
2908
2909 \emph on
2910 $DATADIR/$LIB_DIR_SUFFIX
2911 \end_layout
2912
2913 \end_inset
2914 </cell>
2915 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2916 \begin_inset Text
2917
2918 \begin_layout Standard
2919 /usr/local/share/sdcc/lib
2920 \end_layout
2921
2922 \end_inset
2923 </cell>
2924 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2925 \begin_inset Text
2926
2927 \begin_layout Standard
2928
2929 \backslash
2930 sdcc
2931 \backslash
2932 lib
2933 \end_layout
2934
2935 \end_inset
2936 </cell>
2937 </row>
2938 <row topline="true" bottomline="true">
2939 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2940 \begin_inset Text
2941
2942 \begin_layout Standard
2943 Documentation
2944 \end_layout
2945
2946 \end_inset
2947 </cell>
2948 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2949 \begin_inset Text
2950
2951 \begin_layout Standard
2952
2953 \emph on
2954 $DOCDIR
2955 \end_layout
2956
2957 \end_inset
2958 </cell>
2959 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2960 \begin_inset Text
2961
2962 \begin_layout Standard
2963 /usr/local/share/sdcc/doc
2964 \end_layout
2965
2966 \end_inset
2967 </cell>
2968 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2969 \begin_inset Text
2970
2971 \begin_layout Standard
2972
2973 \backslash
2974 sdcc
2975 \backslash
2976 doc
2977 \end_layout
2978
2979 \end_inset
2980 </cell>
2981 </row>
2982 </lyxtabular>
2983
2984 \end_inset
2985
2986
2987 \end_layout
2988
2989 \begin_layout Verse
2990
2991 \size footnotesize
2992 *compiler, preprocessor, assembler, and linker
2993 \newline
2994 **the 
2995 \shape italic
2996 model
2997 \shape default
2998  is auto-appended by the compiler, e.g.
2999  small, large, z80, ds390 etc
3000 \end_layout
3001
3002 \begin_layout Standard
3003 \noindent
3004 The install paths can still be changed during `make install' with e.g.:
3005 \end_layout
3006
3007 \begin_layout LyX-Code
3008 make install prefix=$(HOME)/local/sdcc
3009 \end_layout
3010
3011 \begin_layout Standard
3012 Of course this doesn't change the search paths compiled into the binaries.
3013 \newline
3014
3015 \newline
3016 Moreove
3017 r the install path can be changed by defining DESTDIR
3018 \begin_inset LatexCommand \index{DESTDIR}
3019
3020 \end_inset
3021
3022 :
3023 \end_layout
3024
3025 \begin_layout LyX-Code
3026 make install DESTDIR=$(HOME)/sdcc.rpm/
3027 \end_layout
3028
3029 \begin_layout Standard
3030 Please note that DESTDIR must have a trailing slash!
3031 \end_layout
3032
3033 \begin_layout Section
3034 Search Paths
3035 \begin_inset LatexCommand \label{sub:Search-Paths}
3036
3037 \end_inset
3038
3039
3040 \begin_inset LatexCommand \index{Search path}
3041
3042 \end_inset
3043
3044
3045 \end_layout
3046
3047 \begin_layout Standard
3048 Some search paths or parts of them are determined by configure variables
3049  (in 
3050 \emph on
3051 italics
3052 \emph default
3053 , see section above).
3054  Further search paths are determined by environment variables during runtime.
3055  
3056 \newline
3057 The paths searched when running the compiler are as follows (the first
3058  catch wins):
3059 \newline
3060
3061 \newline
3062 1.
3063  Binary files (preprocessor, assembler and linker)
3064 \newline
3065
3066 \end_layout
3067
3068 \begin_layout Standard
3069 \align center
3070 \begin_inset Tabular
3071 <lyxtabular version="3" rows="4" columns="3">
3072 <features>
3073 <column alignment="block" valignment="top" leftline="true" width="0in">
3074 <column alignment="block" valignment="top" leftline="true" width="0in">
3075 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
3076 <row topline="true" bottomline="true">
3077 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3078 \begin_inset Text
3079
3080 \begin_layout Standard
3081 Search path
3082 \end_layout
3083
3084 \end_inset
3085 </cell>
3086 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3087 \begin_inset Text
3088
3089 \begin_layout Standard
3090 default
3091 \end_layout
3092
3093 \end_inset
3094 </cell>
3095 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3096 \begin_inset Text
3097
3098 \begin_layout Standard
3099 Win32 builds
3100 \end_layout
3101
3102 \end_inset
3103 </cell>
3104 </row>
3105 <row topline="true">
3106 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3107 \begin_inset Text
3108
3109 \begin_layout Standard
3110 $SDCC_HOME/
3111 \emph on
3112 $PPREFIX2BIN_DIR
3113 \end_layout
3114
3115 \end_inset
3116 </cell>
3117 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3118 \begin_inset Text
3119
3120 \begin_layout Standard
3121 $SDCC_HOME/bin
3122 \end_layout
3123
3124 \end_inset
3125 </cell>
3126 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3127 \begin_inset Text
3128
3129 \begin_layout Standard
3130 $SDCC_HOME
3131 \backslash
3132 bin
3133 \end_layout
3134
3135 \end_inset
3136 </cell>
3137 </row>
3138 <row topline="true">
3139 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3140 \begin_inset Text
3141
3142 \begin_layout Standard
3143 Path of argv[0] (if available)
3144 \end_layout
3145
3146 \end_inset
3147 </cell>
3148 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3149 \begin_inset Text
3150
3151 \begin_layout Standard
3152 Path of argv[0]
3153 \end_layout
3154
3155 \end_inset
3156 </cell>
3157 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3158 \begin_inset Text
3159
3160 \begin_layout Standard
3161 Path of argv[0]
3162 \end_layout
3163
3164 \end_inset
3165 </cell>
3166 </row>
3167 <row topline="true" bottomline="true">
3168 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3169 \begin_inset Text
3170
3171 \begin_layout Standard
3172 $PATH
3173 \end_layout
3174
3175 \end_inset
3176 </cell>
3177 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3178 \begin_inset Text
3179
3180 \begin_layout Standard
3181 $PATH
3182 \end_layout
3183
3184 \end_inset
3185 </cell>
3186 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3187 \begin_inset Text
3188
3189 \begin_layout Standard
3190 $PATH
3191 \end_layout
3192
3193 \end_inset
3194 </cell>
3195 </row>
3196 </lyxtabular>
3197
3198 \end_inset
3199
3200  
3201 \newline
3202
3203 \end_layout
3204
3205 \begin_layout Standard
3206 \noindent
3207 2.
3208  Include files
3209 \newline
3210
3211 \end_layout
3212
3213 \begin_layout Standard
3214 \align center
3215 \begin_inset Tabular
3216 <lyxtabular version="3" rows="6" columns="3">
3217 <features>
3218 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3219 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3220 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
3221 <row topline="true" bottomline="true">
3222 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3223 \begin_inset Text
3224
3225 \begin_layout Standard
3226 Search path
3227 \end_layout
3228
3229 \end_inset
3230 </cell>
3231 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3232 \begin_inset Text
3233
3234 \begin_layout Standard
3235 default
3236 \end_layout
3237
3238 \end_inset
3239 </cell>
3240 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3241 \begin_inset Text
3242
3243 \begin_layout Standard
3244 Win32 builds
3245 \end_layout
3246
3247 \end_inset
3248 </cell>
3249 </row>
3250 <row topline="true">
3251 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3252 \begin_inset Text
3253
3254 \begin_layout Standard
3255 -
3256 \begin_inset ERT
3257 status collapsed
3258
3259 \begin_layout Standard
3260
3261
3262 \backslash
3263 /
3264 \end_layout
3265
3266 \end_inset
3267
3268 -I dir
3269 \end_layout
3270
3271 \end_inset
3272 </cell>
3273 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3274 \begin_inset Text
3275
3276 \begin_layout Standard
3277 -
3278 \begin_inset ERT
3279 status collapsed
3280
3281 \begin_layout Standard
3282
3283
3284 \backslash
3285 /
3286 \end_layout
3287
3288 \end_inset
3289
3290 -I dir
3291 \end_layout
3292
3293 \end_inset
3294 </cell>
3295 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3296 \begin_inset Text
3297
3298 \begin_layout Standard
3299 -
3300 \begin_inset ERT
3301 status collapsed
3302
3303 \begin_layout Standard
3304
3305
3306 \backslash
3307 /
3308 \end_layout
3309
3310 \end_inset
3311
3312 -I dir
3313 \end_layout
3314
3315 \end_inset
3316 </cell>
3317 </row>
3318 <row topline="true">
3319 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3320 \begin_inset Text
3321
3322 \begin_layout Standard
3323 $SDCC_INCLUDE
3324 \end_layout
3325
3326 \end_inset
3327 </cell>
3328 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3329 \begin_inset Text
3330
3331 \begin_layout Standard
3332 $SDCC_INCLUDE
3333 \end_layout
3334
3335 \end_inset
3336 </cell>
3337 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3338 \begin_inset Text
3339
3340 \begin_layout Standard
3341 $SDCC_INCLUDE
3342 \end_layout
3343
3344 \end_inset
3345 </cell>
3346 </row>
3347 <row topline="true">
3348 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3349 \begin_inset Text
3350
3351 \begin_layout Standard
3352 $SDCC_HOME/
3353 \newline
3354
3355 \emph on
3356 $PREFIX2DATA_DIR/
3357 \newline
3358 $INCLUDE_DIR_SUFFIX
3359 \end_layout
3360
3361 \end_inset
3362 </cell>
3363 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3364 \begin_inset Text
3365
3366 \begin_layout Standard
3367 $SDCC_ HOME/
3368 \newline
3369 share/sdcc/
3370 \newline
3371 include
3372 \end_layout
3373
3374 \end_inset
3375 </cell>
3376 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3377 \begin_inset Text
3378
3379 \begin_layout Standard
3380 $SDCC_HOME
3381 \backslash
3382 include
3383 \end_layout
3384
3385 \end_inset
3386 </cell>
3387 </row>
3388 <row topline="true">
3389 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3390 \begin_inset Text
3391
3392 \begin_layout Standard
3393 path(argv[0])/
3394 \newline
3395
3396 \emph on
3397 $BIN2DATADIR/
3398 \emph default
3399
3400 \newline
3401
3402 \emph on
3403 $INCLUDE_DIR_SUFFIX
3404 \end_layout
3405
3406 \end_inset
3407 </cell>
3408 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3409 \begin_inset Text
3410
3411 \begin_layout Standard
3412 path(argv[0])/
3413 \newline
3414 ../sdcc/include
3415 \newline
3416 \InsetSpace ~
3417 \InsetSpace ~
3418 \InsetSpace ~
3419 \InsetSpace ~
3420 \InsetSpace ~
3421 \InsetSpace ~
3422 \InsetSpace ~
3423 \InsetSpace ~
3424 \InsetSpace ~
3425 \InsetSpace ~
3426 \InsetSpace ~
3427 \InsetSpace ~
3428 \InsetSpace ~
3429 \InsetSpace ~
3430 \InsetSpace ~
3431 \InsetSpace ~
3432 \InsetSpace ~
3433 \InsetSpace ~
3434 \InsetSpace ~
3435 \InsetSpace ~
3436 \InsetSpace ~
3437 \InsetSpace ~
3438 \InsetSpace ~
3439 \InsetSpace ~
3440 \InsetSpace ~
3441 \InsetSpace ~
3442 \InsetSpace ~
3443 \InsetSpace ~
3444 \InsetSpace ~
3445 \InsetSpace ~
3446 \InsetSpace ~
3447 \InsetSpace ~
3448 \InsetSpace ~
3449 \InsetSpace ~
3450 \InsetSpace ~
3451 \InsetSpace ~
3452 \InsetSpace ~
3453 \InsetSpace ~
3454
3455 \end_layout
3456
3457 \end_inset
3458 </cell>
3459 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3460 \begin_inset Text
3461
3462 \begin_layout Standard
3463 path(argv[0])
3464 \backslash
3465 ..
3466 \backslash
3467 include
3468 \end_layout
3469
3470 \end_inset
3471 </cell>
3472 </row>
3473 <row topline="true" bottomline="true">
3474 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3475 \begin_inset Text
3476
3477 \begin_layout Standard
3478
3479 \emph on
3480 $DATADIR/
3481 \emph default
3482
3483 \newline
3484
3485 \emph on
3486 $INCLUDE_DIR_SUFFIX
3487 \end_layout
3488
3489 \end_inset
3490 </cell>
3491 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3492 \begin_inset Text
3493
3494 \begin_layout Standard
3495 /usr/local/share/sdcc/
3496 \newline
3497 include
3498 \end_layout
3499
3500 \end_inset
3501 </cell>
3502 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3503 \begin_inset Text
3504
3505 \begin_layout Standard
3506 (not on Win32)
3507 \end_layout
3508
3509 \end_inset
3510 </cell>
3511 </row>
3512 </lyxtabular>
3513
3514 \end_inset
3515
3516  
3517 \newline
3518
3519 \end_layout
3520
3521 \begin_layout Standard
3522 \noindent
3523 The option -
3524 \begin_inset ERT
3525 status collapsed
3526
3527 \begin_layout Standard
3528
3529
3530 \backslash
3531 /
3532 \end_layout
3533
3534 \end_inset
3535
3536 -nostdinc disables the last two search paths.
3537 \newline
3538
3539 \newline
3540 3.
3541  Library files 
3542 \newline
3543
3544 \end_layout
3545
3546 \begin_layout Standard
3547 With the exception of 
3548 \begin_inset Quotes sld
3549 \end_inset
3550
3551 -
3552 \begin_inset ERT
3553 status collapsed
3554
3555 \begin_layout Standard
3556
3557
3558 \backslash
3559 /
3560 \end_layout
3561
3562 \end_inset
3563
3564 -L dir
3565 \begin_inset Quotes srd
3566 \end_inset
3567
3568  the 
3569 \shape italic
3570 model
3571 \shape default
3572  is auto-appended by the compiler (e.g.
3573  small, large, z80, ds390 etc.).
3574  
3575 \newline
3576
3577 \end_layout
3578
3579 \begin_layout Standard
3580 \align center
3581 \begin_inset Tabular
3582 <lyxtabular version="3" rows="6" columns="3">
3583 <features>
3584 <column alignment="block" valignment="top" leftline="true" width="1.7in">
3585 <column alignment="block" valignment="top" leftline="true" width="1.2in">
3586 <column alignment="block" valignment="top" leftline="true" rightline="true" width="1.2in">
3587 <row topline="true" bottomline="true">
3588 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3589 \begin_inset Text
3590
3591 \begin_layout Standard
3592 Search path
3593 \end_layout
3594
3595 \end_inset
3596 </cell>
3597 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3598 \begin_inset Text
3599
3600 \begin_layout Standard
3601 default
3602 \end_layout
3603
3604 \end_inset
3605 </cell>
3606 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3607 \begin_inset Text
3608
3609 \begin_layout Standard
3610 Win32 builds
3611 \end_layout
3612
3613 \end_inset
3614 </cell>
3615 </row>
3616 <row topline="true">
3617 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3618 \begin_inset Text
3619
3620 \begin_layout Standard
3621 -
3622 \begin_inset ERT
3623 status collapsed
3624
3625 \begin_layout Standard
3626
3627
3628 \backslash
3629 /
3630 \end_layout
3631
3632 \end_inset
3633
3634 -L dir
3635 \end_layout
3636
3637 \end_inset
3638 </cell>
3639 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3640 \begin_inset Text
3641
3642 \begin_layout Standard
3643 -
3644 \begin_inset ERT
3645 status collapsed
3646
3647 \begin_layout Standard
3648
3649
3650 \backslash
3651 /
3652 \end_layout
3653
3654 \end_inset
3655
3656 -L dir
3657 \end_layout
3658
3659 \end_inset
3660 </cell>
3661 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3662 \begin_inset Text
3663
3664 \begin_layout Standard
3665 -
3666 \begin_inset ERT
3667 status collapsed
3668
3669 \begin_layout Standard
3670
3671
3672 \backslash
3673 /
3674 \end_layout
3675
3676 \end_inset
3677
3678 -L dir
3679 \end_layout
3680
3681 \end_inset
3682 </cell>
3683 </row>
3684 <row topline="true">
3685 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3686 \begin_inset Text
3687
3688 \begin_layout Standard
3689 $SDCC_LIB/
3690 \newline
3691
3692 \emph on
3693 <model>
3694 \end_layout
3695
3696 \end_inset
3697 </cell>
3698 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3699 \begin_inset Text
3700
3701 \begin_layout Standard
3702 $SDCC_LIB/
3703 \newline
3704
3705 \emph on
3706 <model>
3707 \end_layout
3708
3709 \end_inset
3710 </cell>
3711 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3712 \begin_inset Text
3713
3714 \begin_layout Standard
3715 $SDCC_LIB
3716 \backslash
3717
3718 \newline
3719
3720 \emph on
3721 <model>
3722 \end_layout
3723
3724 \end_inset
3725 </cell>
3726 </row>
3727 <row topline="true">
3728 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3729 \begin_inset Text
3730
3731 \begin_layout Standard
3732 $SDCC_HOME/
3733 \newline
3734
3735 \emph on
3736 $PREFIX2DATA_DIR/
3737 \newline
3738 $LIB_DIR_SUFFIX/<model>
3739 \end_layout
3740
3741 \end_inset
3742 </cell>
3743 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3744 \begin_inset Text
3745
3746 \begin_layout Standard
3747 $SDCC_HOME/
3748 \newline
3749 share/sdcc/
3750 \newline
3751 lib/
3752 \emph on
3753 <model>
3754 \end_layout
3755
3756 \end_inset
3757 </cell>
3758 <cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3759 \begin_inset Text
3760
3761 \begin_layout Standard
3762 $SDCC_HOME
3763 \backslash
3764 lib
3765 \backslash
3766
3767 \emph on
3768
3769 \newline
3770 <model>
3771 \end_layout
3772
3773 \end_inset
3774 </cell>
3775 </row>
3776 <row topline="true">
3777 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3778 \begin_inset Text
3779
3780 \begin_layout Standard
3781 path(argv[0])/
3782 \newline
3783
3784 \emph on
3785 $BIN2DATADIR/
3786 \emph default
3787
3788 \newline
3789
3790 \emph on
3791 $LIB_DIR_SUFFIX/<model>
3792 \end_layout
3793
3794 \end_inset
3795 </cell>
3796 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3797 \begin_inset Text
3798
3799 \begin_layout Standard
3800 path(argv[0])/
3801 \newline
3802 ../sdcc/lib/
3803 \emph on
3804 <model>
3805 \newline
3806 \InsetSpace ~
3807 \InsetSpace ~
3808 \InsetSpace ~
3809 \InsetSpace ~
3810 \InsetSpace ~
3811 \InsetSpace ~
3812 \InsetSpace ~
3813 \InsetSpace ~
3814 \InsetSpace ~
3815 \InsetSpace ~
3816 \InsetSpace ~
3817 \InsetSpace ~
3818 \InsetSpace ~
3819 \InsetSpace ~
3820 \InsetSpace ~
3821 \InsetSpace ~
3822 \InsetSpace ~
3823 \InsetSpace ~
3824 \InsetSpace ~
3825 \InsetSpace ~
3826 \InsetSpace ~
3827 \InsetSpace ~
3828 \InsetSpace ~
3829 \InsetSpace ~
3830 \InsetSpace ~
3831 \InsetSpace ~
3832 \InsetSpace ~
3833 \InsetSpace ~
3834 \InsetSpace ~
3835 \InsetSpace ~
3836 \InsetSpace ~
3837 \InsetSpace ~
3838 \InsetSpace ~
3839 \InsetSpace ~
3840 \InsetSpace ~
3841 \InsetSpace ~
3842 \InsetSpace ~
3843 \InsetSpace ~
3844 \InsetSpace ~
3845
3846 \end_layout
3847
3848 \end_inset
3849 </cell>
3850 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3851 \begin_inset Text
3852
3853 \begin_layout Standard
3854 path(argv[0])
3855 \backslash
3856
3857 \newline
3858 ..
3859 \backslash
3860 lib
3861 \backslash
3862
3863 \emph on
3864 <model>
3865 \newline
3866 \InsetSpace ~
3867 \InsetSpace ~
3868 \InsetSpace ~
3869 \InsetSpace ~
3870 \InsetSpace ~
3871 \InsetSpace ~
3872 \InsetSpace ~
3873 \InsetSpace ~
3874 \InsetSpace ~
3875 \InsetSpace ~
3876 \InsetSpace ~
3877 \InsetSpace ~
3878 \InsetSpace ~
3879 \InsetSpace ~
3880 \InsetSpace ~
3881 \InsetSpace ~
3882 \InsetSpace ~
3883 \InsetSpace ~
3884 \InsetSpace ~
3885 \InsetSpace ~
3886 \InsetSpace ~
3887 \InsetSpace ~
3888 \InsetSpace ~
3889 \InsetSpace ~
3890 \InsetSpace ~
3891 \InsetSpace ~
3892 \InsetSpace ~
3893 \InsetSpace ~
3894 \InsetSpace ~
3895 \InsetSpace ~
3896 \InsetSpace ~
3897 \InsetSpace ~
3898 \InsetSpace ~
3899 \InsetSpace ~
3900 \InsetSpace ~
3901
3902 \end_layout
3903
3904 \end_inset
3905 </cell>
3906 </row>
3907 <row topline="true" bottomline="true">
3908 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3909 \begin_inset Text
3910
3911 \begin_layout Standard
3912
3913 \emph on
3914 $DATADIR/
3915 \newline
3916 $LIB_DIR_SUFFIX/<model>
3917 \end_layout
3918
3919 \end_inset
3920 </cell>
3921 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3922 \begin_inset Text
3923
3924 \begin_layout Standard
3925 /usr/local/share/sdcc/
3926 \newline
3927 lib/
3928 \emph on
3929 <model>
3930 \end_layout
3931
3932 \end_inset
3933 </cell>
3934 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3935 \begin_inset Text
3936
3937 \begin_layout Standard
3938 (not on Win32)
3939 \end_layout
3940
3941 \end_inset
3942 </cell>
3943 </row>
3944 </lyxtabular>
3945
3946 \end_inset
3947
3948
3949 \newline
3950
3951 \end_layout
3952
3953 \begin_layout Standard
3954 \begin_inset Note Note
3955 status collapsed
3956
3957 \begin_layout Standard
3958 Don't delete any of the stray spaces in the table above without checking
3959  the HTML output (last line)!
3960 \end_layout
3961
3962 \end_inset
3963
3964
3965 \end_layout
3966
3967 \begin_layout Standard
3968 \InsetSpace ~
3969
3970 \newline
3971 The option -
3972 \begin_inset ERT
3973 status collapsed
3974
3975 \begin_layout Standard
3976
3977
3978 \backslash
3979 /
3980 \end_layout
3981
3982 \end_inset
3983
3984 -nostdlib disables the last two search paths.
3985 \end_layout
3986
3987 \begin_layout Section
3988 Building SDCC
3989 \begin_inset LatexCommand \index{Building SDCC}
3990
3991 \end_inset
3992
3993
3994 \end_layout
3995
3996 \begin_layout Subsection
3997 Building SDCC on Linux
3998 \begin_inset LatexCommand \label{sub:Building-SDCC-on-Linux}
3999
4000 \end_inset
4001
4002
4003 \end_layout
4004
4005 \begin_layout Enumerate
4006
4007 \series medium
4008 Download the source package
4009 \series default
4010  either from the SDCC Subversion repository or from snapshot builds
4011 \series medium
4012 , it will be named something like sdcc
4013 \series default
4014 -src
4015 \series medium
4016 -yyyymmdd-rrrr.t
4017 \series default
4018 ar.
4019 \series medium
4020 bz2
4021 \series default
4022  
4023 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
4024
4025 \end_inset
4026
4027 .
4028 \end_layout
4029
4030 \begin_layout Enumerate
4031
4032 \series medium
4033 Bring up a command line terminal, such as xterm.
4034 \end_layout
4035
4036 \begin_layout Enumerate
4037
4038 \series medium
4039 Unpack the file using a command like: 
4040 \family sans
4041 \series bold
4042 "tar -xvzf sdcc-src-yyyymmdd-rrrr.tar.bz2
4043 \begin_inset Quotes srd
4044 \end_inset
4045
4046
4047 \family default
4048 \series medium
4049 , this will create a sub-directory called sdcc with all of the sources.
4050 \end_layout
4051
4052 \begin_layout Enumerate
4053 Change directory into the main SDCC directory, for example type: 
4054 \family sans
4055 \series bold
4056 "cd sdcc
4057 \series default
4058 ".
4059 \end_layout
4060
4061 \begin_layout Enumerate
4062
4063 \series medium
4064 Type 
4065 \family sans
4066 \series bold
4067 "./configure
4068 \family default
4069 \series default
4070 ".
4071  This configures the package for compilation on your system.
4072 \end_layout
4073
4074 \begin_layout Enumerate
4075
4076 \series medium
4077 Type 
4078 \family sans
4079 \series bold
4080 "make
4081 \family default
4082 \series default
4083 "
4084 \series medium
4085 .
4086
4087 \series default
4088  All of the source packages will compile, this can take a while.
4089 \end_layout
4090
4091 \begin_layout Enumerate
4092
4093 \series medium
4094 Type 
4095 \family sans
4096 \series bold
4097 "make install"
4098 \family default
4099 \series default
4100  as root
4101 \series medium
4102 .
4103
4104 \series default
4105  This copies the binary executables, the include files, the libraries and
4106  the documentation to the install directories.
4107  Proceed with section 
4108 \begin_inset LatexCommand \ref{sec:Testing-the-SDCC}
4109
4110 \end_inset
4111
4112 .
4113 \end_layout
4114
4115 \begin_layout Subsection
4116 Building SDCC on Mac OS X
4117 \end_layout
4118
4119 \begin_layout Standard
4120 Follow the instruction for Linux.
4121 \newline
4122
4123 \newline
4124 On Mac OS X 10.2.x it was reported, that the
4125  default gcc (version 3.1 20020420 (prerelease)) fails to compile SDCC.
4126  Fortunately there's also gcc 2.9.x installed, which works fine.
4127  This compiler can be selected by running 'configure' with:
4128 \end_layout
4129
4130 \begin_layout LyX-Code
4131 ./configure CC=gcc2 CXX=g++2
4132 \end_layout
4133
4134 \begin_layout Standard
4135 Universal (ppc and i386) binaries can be produced on Mac OS X 10.4.x with
4136  Xcode.
4137  Run 'configure' with:
4138 \end_layout
4139
4140 \begin_layout LyX-Code
4141 ./configure 
4142 \backslash
4143
4144 \end_layout
4145
4146 \begin_layout LyX-Code
4147 LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
4148  ppc" 
4149 \backslash
4150
4151 \end_layout
4152
4153 \begin_layout LyX-Code
4154 CXXFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
4155  ppc" 
4156 \backslash
4157
4158 \end_layout
4159
4160 \begin_layout LyX-Code
4161 CFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
4162 \end_layout
4163
4164 \begin_layout Subsection
4165 Cross compiling SDCC on Linux for Windows
4166 \end_layout
4167
4168 \begin_layout Standard
4169 With the Mingw32 gcc cross compiler it's easy to compile SDCC for Win32.
4170  See section 'Configure Options'.
4171 \end_layout
4172
4173 \begin_layout Subsection
4174 Building SDCC using Cygwin and Mingw32
4175 \end_layout
4176
4177 \begin_layout Standard
4178 For building and installing a Cygwin executable follow the instructions
4179  for Linux.
4180 \newline
4181
4182 \newline
4183 On Cygwin a 
4184 \begin_inset Quotes sld
4185 \end_inset
4186
4187 native
4188 \begin_inset Quotes srd
4189 \end_inset
4190
4191  Win32-binary can be built, which will not need the Cygwin-DLL.
4192  For the necessary 'configure' options see section 'configure options' or
4193  the script 'sdcc/support/scripts/sdcc_cygwin_mingw32'.
4194 \newline
4195
4196 \newline
4197 In order to install
4198  Cygwin on Windows download setup.exe from 
4199 \begin_inset LatexCommand \url[www.cygwin.com]{http://www.cygwin.com/}
4200
4201 \end_inset
4202
4203 .
4204  Run it, set the 
4205 \begin_inset Quotes sld
4206 \end_inset
4207
4208 default text file type
4209 \begin_inset Quotes srd
4210 \end_inset
4211
4212  to 
4213 \begin_inset Quotes sld
4214 \end_inset
4215
4216 unix
4217 \begin_inset Quotes srd
4218 \end_inset
4219
4220  and download/install at least the following packages.
4221  Some packages are selected by default, others will be automatically selected
4222  because of dependencies with the manually selected packages.
4223  Never deselect these packages!
4224 \end_layout
4225
4226 \begin_layout Itemize
4227 flex
4228 \end_layout
4229
4230 \begin_layout Itemize
4231 bison
4232 \end_layout
4233
4234 \begin_layout Itemize
4235 gcc ; version 3.x is fine, no need to use the old 2.9x
4236 \end_layout
4237
4238 \begin_layout Itemize
4239 binutils ; selected with gcc
4240 \end_layout
4241
4242 \begin_layout Itemize
4243 make
4244 \end_layout
4245
4246 \begin_layout Itemize
4247 rxvt ; a nice console, which makes life much easier under windoze (see below)
4248 \end_layout
4249
4250 \begin_layout Itemize
4251 man ; not really needed for building SDCC, but you'll miss it sooner or
4252  later
4253 \end_layout
4254
4255 \begin_layout Itemize
4256 less ; not really needed for building SDCC, but you'll miss it sooner or
4257  later
4258 \end_layout
4259
4260 \begin_layout Itemize
4261 svn ; only if you use Subversion access
4262 \end_layout
4263
4264 \begin_layout Standard
4265 If you want to develop something you'll need:
4266 \end_layout
4267
4268 \begin_layout Itemize
4269 python ; for the regression tests
4270 \end_layout
4271
4272 \begin_layout Itemize
4273 gdb ; the gnu debugger, together with the nice GUI 
4274 \begin_inset Quotes sld
4275 \end_inset
4276
4277 insight
4278 \begin_inset Quotes srd
4279 \end_inset
4280
4281
4282 \end_layout
4283
4284 \begin_layout Itemize
4285 openssh ; to access the CF or commit changes
4286 \end_layout
4287
4288 \begin_layout Itemize
4289 autoconf and autoconf-devel ; if you want to fight with 'configure', don't
4290  use autoconf-stable!
4291 \end_layout
4292
4293 \begin_layout Standard
4294 rxvt is a nice console with history.
4295  Replace in your cygwin.bat the line
4296 \end_layout
4297
4298 \begin_layout LyX-Code
4299 bash -
4300 \begin_inset ERT
4301 status collapsed
4302
4303 \begin_layout Standard
4304
4305
4306 \backslash
4307 /
4308 \end_layout
4309
4310 \end_inset
4311
4312 -login -i 
4313 \end_layout
4314
4315 \begin_layout Standard
4316 with (one line):
4317 \end_layout
4318
4319 \begin_layout LyX-Code
4320 rxvt -sl 1000 -fn "Lucida Console-12" -sr -cr red
4321 \end_layout
4322
4323 \begin_layout LyX-Code
4324      -bg black -fg white -geometry 100x65 -e bash -
4325 \begin_inset ERT
4326 status collapsed
4327
4328 \begin_layout Standard
4329
4330
4331 \backslash
4332 /
4333 \end_layout
4334
4335 \end_inset
4336
4337 -login
4338 \end_layout
4339
4340 \begin_layout Standard
4341 Text selected with the mouse is automatically copied to the clipboard, pasting
4342  works with shift-insert.
4343 \newline
4344
4345 \newline
4346 The other good tip is to make sure you have no //c/-styl
4347 e paths anywhere, use /cygdrive/c/ instead.
4348  Using // invokes a network lookup which is very slow.
4349  If you think 
4350 \begin_inset Quotes sld
4351 \end_inset
4352
4353 cygdrive
4354 \begin_inset Quotes srd
4355 \end_inset
4356
4357  is too long, you can change it with e.g.
4358 \end_layout
4359
4360 \begin_layout LyX-Code
4361 mount -s -u -c /mnt
4362 \end_layout
4363
4364 \begin_layout Standard
4365 SDCC sources use the unix line ending LF.
4366  Life is much easier, if you store the source tree on a drive which is mounted
4367  in binary mode.
4368  And use an editor which can handle LF-only line endings.
4369  Make sure not to commit files with windows line endings.
4370  The tabulator spacing
4371 \begin_inset LatexCommand \index{tabulator spacing (8 columns)}
4372
4373 \end_inset
4374
4375  used in the project is 8.
4376  Although a tabulator spacing of 8 is a sensible choice for programmers
4377  (it's a power of 2 and allows to display 8/16 bit signed variables without
4378  loosing columns) the plan is to move towards using only spaces in the source.
4379 \end_layout
4380
4381 \begin_layout Subsection
4382 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)
4383 \end_layout
4384
4385 \begin_layout Standard
4386
4387 \series medium
4388 Download the source package
4389 \series default
4390  either from the SDCC Subversion repository or from the 
4391 \begin_inset LatexCommand \url[snapshot builds]{http://sdcc.sourceforge.net/snap.php}
4392
4393 \end_inset
4394
4395
4396 \series medium
4397 , it will be named something like sdcc
4398 \series default
4399 -src
4400 \series medium
4401 -yyyymmdd-rrrr.tar.bz2.
4402
4403 \series default
4404  SDCC is distributed with all the projects, workspaces, and files you need
4405  to build it using Visual C++ 6.0/NET (except for SDCDB and ucSim).
4406  The workspace name is 'sdcc.dsw'.
4407  Please note that as it is now, all the executables are created in a folder
4408  called sdcc
4409 \backslash
4410 bin_vc.
4411  Once built you need to copy the executables from sdcc
4412 \backslash
4413 bin_vc to sdcc
4414 \backslash
4415 bin before running SDCC.
4416  
4417 \newline
4418
4419 \newline
4420 WARNING: Visual studio is very picky with line terminations; it expects
4421  the 0x0d, 0x0a DOS style line endings, not the 0x0a Unix style line endings.
4422  When using the Subversion repository it's easiest to configure the svn
4423  client to convert automatically for you.
4424  If however you are getting a message such as "This makefile was not generated
4425  by Developer Studio etc.
4426  etc.
4427 \begin_inset Quotes srd
4428 \end_inset
4429
4430  when opening the sdcc.dsw workspace or any of the *.dsp projects, then you
4431  need to convert the Unix style line endings to DOS style line endings.
4432  To do so you can use the 
4433 \begin_inset Quotes sld
4434 \end_inset
4435
4436 unix2dos
4437 \begin_inset Quotes srd
4438 \end_inset
4439
4440  utility freely available on the internet.
4441  Doug Hawkins reported in the sdcc-user list that this works:
4442 \newline
4443
4444 \newline
4445 C:
4446 \backslash
4447 Programming
4448 \backslash
4449 SDCC> unix2dos sdcc.dsw
4450 \newline
4451 C:
4452 \backslash
4453 Programming
4454 \backslash
4455 SDCC> for /R %I in (*.dsp) do @unix2dos "%I"
4456 \newline
4457
4458 \newline
4459 In order to build SDCC with MSVC
4460  you need win32 executables of bison.exe, flex.exe, and gawk.exe.
4461  One good place to get them is 
4462 \begin_inset LatexCommand \url[here]{http://unxutils.sourceforge.net}
4463
4464 \end_inset
4465
4466
4467 \newline
4468
4469 \newline
4470 Download the file UnxUtils
4471 \begin_inset LatexCommand \index{UnxUtils}
4472
4473 \end_inset
4474
4475 .zip.
4476  Now you have to install the utilities and setup MSVC so it can locate the
4477  required programs.
4478  Here there are two alternatives (choose one!):
4479 \end_layout
4480
4481 \begin_layout Enumerate
4482 The easy way:
4483 \newline
4484
4485 \newline
4486 a) Extract UnxUtils.zip to your C:
4487 \backslash
4488  hard disk PRESERVING the original paths, otherwise bison won't work.
4489  (If you are using WinZip make certain that 'Use folder names' is selected)
4490 \newline
4491
4492 \newline
4493 b)
4494  In the Visual C++ IDE click Tools, Options, select the Directory tab, in
4495  'Show directories for:' select 'Executable files', and in the directories
4496  window add a new path: 'C:
4497 \backslash
4498 user
4499 \backslash
4500 local
4501 \backslash
4502 wbin', click ok.
4503 \newline
4504
4505 \newline
4506 (As a side effect, you get a bunch of Unix utilities that
4507  could be useful, such as diff and patch.)
4508 \end_layout
4509
4510 \begin_layout Enumerate
4511 A more compact way:
4512 \newline
4513
4514 \newline
4515 This one avoids extracting a bunch of files you may not
4516  use, but requires some extra work:
4517 \newline
4518
4519 \newline
4520 a) Create a directory were to put the
4521  tools needed, or use a directory already present.
4522  Say for example 'C:
4523 \backslash
4524 util'.
4525 \newline
4526
4527 \newline
4528 b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and
4529  gawk.exe to such directory WITHOUT preserving the original paths.
4530  (If you are using WinZip make certain that 'Use folder names' is not selected)
4531 \newline
4532
4533 \newline
4534 c
4535 ) Rename bison.exe to '_bison.exe'.
4536 \newline
4537
4538 \newline
4539 d) Create a batch file 'bison.bat' in 'C:
4540 \backslash
4541 util
4542 \backslash
4543 ' and add these lines: 
4544 \newline
4545 \InsetSpace ~
4546 \InsetSpace ~
4547 set BISON_SIMPLE=C:
4548 \backslash
4549 util
4550 \backslash
4551 bison.simple 
4552 \newline
4553 \InsetSpace ~
4554 \InsetSpace ~
4555 set BISON_HAIRY=C:
4556 \backslash
4557 util
4558 \backslash
4559 bison.hairy
4560 \newline
4561 \InsetSpace ~
4562 \InsetSpace ~
4563 _bison %1 %2 %3 %4 %5 %6 %7 %8 %9
4564 \newline
4565
4566 \newline
4567 Steps 'c' and 'd' are needed
4568  because bison requires by default that the files 'bison.simple' and 'bison.hairy'
4569  reside in some weird Unix directory, '/usr/local/share/' I think.
4570  So it is necessary to tell bison where those files are located if they
4571  are not in such directory.
4572  That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.
4573 \newline
4574
4575 \newline
4576 e
4577 ) In the Visual C++ IDE click Tools, Options, select the Directory tab,
4578  in 'Show directories for:' select 'Executable files', and in the directories
4579  window add a new path: 'c:
4580 \backslash
4581 util', click ok.
4582  Note that you can use any other path instead of 'c:
4583 \backslash
4584 util', even the path where the Visual C++ tools are, probably: 'C:
4585 \backslash
4586 Program Files
4587 \backslash
4588 Microsoft Visual Studio
4589 \backslash
4590 Common
4591 \backslash
4592 Tools'.
4593  So you don't have to execute step 'e' :)
4594 \end_layout
4595
4596 \begin_layout Standard
4597 That is it.
4598  Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy
4599  the executables from sdcc
4600 \backslash
4601 bin_vc to sdcc
4602 \backslash
4603 bin, and you can compile using SDCC.
4604 \end_layout
4605
4606 \begin_layout Subsection
4607 Building SDCC Using Borland
4608 \end_layout
4609
4610 \begin_layout Enumerate
4611 From the sdcc directory, run the command "make -f Makefile.bcc".
4612  This should regenerate all the .exe files in the bin directory except for
4613  SDCDB and ucSim.
4614 \end_layout
4615
4616 \begin_layout Enumerate
4617 If you modify any source files and need to rebuild, be aware that the dependenci
4618 es may not be correctly calculated.
4619  The safest option is to delete all .obj files and run the build again.
4620  From a Cygwin BASH prompt, this can easily be done with the command (be
4621  sure you are in the sdcc directory):
4622 \newline
4623
4624 \newline
4625
4626 \family sans
4627 \series bold
4628 find .
4629  
4630 \backslash
4631 ( -name '*.obj' -o -name '*.lib' -o -name '*.rul' 
4632 \backslash
4633 ) -print -exec rm {} 
4634 \backslash
4635 ;
4636 \family default
4637 \series default
4638
4639 \newline
4640
4641 \newline
4642 or on Windows NT/2000/XP from the command prompt with the command:
4643 \newline
4644
4645 \family sans
4646 \series bold
4647
4648 \newline
4649 del /s *.obj *.lib *.rul
4650 \family default
4651 \series default
4652  from the sdcc directory.
4653 \end_layout
4654
4655 \begin_layout Subsection
4656 Windows Install Using a ZIP Package
4657 \end_layout
4658
4659 \begin_layout Enumerate
4660 Download the binary zip package from 
4661 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4662
4663 \end_inset
4664
4665  and unpack it using your favorite unpacking tool (gunzip, WinZip, etc).
4666  This should unpack to a group of sub-directories.
4667  An example directory structure after unpacking the mingw32 package is:
4668  c:
4669 \backslash
4670 sdcc
4671 \backslash
4672 bin for the executables, c:
4673 \backslash
4674 sdcc
4675 \backslash
4676 include and c:
4677 \backslash
4678 sdcc
4679 \backslash
4680 lib for the include and libraries.
4681 \end_layout
4682
4683 \begin_layout Enumerate
4684 Adjust your environment variable PATH to include the location of the bin
4685  directory or start sdcc using the full path.
4686 \end_layout
4687
4688 \begin_layout Subsection
4689 Windows Install Using the Setup Program
4690 \begin_inset LatexCommand \label{sub:Windows-Install}
4691
4692 \end_inset
4693
4694
4695 \end_layout
4696
4697 \begin_layout Standard
4698 Download the setup program 
4699 \emph on
4700 sdcc-x.y.z-setup.exe
4701 \emph default
4702  for an official release from 
4703 \newline
4704
4705 \begin_inset LatexCommand \url{http://sf.net/project/showfiles.php?group_id=599}
4706
4707 \end_inset
4708
4709  or a setup program for one of the snapshots 
4710 \emph on
4711 sdcc-yyyymmdd-xxxx-setup.exe
4712 \emph default
4713  from 
4714 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4715
4716 \end_inset
4717
4718  and execute it.
4719  A windows typical installer will guide you through the installation process.
4720 \end_layout
4721
4722 \begin_layout Subsection
4723 VPATH
4724 \begin_inset LatexCommand \index{VPATH}
4725
4726 \end_inset
4727
4728  feature
4729 \end_layout
4730
4731 \begin_layout Standard
4732 SDCC supports the VPATH feature provided by configure and make.
4733  It allows to separate the source and build trees.
4734  Here's an example:
4735 \end_layout
4736
4737 \begin_layout Standard
4738
4739 \family typewriter
4740 cd ~\InsetSpace ~
4741 \InsetSpace ~
4742 \InsetSpace ~
4743 \InsetSpace ~
4744 \InsetSpace ~
4745 \InsetSpace ~
4746 \InsetSpace ~
4747 \InsetSpace ~
4748 \InsetSpace ~
4749 \InsetSpace ~
4750 \InsetSpace ~
4751 \InsetSpace ~
4752 \InsetSpace ~
4753 \InsetSpace ~
4754 \InsetSpace ~
4755 \InsetSpace ~
4756 \InsetSpace ~
4757 \InsetSpace ~
4758 \InsetSpace ~
4759 \InsetSpace ~
4760 \InsetSpace ~
4761 # cd $HOME
4762 \end_layout
4763
4764 \begin_layout Standard
4765
4766 \family typewriter
4767 tar -xzf sdcc.src.tar.gz\InsetSpace ~
4768 # extract source to directory sdcc
4769 \end_layout
4770
4771 \begin_layout Standard
4772
4773 \family typewriter
4774 mkdir sdcc.build\InsetSpace ~
4775 \InsetSpace ~
4776 \InsetSpace ~
4777 \InsetSpace ~
4778 \InsetSpace ~
4779 \InsetSpace ~
4780 \InsetSpace ~
4781 \InsetSpace ~
4782 \InsetSpace ~
4783 # put output in sdcc.build
4784 \end_layout
4785
4786 \begin_layout Standard
4787
4788 \family typewriter
4789 cd sdcc.build
4790 \end_layout
4791
4792 \begin_layout Standard
4793
4794 \family typewriter
4795 ../sdcc/configure\InsetSpace ~
4796 \InsetSpace ~
4797 \InsetSpace ~
4798 \InsetSpace ~
4799 \InsetSpace ~
4800 \InsetSpace ~
4801 \InsetSpace ~
4802 \InsetSpace ~
4803 # configure is doing all the magic!
4804 \end_layout
4805
4806 \begin_layout Standard
4807
4808 \family typewriter
4809 make
4810 \end_layout
4811
4812 \begin_layout Standard
4813 \noindent
4814 That's it! 
4815 \series bold
4816 configure
4817 \series default
4818  will create the directory tree will all the necessary Makefiles in ~/sdcc.build.
4819  It automagically computes the variables srcdir, top_srcdir and top_buildir
4820  for each directory.
4821  After running 
4822 \series bold
4823 make
4824 \series default
4825  the generated files will be in ~/sdcc.build, while the source files stay
4826  in ~/sdcc.
4827 \newline
4828 This is not only usefull for building different binaries, e.g.
4829  when cross compiling.
4830  It also gives you a much better overview in the source tree when all the
4831  generated files are not scattered between the source files.
4832  And the best thing is: if you want to change a file you can leave the original
4833  file untouched in the source directory.
4834  Simply copy it to the build directory, edit it, enter `make clean', `rm
4835  Makefile.dep' and `make'.
4836  
4837 \series bold
4838 make
4839 \series default
4840  will do the rest for you!
4841 \end_layout
4842
4843 \begin_layout Section
4844 Building the Documentation
4845 \end_layout
4846
4847 \begin_layout Standard
4848 Add -
4849 \begin_inset ERT
4850 status collapsed
4851
4852 \begin_layout Standard
4853
4854
4855 \backslash
4856 /
4857 \end_layout
4858
4859 \end_inset
4860
4861 -enable-doc to the configure arguments to build the documentation together
4862  with all the other stuff.
4863  You will need several tools (LyX, LaTeX, LaTeX2HTML, pdflatex, dvipdf,
4864  dvips and makeindex) to get the job done.
4865  Another possibility is to change to the doc directory and to type 
4866 \family sans
4867 \series bold
4868
4869 \begin_inset Quotes srd
4870 \end_inset
4871
4872 make
4873 \begin_inset Quotes srd
4874 \end_inset
4875
4876
4877 \family default
4878 \series default
4879  there.
4880  You're invited to make changes and additions to this manual (sdcc/doc/sdccman.ly
4881 x).
4882  Using LyX 
4883 \begin_inset LatexCommand \url{http://www.lyx.org}
4884
4885 \end_inset
4886
4887  as editor is straightforward.
4888  Prebuilt documentation in html and pdf format is available from 
4889 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4890
4891 \end_inset
4892
4893 .
4894 \end_layout
4895
4896 \begin_layout Section
4897 Reading the Documentation
4898 \begin_inset LatexCommand \index{Documentation}
4899
4900 \end_inset
4901
4902
4903 \end_layout
4904
4905 \begin_layout Standard
4906 Currently reading the document in pdf format is recommended, as for unknown
4907  reason the hyperlinks are working there whereas in the html version they
4908  are not
4909 \begin_inset Foot
4910 status open
4911
4912 \begin_layout Standard
4913 If you should know why please drop us a note
4914 \end_layout
4915
4916 \end_inset
4917
4918 .
4919  
4920 \newline
4921 You'll find the pdf version
4922 \begin_inset LatexCommand \index{PDF version of this document}
4923
4924 \end_inset
4925
4926  at 
4927 \begin_inset LatexCommand \url{http://sdcc.sf.net/doc/sdccman.pdf}
4928
4929 \end_inset
4930
4931 .
4932  
4933 \newline
4934 A html version
4935 \begin_inset LatexCommand \index{HTML version of this document}
4936
4937 \end_inset
4938
4939  should be online at 
4940 \begin_inset LatexCommand \url{http://sdcc.sf.net/doc/sdccman.html/index.html}
4941
4942 \end_inset
4943
4944 .
4945 \newline
4946 This documentation is in some aspects different from a commercial documentation:
4947  
4948 \end_layout
4949
4950 \begin_layout Itemize
4951 It tries to document SDCC for several processor architectures in one document
4952  (commercially these probably would be separate documents/products).
4953  This document
4954 \begin_inset LatexCommand \index{Status of documentation}
4955
4956 \end_inset
4957
4958  currently matches SDCC for mcs51 and DS390 best and does give too few informati
4959 on about f.e.
4960  Z80, PIC14, PIC16 and HC08.
4961 \end_layout
4962
4963 \begin_layout Itemize
4964 There are many references pointing away from this documentation.
4965  Don't let this distract you.
4966  If there f.e.
4967  was a reference like 
4968 \begin_inset LatexCommand \url{http://www.opencores.org}
4969
4970 \end_inset
4971
4972  together with a statement 
4973 \begin_inset Quotes sld
4974 \end_inset
4975
4976 some processors which are targetted by SDCC can be implemented in a 
4977 \emph on
4978 f
4979 \emph default
4980 ield 
4981 \emph on
4982 p
4983 \emph default
4984 rogrammable 
4985 \emph on
4986 g
4987 \emph default
4988 ate 
4989 \emph on
4990 a
4991 \emph default
4992 rray
4993 \begin_inset LatexCommand \index{FPGA (field programmable gate array)}
4994
4995 \end_inset
4996
4997
4998 \begin_inset Quotes srd
4999 \end_inset
5000
5001  or 
5002 \begin_inset LatexCommand \url{http://sf.net/projects/fpgac}
5003
5004 \end_inset
5005
5006
5007 \begin_inset LatexCommand \index{FpgaC ((subset of) C to FPGA compiler)}
5008
5009 \end_inset
5010
5011  
5012 \begin_inset Quotes sld
5013 \end_inset
5014
5015 have you ever heard of an open source compiler that compiles a subset of
5016  C for an FPGA?
5017 \begin_inset Quotes srd
5018 \end_inset
5019
5020  we expect you to have a quick look there and come back.
5021  If you read this you are on the right track.
5022 \end_layout
5023
5024 \begin_layout Itemize
5025 Some sections attribute more space to problems, restrictions and warnings
5026  than to the solution.
5027 \end_layout
5028
5029 \begin_layout Itemize
5030 The installation section and the section about the debugger is intimidating.
5031 \end_layout
5032
5033 \begin_layout Itemize
5034 There are still lots of typos and there are more different writing styles
5035  than pictures.
5036 \end_layout
5037
5038 \begin_layout Section
5039 Testing the SDCC Compiler
5040 \begin_inset LatexCommand \label{sec:Testing-the-SDCC}
5041
5042 \end_inset
5043
5044
5045 \end_layout
5046
5047 \begin_layout Standard
5048 The first thing you should do after installing your SDCC compiler is to
5049  see if it runs.
5050  Type 
5051 \family sans
5052 \series bold
5053 "sdcc -
5054 \begin_inset ERT
5055 status collapsed
5056
5057 \begin_layout Standard
5058
5059
5060 \backslash
5061 /
5062 \end_layout
5063
5064 \end_inset
5065
5066 -version"
5067 \begin_inset LatexCommand \index{version}
5068
5069 \end_inset
5070
5071
5072 \family default
5073 \series default
5074  at the prompt, and the program should run and output its version like:
5075  
5076 \newline
5077
5078 \family typewriter
5079 SDCC : mcs51/z80/avr/ds390/pic16/pic14/ds400/hc08 2.5.6 #4169 (May 8 2006)
5080  (UNIX)
5081 \end_layout
5082
5083 \begin_layout Standard
5084 If it doesn't run, or gives a message about not finding sdcc program, then
5085  you need to check over your installation.
5086  Make sure that the sdcc bin directory is in your executable search path
5087  defined by the PATH environment setting (
5088 \series medium
5089 see 
5090 \series default
5091 section 
5092 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5093
5094 \end_inset
5095
5096 \InsetSpace ~
5097
5098 \series medium
5099 Install trouble-shooting for suggestions
5100 \series default
5101 ).
5102  Make sure that the sdcc program is in the bin folder, if not perhaps something
5103  did not install correctly.
5104 \newline
5105
5106 \newline
5107
5108 \series medium
5109 SDCC 
5110 \series default
5111 is commonly installed as described in section 
5112 \begin_inset Quotes sld
5113 \end_inset
5114
5115 Install and search paths
5116 \begin_inset Quotes srd
5117 \end_inset
5118
5119 .
5120 \newline
5121
5122 \newline
5123
5124 \series medium
5125 Make sure the compiler works on a very simple example.
5126  Type in the following test.c program using your favorite 
5127 \series default
5128 ASCII 
5129 \series medium
5130 editor:
5131 \end_layout
5132
5133 \begin_layout Verse
5134
5135 \family typewriter
5136 char test;
5137 \newline
5138
5139 \newline
5140 void main(void) {
5141 \newline
5142 \InsetSpace ~
5143 \InsetSpace ~
5144 \InsetSpace ~
5145 \InsetSpace ~
5146 test=0;
5147 \newline
5148 }
5149 \end_layout
5150
5151 \begin_layout Standard
5152
5153 \series medium
5154 Compile this using the following command: 
5155 \family sans
5156 \series bold
5157 "sdcc -c test.c".
5158
5159 \family default
5160 \series default
5161  
5162 \series medium
5163 If all goes well, the compiler will generate a test.asm and test.rel file.
5164  Congratulations, you've just compiled your first program with SDCC.
5165  We used the -c option to tell SDCC not to link the generated code, just
5166  to keep things simple for this step.
5167 \series default
5168
5169 \newline
5170
5171 \newline
5172
5173 \series medium
5174 The next step is to try it with the linker.
5175  Type in 
5176 \family sans
5177 \series bold
5178 "sdcc test.c
5179 \family default
5180 \series default
5181 "
5182 \series medium
5183 .
5184  If all goes well the compiler will link with the libraries and produce
5185  a test.ihx output file.
5186  If this step fails
5187 \series default
5188  
5189 \series medium
5190 (no test.ihx, and the linker generates warnings), then the problem is most
5191  likely that 
5192 \series default
5193 SDCC
5194 \series medium
5195  cannot find the 
5196 \series default
5197 /
5198 \series medium
5199 usr/local/share/sdcc/lib directory
5200 \series default
5201  
5202 \series medium
5203 (see 
5204 \series default
5205 section 
5206 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5207
5208 \end_inset
5209
5210 \InsetSpace ~
5211
5212 \series medium
5213 Install trouble-shooting for suggestions).
5214 \series default
5215
5216 \newline
5217
5218 \newline
5219
5220 \series medium
5221 The final test is to ensure 
5222 \series default
5223 SDCC
5224 \series medium
5225  can use the 
5226 \series default
5227 standard
5228 \series medium
5229  header files and libraries.
5230  Edit test.c and change it to the following:
5231 \end_layout
5232
5233 \begin_layout Verse
5234
5235 \family typewriter
5236 #include <string.h>
5237 \newline
5238
5239 \newline
5240 char str1[10];
5241 \newline
5242
5243 \newline
5244 void main(void) {
5245 \newline
5246 \InsetSpace ~
5247 \InsetSpace ~
5248 strcpy(str1, "testing");
5249 \newline
5250 }
5251 \end_layout
5252
5253 \begin_layout Standard
5254
5255 \series medium
5256 Compile this by typing 
5257 \family sans
5258 \series bold
5259 "sdcc test.c"
5260 \family default
5261 \series medium
5262 .
5263  This should generate a test.ihx output file, and it should give no warnings
5264  such as not finding the string.h file.
5265  If it cannot find the string.h file, then the problem is that 
5266 \series default
5267 SDCC
5268 \series medium
5269  cannot find the /usr/local/share/sdcc/include directory
5270 \series default
5271  
5272 \series medium
5273 (see the 
5274 \series default
5275 section 
5276 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5277
5278 \end_inset
5279
5280 \InsetSpace ~
5281
5282 \series medium
5283 Install trouble-shooting section for suggestions).
5284
5285 \series default
5286  Use option 
5287 \series bold
5288 -
5289 \begin_inset ERT
5290 status collapsed
5291
5292 \begin_layout Standard
5293
5294
5295 \backslash
5296 /
5297 \end_layout
5298
5299 \end_inset
5300
5301 -print-search-dirs
5302 \series default
5303
5304 \begin_inset LatexCommand \index{-\/-print-search-dirs}
5305
5306 \end_inset
5307
5308  to find exactly where SDCC is looking for the include and lib files.
5309 \end_layout
5310
5311 \begin_layout Section
5312 Install Trouble-shooting
5313 \begin_inset LatexCommand \label{sub:Install-Trouble-shooting}
5314
5315 \end_inset
5316
5317
5318 \begin_inset LatexCommand \index{Install trouble-shooting}
5319
5320 \end_inset
5321
5322
5323 \end_layout
5324
5325 \begin_layout Subsection
5326 If SDCC does not build correctly
5327 \end_layout
5328
5329 \begin_layout Standard
5330 A thing to try is starting from scratch by unpacking the .tgz source package
5331  again in an empty directory.
5332  Configure it like:
5333 \newline
5334
5335 \newline
5336
5337 \family sans
5338 \series bold
5339 ./configure 2>&1 | tee configure.log
5340 \family default
5341 \series default
5342
5343 \newline
5344
5345 \newline
5346 and build it like:
5347 \newline
5348
5349 \newline
5350
5351 \family sans
5352 \series bold
5353 make 2>&1 | tee make.log
5354 \family default
5355 \series default
5356
5357 \newline
5358
5359 \newline
5360 If anything goes wrong, you can review the log files to locate the problem.
5361  Or a relevant part of this can be attached to an email that could be helpful
5362  when requesting help from the mailing list.
5363 \end_layout
5364
5365 \begin_layout Subsection
5366 What the 
5367 \begin_inset Quotes sld
5368 \end_inset
5369
5370 ./configure
5371 \begin_inset Quotes srd
5372 \end_inset
5373
5374  does
5375 \end_layout
5376
5377 \begin_layout Standard
5378 The 
5379 \begin_inset Quotes sld
5380 \end_inset
5381
5382 ./configure
5383 \begin_inset Quotes srd
5384 \end_inset
5385
5386  command is a script that analyzes your system and performs some configuration
5387  to ensure the source package compiles on your system.
5388  It will take a few minutes to run, and will compile a few tests to determine
5389  what compiler features are installed.
5390 \end_layout
5391
5392 \begin_layout Subsection
5393 What the 
5394 \begin_inset Quotes sld
5395 \end_inset
5396
5397 make
5398 \begin_inset Quotes srd
5399 \end_inset
5400
5401  does
5402 \end_layout
5403
5404 \begin_layout Standard
5405 This runs the GNU make tool, which automatically compiles all the source
5406  packages into the final installed binary executables.
5407 \end_layout
5408
5409 \begin_layout Subsection
5410 What the 
5411 \begin_inset Quotes sld
5412 \end_inset
5413
5414 make install
5415 \begin_inset Quotes erd
5416 \end_inset
5417
5418  command does.
5419 \end_layout
5420
5421 \begin_layout Standard
5422 This will install the compiler, other executables libraries and include
5423  files into the appropriate directories.
5424  See sections 
5425 \begin_inset LatexCommand \ref{sub:Install-paths}
5426
5427 \end_inset
5428
5429 ,\InsetSpace ~
5430
5431 \begin_inset LatexCommand \ref{sub:Search-Paths}
5432
5433 \end_inset
5434
5435 \InsetSpace ~
5436 about install and search paths.
5437 \newline
5438 On most systems you will need super-user privilege
5439 s to do this.
5440 \end_layout
5441
5442 \begin_layout Section
5443 Components of SDCC
5444 \end_layout
5445
5446 \begin_layout Standard
5447 SDCC is not just a compiler, but a collection of tools by various developers.
5448  These include linkers, assemblers, simulators and other components.
5449  Here is a summary of some of the components.
5450  Note that the included simulator and assembler have separate documentation
5451  which you can find in the source package in their respective directories.
5452  As SDCC grows to include support for other processors, other packages from
5453  various developers are included and may have their own sets of documentation.
5454 \newline
5455
5456 \newline
5457 You
5458  might want to look at the files which are installed in <installdir>.
5459  At the time of this writing, we find the following programs for gcc-builds:
5460 \newline
5461
5462  
5463 \newline
5464 In <installdir>/bin:
5465 \end_layout
5466
5467 \begin_layout Itemize
5468 sdcc - The compiler.
5469 \end_layout
5470
5471 \begin_layout Itemize
5472 sdcpp - The C preprocessor.
5473 \end_layout
5474
5475 \begin_layout Itemize
5476 asx8051 - The assembler for 8051 type processors.
5477 \end_layout
5478
5479 \begin_layout Itemize
5480 as-z80
5481 \series bold
5482
5483 \series default
5484 as-gbz80 - The Z80 and GameBoy Z80 assemblers.
5485 \end_layout
5486
5487 \begin_layout Itemize
5488 aslink -The linker for 8051 type processors.
5489 \end_layout
5490
5491 \begin_layout Itemize
5492 link-z80
5493 \series bold
5494
5495 \series default
5496 link-gbz80 - The Z80 and GameBoy Z80 linkers.
5497 \end_layout
5498
5499 \begin_layout Itemize
5500 s51 - The ucSim 8051 simulator.
5501 \end_layout
5502
5503 \begin_layout Itemize
5504 sdcdb - The source debugger.
5505 \end_layout
5506
5507 \begin_layout Itemize
5508 packihx - A tool to pack (compress) Intel hex files.
5509 \end_layout
5510
5511 \begin_layout Standard
5512 In <installdir>/share/sdcc/include
5513 \end_layout
5514
5515 \begin_layout Itemize
5516 the include files
5517 \end_layout
5518
5519 \begin_layout Standard
5520 In <installdir>/share/sdcc/lib
5521 \end_layout
5522
5523 \begin_layout Itemize
5524 the subdirs src and small, large, z80, gbz80 and ds390 with the precompiled
5525  relocatables.
5526 \end_layout
5527
5528 \begin_layout Standard
5529 In <installdir>/share/sdcc/doc
5530 \end_layout
5531
5532 \begin_layout Itemize
5533 the documentation
5534 \end_layout
5535
5536 \begin_layout Standard
5537 As development for other processors proceeds, this list will expand to include
5538  executables to support processors like AVR, PIC, etc.
5539 \end_layout
5540
5541 \begin_layout Subsection
5542 sdcc - The Compiler
5543 \end_layout
5544
5545 \begin_layout Standard
5546 This is the actual compiler, it in turn uses the c-preprocessor and invokes
5547  the assembler and linkage editor.
5548 \end_layout
5549
5550 \begin_layout Subsection
5551 sdcpp - The C-Preprocessor
5552 \end_layout
5553
5554 \begin_layout Standard
5555 The preprocessor
5556 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
5557
5558 \end_inset
5559
5560  is a modified version of the GNU cpp
5561 \begin_inset LatexCommand \index{cpp|see{sdcpp}}
5562
5563 \end_inset
5564
5565  preprocessor 
5566 \begin_inset LatexCommand \url{http://gcc.gnu.org/}
5567
5568 \end_inset
5569
5570 .
5571  The C preprocessor is used to pull in #include sources, process #ifdef
5572  statements, #defines and so on.
5573 \end_layout
5574
5575 \begin_layout Subsection
5576 as
5577 \emph on
5578 xxxx
5579 \emph default
5580 , aslink, link-
5581 \emph on
5582 xxx
5583 \emph default
5584  - The Assemblers and Linkage Editors
5585 \end_layout
5586
5587 \begin_layout Standard
5588 This is retargettable assembler & linkage editor, it was developed by Alan
5589  Baldwin.
5590  John Hartman created the version for 8051, and I (Sandeep) have made some
5591  enhancements and bug fixes for it to work properly with SDCC.
5592 \end_layout
5593
5594 \begin_layout Subsection
5595 s51 - The Simulator
5596 \end_layout
5597
5598 \begin_layout Standard
5599 S51
5600 \begin_inset LatexCommand \index{s51}
5601
5602 \end_inset
5603
5604  is a free open source simulator developed by Daniel Drotos.
5605  The simulator is built as part of the build process.
5606  For more information visit Daniel's web site at: 
5607 \begin_inset LatexCommand \url{http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51}
5608
5609 \end_inset
5610
5611 .
5612  It currently supports the core mcs51, the Dallas DS80C390 and the Phillips
5613  XA51 family.
5614 \end_layout
5615
5616 \begin_layout Subsection
5617 sdcdb - Source Level Debugger
5618 \end_layout
5619
5620 \begin_layout Standard
5621 SDCDB
5622 \begin_inset LatexCommand \index{SDCDB (debugger)}
5623
5624 \end_inset
5625
5626  is the companion source level debugger.
5627  More about SDCDB in section 
5628 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
5629
5630 \end_inset
5631
5632 .
5633  The current version of the debugger uses Daniel's Simulator S51
5634 \begin_inset LatexCommand \index{s51}
5635
5636 \end_inset
5637
5638 , but can be easily changed to use other simulators.
5639 \end_layout
5640
5641 \begin_layout Chapter
5642 Using SDCC
5643 \end_layout
5644
5645 \begin_layout Section
5646 Compiling
5647 \end_layout
5648
5649 \begin_layout Subsection
5650 Single Source File Projects
5651 \end_layout
5652
5653 \begin_layout Standard
5654 For single source file 8051 projects the process is very simple.
5655  Compile your programs with the following command 
5656 \family sans
5657 \series bold
5658 "sdcc sourcefile.c".
5659
5660 \family default
5661 \series default
5662  This will compile, assemble and link your source file.
5663  Output files are as follows:
5664 \end_layout
5665
5666 \begin_layout Itemize
5667 sourcefile.asm
5668 \begin_inset LatexCommand \index{<file>.asm}
5669
5670 \end_inset
5671
5672  - Assembler source
5673 \begin_inset LatexCommand \index{Assembler source}
5674
5675 \end_inset
5676
5677  file created by the compiler
5678 \end_layout
5679
5680 \begin_layout Itemize
5681 sourcefile.lst
5682 \begin_inset LatexCommand \index{<file>.lst}
5683
5684 \end_inset
5685
5686  - Assembler listing
5687 \begin_inset LatexCommand \index{Assembler listing}
5688
5689 \end_inset
5690
5691  file created by the Assembler
5692 \end_layout
5693
5694 \begin_layout Itemize
5695 sourcefile.rst
5696 \begin_inset LatexCommand \index{<file>.rst}
5697
5698 \end_inset
5699
5700  - Assembler listing
5701 \begin_inset LatexCommand \index{Assembler listing}
5702
5703 \end_inset
5704
5705  file updated with linkedit information, created by linkage editor
5706 \end_layout
5707
5708 \begin_layout Itemize
5709 sourcefile.sym
5710 \begin_inset LatexCommand \index{<file>.sym}
5711
5712 \end_inset
5713
5714  - symbol listing
5715 \begin_inset LatexCommand \index{Symbol listing}
5716
5717 \end_inset
5718
5719  for the sourcefile, created by the assembler
5720 \end_layout
5721
5722 \begin_layout Itemize
5723 sourcefile.rel
5724 \begin_inset LatexCommand \index{<file>.rel}
5725
5726 \end_inset
5727
5728  or sourcefile.o
5729 \begin_inset LatexCommand \index{<file>.o}
5730
5731 \end_inset
5732
5733  - Object file
5734 \begin_inset LatexCommand \index{Object file}
5735
5736 \end_inset
5737
5738  created by the assembler, input to Linkage editor
5739 \end_layout
5740
5741 \begin_layout Itemize
5742 sourcefile.map
5743 \begin_inset LatexCommand \index{<file>.map}
5744
5745 \end_inset
5746
5747  - The memory map
5748 \begin_inset LatexCommand \index{Memory map}
5749
5750 \end_inset
5751
5752  for the load module, created by the Linker
5753 \end_layout
5754
5755 \begin_layout Itemize
5756 sourcefile.mem
5757 \begin_inset LatexCommand \index{<file>.mem}
5758
5759 \end_inset
5760
5761  - A file with a summary of the memory usage
5762 \end_layout
5763
5764 \begin_layout Itemize
5765 sourcefile.ihx
5766 \begin_inset LatexCommand \index{<file>.ihx}
5767
5768 \end_inset
5769
5770  - The load module in Intel hex format
5771 \begin_inset LatexCommand \index{Intel hex format}
5772
5773 \end_inset
5774
5775  (you can select the Motorola S19 format
5776 \begin_inset LatexCommand \index{Motorola S19 format}
5777
5778 \end_inset
5779
5780  with -
5781 \begin_inset ERT
5782 status collapsed
5783
5784 \begin_layout Standard
5785
5786
5787 \backslash
5788 /
5789 \end_layout
5790
5791 \end_inset
5792
5793 -out-fmt-s19
5794 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
5795
5796 \end_inset
5797
5798 .
5799  If you need another format you might want to use 
5800 \family sans
5801 \shape italic
5802 objdump
5803 \family default
5804 \shape default
5805
5806 \begin_inset LatexCommand \index{objdump (tool)}
5807
5808 \end_inset
5809
5810  or
5811 \family sans
5812 \shape italic
5813  srecord
5814 \family default
5815 \shape default
5816
5817 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5818
5819 \end_inset
5820
5821
5822 \begin_inset Note Note
5823 status collapsed
5824
5825 \begin_layout Standard
5826 hyperlinks needed
5827 \end_layout
5828
5829 \end_inset
5830
5831  - see also section 
5832 \begin_inset LatexCommand \vref{sub:Postprocessing-the-Intel}
5833
5834 \end_inset
5835
5836 ).
5837  Both formats are documented in the documentation of srecord
5838 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5839
5840 \end_inset
5841
5842
5843 \end_layout
5844
5845 \begin_layout Itemize
5846 sourcefile.adb
5847 \begin_inset LatexCommand \index{<file>.adb}
5848
5849 \end_inset
5850
5851  - An intermediate file containing debug information needed to create the
5852  .cdb file (with -
5853 \begin_inset ERT
5854 status collapsed
5855
5856 \begin_layout Standard
5857
5858
5859 \backslash
5860 /
5861 \end_layout
5862
5863 \end_inset
5864
5865 -debug
5866 \begin_inset LatexCommand \index{-\/-debug}
5867
5868 \end_inset
5869
5870
5871 \end_layout
5872
5873 \begin_layout Itemize
5874 sourcefile.cdb
5875 \begin_inset LatexCommand \index{<file>.cdb}
5876
5877 \end_inset
5878
5879  - An optional file (with -
5880 \begin_inset ERT
5881 status collapsed
5882
5883 \begin_layout Standard
5884
5885
5886 \backslash
5887 /
5888 \end_layout
5889
5890 \end_inset
5891
5892 -debug) containing debug information.
5893  The format is documented in cdbfileformat.pdf
5894 \end_layout
5895
5896 \begin_layout Itemize
5897 sourcefile.
5898  - (no extension)
5899 \begin_inset LatexCommand \index{<file> (no extension)}
5900
5901 \end_inset
5902
5903  An optional AOMF or AOMF51
5904 \begin_inset LatexCommand \index{AOMF, AOMF51}
5905
5906 \end_inset
5907
5908  
5909 \begin_inset LatexCommand \label{OMF file}
5910
5911 \end_inset
5912
5913 file containing debug information (generated with option -
5914 \begin_inset ERT
5915 status collapsed
5916
5917 \begin_layout Standard
5918
5919
5920 \backslash
5921 /
5922 \end_layout
5923
5924 \end_inset
5925
5926 -debug).
5927  The (Intel)
5928 \emph on
5929  a
5930 \emph default
5931 bsolute 
5932 \emph on
5933 o
5934 \emph default
5935 bject 
5936 \emph on
5937 m
5938 \emph default
5939 odule 
5940 \emph on
5941 f
5942 \emph default
5943 ormat is a subformat of the OMF51 format and is commonly used by third party
5944  tools (debuggers
5945 \begin_inset LatexCommand \index{Debugger}
5946
5947 \end_inset
5948
5949 , simulators, emulators).
5950 \end_layout
5951
5952 \begin_layout Itemize
5953 sourcefile.dump*
5954 \begin_inset LatexCommand \index{<file>.dump*}
5955
5956 \end_inset
5957
5958  - Dump file to debug the compiler it self (generated with option -
5959 \begin_inset ERT
5960 status collapsed
5961
5962 \begin_layout Standard
5963
5964
5965 \backslash
5966 /
5967 \end_layout
5968
5969 \end_inset
5970
5971 -dumpall) (see section 
5972 \begin_inset LatexCommand \ref{sub:Intermediate-Dump-Options}
5973
5974 \end_inset
5975
5976 \InsetSpace ~
5977  and section 
5978 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
5979
5980 \end_inset
5981
5982 \InsetSpace ~
5983
5984 \begin_inset Quotes sld
5985 \end_inset
5986
5987 Anatomy of the compiler
5988 \begin_inset Quotes srd
5989 \end_inset
5990
5991 ).
5992 \end_layout
5993
5994 \begin_layout Subsection
5995 Postprocessing the Intel Hex
5996 \begin_inset LatexCommand \index{Intel hex format}
5997
5998 \end_inset
5999
6000  file
6001 \begin_inset LatexCommand \label{sub:Postprocessing-the-Intel}
6002
6003 \end_inset
6004
6005
6006 \end_layout
6007
6008 \begin_layout Standard
6009 In most cases this won't be needed but the Intel Hex file
6010 \begin_inset LatexCommand \index{<file>.ihx}
6011
6012 \end_inset
6013
6014  which is generated by SDCC might include lines of varying length and the
6015  addresses within the file are not guaranteed to be strictly ascending.
6016  If your toolchain or a bootloader does not like this you can use the tool
6017  
6018 \family typewriter
6019 packihx
6020 \family default
6021
6022 \begin_inset LatexCommand \index{packihx (tool)}
6023
6024 \end_inset
6025
6026  which is part of the SDCC distribution: 
6027 \newline
6028
6029 \newline
6030
6031 \family sans
6032 \series bold
6033  packihx sourcefile.ihx >sourcefile.hex
6034 \family default
6035 \series default
6036
6037 \newline
6038
6039 \newline
6040 The separately available
6041 \emph on
6042  srecord
6043 \emph default
6044
6045 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
6046
6047 \end_inset
6048
6049  package additionally allows to set undefined locations to a predefined
6050  value, to insert checksums
6051 \begin_inset LatexCommand \index{checksum}
6052
6053 \end_inset
6054
6055  of various flavours (crc, add, xor) and to perform other manipulations
6056  (convert, split, crop, offset, ...).
6057  
6058 \newline
6059
6060 \newline
6061
6062 \family sans
6063 \series bold
6064 srec_cat\InsetSpace ~
6065 \InsetSpace ~
6066 sourcefile.ihx -intel\InsetSpace ~
6067 \InsetSpace ~
6068 -o sourcefile.hex -intel
6069 \newline
6070
6071 \newline
6072
6073 \family default
6074 \series default
6075 An example for a more complex command line
6076 \begin_inset Foot
6077 status open
6078
6079 \begin_layout Standard
6080 the command backfills
6081 \begin_inset LatexCommand \index{backfill unused memory}
6082
6083 \end_inset
6084
6085  unused memory with 0x12 and the overall 16 bit sum of the complete 64 kByte
6086  block is zero.
6087  If the program counter on an mcs51 runs wild the backfill pattern 0x12
6088  will be interpreted as an 
6089 \family typewriter
6090 lcall
6091 \family default
6092  to address 
6093 \family typewriter
6094 0x1212
6095 \family default
6096  (where an emergency routine could sit).
6097 \end_layout
6098
6099 \end_inset
6100
6101  could look like:
6102 \newline
6103
6104 \newline
6105
6106 \family sans
6107 \series bold
6108 \size footnotesize
6109 srec_cat\InsetSpace ~
6110 sourcefile.ihx -intel\InsetSpace ~
6111 \InsetSpace ~
6112 -fill 0x12 0x0000 0xfffe\InsetSpace ~
6113 -little-endian-checksum-nega
6114 tive 0xfffe 0x02 0x02\InsetSpace ~
6115 \InsetSpace ~
6116 -o sourcefile.hex -intel
6117 \size default
6118
6119 \newline
6120
6121 \newline
6122
6123 \family default
6124 \series default
6125 The srecord package is available at 
6126 \begin_inset LatexCommand \url{http://sf.net/projects/srecord}
6127
6128 \end_inset
6129
6130  .
6131 \end_layout
6132
6133 \begin_layout Subsection
6134 Projects with Multiple Source Files
6135 \end_layout
6136
6137 \begin_layout Standard
6138 SDCC can compile only ONE file at a time.
6139  Let us for example assume that you have a project containing the following
6140  files:
6141 \newline
6142
6143 \newline
6144 foo1.c (contains some functions)
6145 \newline
6146 foo2.c (contains some more functions)
6147 \newline
6148 foomai
6149 n.c (contains more functions and the function main)
6150 \newline
6151
6152 \size footnotesize
6153
6154 \newline
6155
6156 \size default
6157 The first two files will need to be compiled separately with the commands:
6158 \size footnotesize
6159  
6160 \size default
6161
6162 \newline
6163
6164 \newline
6165
6166 \family sans
6167 \series bold
6168 sdcc\InsetSpace ~
6169 -c\InsetSpace ~
6170 foo1.c
6171 \family default
6172 \series default
6173 \size footnotesize
6174
6175 \newline
6176
6177 \family sans
6178 \series bold
6179 \size default
6180 sdcc\InsetSpace ~
6181 -c\InsetSpace ~
6182 foo2.c
6183 \family default
6184 \series default
6185
6186 \newline
6187
6188 \newline
6189 Then compile the source file containing the 
6190 \emph on
6191 main()
6192 \emph default
6193  function and link
6194 \begin_inset LatexCommand \index{Linker}
6195
6196 \end_inset
6197
6198  the files together with the following command: 
6199 \newline
6200
6201 \newline
6202
6203 \family sans
6204 \series bold
6205 sdcc\InsetSpace ~
6206 foomain.c\InsetSpace ~
6207 foo1.rel\InsetSpace ~
6208 foo2.rel
6209 \family default
6210 \series default
6211
6212 \begin_inset LatexCommand \index{<file>.rel}
6213
6214 \end_inset
6215
6216
6217 \newline
6218
6219 \newline
6220 Alternatively, 
6221 \emph on
6222 foomain.c 
6223 \emph default
6224 can be separately compiled as well: 
6225 \family sans
6226 \series bold
6227
6228 \newline
6229
6230 \newline
6231 sdcc\InsetSpace ~
6232 -c\InsetSpace ~
6233 foomain.c
6234 \newline
6235 sdcc foomain.rel foo1.rel foo2.rel
6236 \newline
6237
6238 \newline
6239
6240 \family default
6241 \series default
6242 The file containing the 
6243 \emph on
6244 main()
6245 \emph default
6246  function
6247 \emph on
6248  
6249 \emph default
6250 \noun on
6251 must
6252 \noun default
6253  be the 
6254 \noun on
6255 first
6256 \noun default
6257  file specified in the command line, since the linkage editor processes
6258  file in the order they are presented to it.
6259  The linker is invoked from SDCC using a script file with extension .lnk
6260 \begin_inset LatexCommand \index{<file>.lnk}
6261
6262 \end_inset
6263
6264 .
6265  You can view this file to troubleshoot linking problems such as those arising
6266  from missing libraries.
6267 \end_layout
6268
6269 \begin_layout Subsection
6270 Projects with Additional Libraries
6271 \begin_inset LatexCommand \index{Libraries}
6272
6273 \end_inset
6274
6275
6276 \end_layout
6277
6278 \begin_layout Standard
6279 Some reusable routines may be compiled into a library, see the documentation
6280  for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc)
6281  for how to create a 
6282 \emph on
6283 .lib
6284 \begin_inset LatexCommand \index{<file>.lib}
6285
6286 \end_inset
6287
6288
6289 \emph default
6290  library file.
6291  Libraries created in this manner can be included in the command line.
6292  Make sure you include the -L <library-path> option to tell the linker where
6293  to look for these files if they are not in the current directory.
6294  Here is an example, assuming you have the source file 
6295 \emph on
6296 foomain.c
6297 \emph default
6298  and a library
6299 \emph on
6300  foolib.lib
6301 \emph default
6302  in the directory 
6303 \emph on
6304 mylib
6305 \emph default
6306  (if that is not the same as your current project):
6307 \newline
6308
6309 \newline
6310
6311 \family sans
6312 \series bold
6313 sdcc foomain.c foolib.lib -L mylib
6314 \newline
6315
6316 \newline
6317
6318 \family default
6319 \series default
6320 Note here that
6321 \emph on
6322  mylib
6323 \emph default
6324  must be an absolute path name.
6325 \newline
6326
6327 \newline
6328 The most efficient way to use libraries is
6329  to keep separate modules in separate source files.
6330  The lib file now should name all the modules.rel
6331 \begin_inset LatexCommand \index{<file>.rel}
6332
6333 \end_inset
6334
6335  files.
6336  For an example see the standard library file 
6337 \emph on
6338 libsdcc.lib
6339 \emph default
6340  in the directory <installdir>/share/lib/small.
6341 \end_layout
6342
6343 \begin_layout Subsection
6344 Using sdcclib to Create and Manage Libraries
6345 \begin_inset LatexCommand \index{sdcclib}
6346
6347 \end_inset
6348
6349
6350 \end_layout
6351
6352 \begin_layout Standard
6353 Alternatively, instead of having a .rel file for each entry on the library
6354  file as described in the preceding section, sdcclib can be used to embed
6355  all the modules belonging to such library in the library file itself.
6356  This results in a larger library file, but it greatly reduces the number
6357  of disk files accessed by the linker.
6358   Additionally, the packed library file contains an index of all include
6359  modules and symbols that significantly speeds up the linking process.
6360  To display a list of options supported by sdcclib type:
6361 \newline
6362
6363 \end_layout
6364
6365 \begin_layout Standard
6366
6367 \family sans
6368 \series bold
6369 sdcclib -?
6370 \begin_inset LatexCommand \index{sdcclib}
6371
6372 \end_inset
6373
6374
6375 \newline
6376
6377 \newline
6378
6379 \family default
6380 \series default
6381 To create a new library file, start by compiling all the required modules.
6382  For example:
6383 \newline
6384
6385 \end_layout
6386
6387 \begin_layout Standard
6388
6389 \family sans
6390 \series bold
6391 sdcc -c _divsint.c
6392 \end_layout
6393
6394 \begin_layout Standard
6395
6396 \family sans
6397 \series bold
6398 sdcc -c _divuint.c
6399 \end_layout
6400
6401 \begin_layout Standard
6402
6403 \family sans
6404 \series bold
6405 sdcc -c _modsint.c
6406 \end_layout
6407
6408 \begin_layout Standard
6409
6410 \family sans
6411 \series bold
6412 sdcc -c _moduint.c
6413 \end_layout
6414
6415 \begin_layout Standard
6416
6417 \family sans
6418 \series bold
6419 sdcc -c _mulint.c
6420 \newline
6421
6422 \end_layout
6423
6424 \begin_layout Standard
6425 This will create files _divsint.rel, _divuint.rel, _modsint.rel, _moduint.rel,
6426  and _mulint.rel.
6427  The next step is to add the .rel files to the library file:
6428 \newline
6429
6430 \end_layout
6431
6432 \begin_layout Standard
6433
6434 \family sans
6435 \series bold
6436 sdcclib libint.lib _divsint.rel
6437 \family default
6438
6439 \begin_inset LatexCommand \index{sdcclib}
6440
6441 \end_inset
6442
6443
6444 \end_layout
6445
6446 \begin_layout Standard
6447
6448 \family sans
6449 \series bold
6450 sdcclib libint.lib _divuint.rel
6451 \end_layout
6452
6453 \begin_layout Standard
6454
6455 \family sans
6456 \series bold
6457 sdcclib libint.lib _modsint.rel
6458 \end_layout
6459
6460 \begin_layout Standard
6461
6462 \family sans
6463 \series bold
6464 sdcclib libint.lib _moduint.rel
6465 \end_layout
6466
6467 \begin_layout Standard
6468
6469 \family sans
6470 \series bold
6471 sdcclib libint.lib _mulint.rel
6472 \family default
6473 \series default
6474
6475 \newline
6476
6477 \end_layout
6478
6479 \begin_layout Standard
6480 Or, if you preffer:
6481 \family sans
6482 \series bold
6483
6484 \newline
6485
6486 \end_layout
6487
6488 \begin_layout Standard
6489
6490 \family sans
6491 \series bold
6492 sdcclib libint.lib _divsint.rel _divuint.rel _modsint.rel _moduint.rel _mulint.rel
6493 \family default
6494 \series default
6495
6496 \newline
6497
6498 \end_layout
6499
6500 \begin_layout Standard
6501 If the file already exists in the library, it will be replaced.
6502  If a list of .rel files is available, you can tell sdcclib to add those
6503  files to a library.
6504  For example, if the file 'myliblist.txt' contains
6505 \family sans
6506 \series bold
6507
6508 \newline
6509
6510 \end_layout
6511
6512 \begin_layout Standard
6513
6514 \family sans
6515 \series bold
6516 _divsint.rel
6517 \end_layout
6518
6519 \begin_layout Standard
6520
6521 \family sans
6522 \series bold
6523 _divuint.rel
6524 \end_layout
6525
6526 \begin_layout Standard
6527
6528 \family sans
6529 \series bold
6530 _modsint.rel
6531 \end_layout
6532
6533 \begin_layout Standard
6534
6535 \family sans
6536 \series bold
6537 _moduint.rel
6538 \end_layout
6539
6540 \begin_layout Standard
6541
6542 \family sans
6543 \series bold
6544 _mulint.rel
6545 \family default
6546 \series default
6547
6548 \newline
6549
6550 \end_layout
6551
6552 \begin_layout Standard
6553 Use
6554 \family sans
6555 \series bold
6556
6557 \newline
6558
6559 \end_layout
6560
6561 \begin_layout Standard
6562
6563 \family sans
6564 \series bold
6565 sdcclib -l libint.lib myliblist.txt
6566 \family default
6567 \series default
6568
6569 \newline
6570
6571 \end_layout
6572
6573 \begin_layout Standard
6574 Additionally, you can instruct sdcclib to compiles the files before adding
6575  them to the library.
6576  This is achieved using the environment variables SDCCLIB_CC and/or SDCCLIB_AS.
6577  For example:
6578 \family sans
6579 \series bold
6580
6581 \newline
6582
6583 \end_layout
6584
6585 \begin_layout Standard
6586
6587 \family sans
6588 \series bold
6589 set SDCCLIB_CC=sdcc -c
6590 \end_layout
6591
6592 \begin_layout Standard
6593
6594 \family sans
6595 \series bold
6596 sdcclib -l libint.lib myliblist.txt
6597 \family default
6598 \series default
6599
6600 \newline
6601
6602 \end_layout
6603
6604 \begin_layout Standard
6605 To see what modules and symbols are included in the library, options -s
6606  and -m are available.
6607  For example:
6608 \newline
6609
6610 \newline
6611
6612 \family sans
6613 \series bold
6614 sdcclib -s libint.lib
6615 \family default
6616
6617 \begin_inset LatexCommand \index{sdcclib}
6618
6619 \end_inset
6620
6621
6622 \newline
6623
6624 \family typewriter
6625 \series default
6626 _divsint.rel:
6627 \end_layout
6628
6629 \begin_layout Standard
6630
6631 \family typewriter
6632 __divsint_a_1_1
6633 \end_layout
6634
6635 \begin_layout Standard
6636
6637 \family typewriter
6638 __divsint_PARM_2
6639 \end_layout
6640
6641 \begin_layout Standard
6642
6643 \family typewriter
6644 __divsint
6645 \newline
6646 _divuint.rel:
6647 \end_layout
6648
6649 \begin_layout Standard
6650
6651 \family typewriter
6652 __divuint_a_1_1
6653 \end_layout
6654
6655 \begin_layout Standard
6656
6657 \family typewriter
6658 __divuint_PARM_2
6659 \end_layout
6660
6661 \begin_layout Standard
6662
6663 \family typewriter
6664 __divuint_reste_1_1
6665 \end_layout
6666
6667 \begin_layout Standard
6668
6669 \family typewriter
6670 __divuint_count_1_1
6671 \end_layout
6672
6673 \begin_layout Standard
6674
6675 \family typewriter
6676 __divuint
6677 \newline
6678 _modsint.rel:
6679 \end_layout
6680
6681 \begin_layout Standard
6682
6683 \family typewriter
6684 __modsint_a_1_1
6685 \end_layout
6686
6687 \begin_layout Standard
6688
6689 \family typewriter
6690 __modsint_PARM_2
6691 \end_layout
6692
6693 \begin_layout Standard
6694
6695 \family typewriter
6696 __modsint
6697 \newline
6698 _moduint.rel:
6699 \end_layout
6700
6701 \begin_layout Standard
6702
6703 \family typewriter
6704 __moduint_a_1_1
6705 \end_layout
6706
6707 \begin_layout Standard
6708
6709 \family typewriter
6710 __moduint_PARM_2
6711 \end_layout
6712
6713 \begin_layout Standard
6714
6715 \family typewriter
6716 __moduint_count_1_1
6717 \end_layout
6718
6719 \begin_layout Standard
6720
6721 \family typewriter
6722 __moduint
6723 \newline
6724 _mulint.rel:
6725 \end_layout
6726
6727 \begin_layout Standard
6728
6729 \family typewriter
6730 __mulint_PARM_2
6731 \end_layout
6732
6733 \begin_layout Standard
6734
6735 \family typewriter
6736 __mulint
6737 \family default
6738 \series bold
6739
6740 \newline
6741
6742 \end_layout
6743
6744 \begin_layout Standard
6745 If the source files are compiled using -
6746 \begin_inset ERT
6747 status collapsed
6748
6749 \begin_layout Standard
6750
6751
6752 \backslash
6753 /
6754 \end_layout
6755
6756 \end_inset
6757
6758 -debug
6759 \begin_inset LatexCommand \index{-\/-debug}
6760
6761 \end_inset
6762
6763 , the corresponding debug information file .adb will be include in the library
6764  file as well.
6765  The library files created with sdcclib are plain text files, so they can
6766  be viewed with a text editor.
6767  It is not recomended to modify a library file created with sdcclib using
6768  a text editor, as there are file indexes numbers located accross the file
6769  used by the linker to quickly locate the required module to link.
6770  Once a .rel file (as well as a .adb file) is added to a library using sdcclib,
6771  it can be safely deleted, since all the information required for linking
6772  is embedded in the library file itself.
6773  Library files created using sdcclib are used as described in the preceding
6774  sections.
6775 \begin_inset VSpace bigskip
6776 \end_inset
6777
6778
6779 \end_layout
6780
6781 \begin_layout Section
6782 Command Line Options
6783 \begin_inset LatexCommand \index{Command Line Options}
6784
6785 \end_inset
6786
6787
6788 \begin_inset LatexCommand \label{sec:Command-Line-Options}
6789
6790 \end_inset
6791
6792
6793 \end_layout
6794
6795 \begin_layout Subsection
6796 Processor Selection Options
6797 \begin_inset LatexCommand \index{Options processor selection}
6798
6799 \end_inset
6800
6801
6802 \begin_inset LatexCommand \index{Processor selection options}
6803
6804 \end_inset
6805
6806
6807 \end_layout
6808
6809 \begin_layout List
6810 \labelwidthstring 00.00.0000
6811
6812 \series bold
6813 -mmcs51
6814 \begin_inset LatexCommand \index{-mmcs51}
6815
6816 \end_inset
6817
6818
6819 \series default
6820  Generate code for the Intel MCS51
6821 \begin_inset LatexCommand \index{MCS51}
6822
6823 \end_inset
6824
6825  family of processors.
6826  This is the default processor target.
6827 \end_layout
6828
6829 \begin_layout List
6830 \labelwidthstring 00.00.0000
6831
6832 \series bold
6833 -mds390
6834 \begin_inset LatexCommand \index{-mds390}
6835
6836 \end_inset
6837
6838
6839 \series default
6840  Generate code for the Dallas DS80C390
6841 \begin_inset LatexCommand \index{DS80C390}
6842
6843 \end_inset
6844
6845  processor.
6846 \end_layout
6847
6848 \begin_layout List
6849 \labelwidthstring 00.00.0000
6850
6851 \series bold
6852 -mds400
6853 \begin_inset LatexCommand \index{-mds400}
6854
6855 \end_inset
6856
6857
6858 \series default
6859  Generate code for the Dallas DS80C400
6860 \begin_inset LatexCommand \index{DS80C400}
6861
6862 \end_inset
6863
6864  processor.
6865 \end_layout
6866
6867 \begin_layout List
6868 \labelwidthstring 00.00.0000
6869
6870 \series bold
6871 -mhc08
6872 \begin_inset LatexCommand \index{-mhc08}
6873
6874 \end_inset
6875
6876
6877 \series default
6878  Generate code for the Freescale/Motorola HC08
6879 \begin_inset LatexCommand \index{HC08}
6880
6881 \end_inset
6882
6883  family of processors.
6884 \end_layout
6885
6886 \begin_layout List
6887 \labelwidthstring 00.00.0000
6888
6889 \series bold
6890 -mz80
6891 \begin_inset LatexCommand \index{-mz80}
6892
6893 \end_inset
6894
6895
6896 \series default
6897  Generate code for the Zilog Z80
6898 \begin_inset LatexCommand \index{Z80}
6899
6900 \end_inset
6901
6902  family of processors.
6903 \end_layout
6904
6905 \begin_layout List
6906 \labelwidthstring 00.00.0000
6907
6908 \series bold
6909 -mgbz80
6910 \begin_inset LatexCommand \index{-mgbz80}
6911
6912 \end_inset
6913
6914
6915 \series default
6916  Generate code for the GameBoy Z80
6917 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
6918
6919 \end_inset
6920
6921  processor (Not actively maintained).
6922 \end_layout
6923
6924 \begin_layout List
6925 \labelwidthstring 00.00.0000
6926
6927 \series bold
6928 -mavr
6929 \begin_inset LatexCommand \index{-mavr}
6930
6931 \end_inset
6932
6933
6934 \series default
6935  Generate code for the Atmel AVR
6936 \begin_inset LatexCommand \index{AVR}
6937
6938 \end_inset
6939
6940  processor (Not maintained, not complete).
6941  AVR users should probably have a look at winavr 
6942 \begin_inset LatexCommand \url{http://sourceforge.net/projects/winavr}
6943
6944 \end_inset
6945
6946  or 
6947 \begin_inset LatexCommand \url{http://www.avrfreaks.net/index.php?name=PNphpBB2&file=index}
6948
6949 \end_inset
6950
6951 , which is based on AVR-port of the gcc compiler.
6952 \end_layout
6953
6954 \begin_layout Standard
6955 \begin_inset Note Note
6956 status collapsed
6957
6958 \begin_layout Standard
6959 I think it is fair to direct users there for now.
6960  Open source is also about avoiding unnecessary work .
6961  But I didn't find the 'official' link.
6962 \end_layout
6963
6964 \end_inset
6965
6966
6967 \end_layout
6968
6969 \begin_layout List
6970 \labelwidthstring 00.00.0000
6971
6972 \series bold
6973 -mpic14
6974 \begin_inset LatexCommand \index{-mpic14}
6975
6976 \end_inset
6977
6978
6979 \series default
6980  Generate code for the Microchip PIC 14
6981 \begin_inset LatexCommand \index{PIC14}
6982
6983 \end_inset
6984
6985 -bit processors (p16f84 and variants.
6986  In development, not complete).
6987 \end_layout
6988
6989 \begin_layout Standard
6990 \begin_inset Note Note
6991 status collapsed
6992
6993 \begin_layout Standard
6994 p16f627 p16f628 p16f84 p16f873 p16f877?
6995 \end_layout
6996
6997 \end_inset
6998
6999
7000 \end_layout
7001
7002 \begin_layout List
7003 \labelwidthstring 00.00.0000
7004
7005 \series bold
7006 -mpic16
7007 \begin_inset LatexCommand \index{-mpic16}
7008
7009 \end_inset
7010
7011
7012 \series default
7013  Generate code for the Microchip PIC 16
7014 \begin_inset LatexCommand \index{PIC16}
7015
7016 \end_inset
7017
7018 -bit processors (p18f452 and variants.
7019  In development, not complete).
7020 \end_layout
7021
7022 \begin_layout List
7023 \labelwidthstring 00.00.0000
7024
7025 \series bold
7026 -mtlcs900h
7027 \series default
7028  Generate code for the Toshiba TLCS-900H
7029 \begin_inset LatexCommand \index{TLCS-900H}
7030
7031 \end_inset
7032
7033  processor (Not maintained, not complete).
7034 \end_layout
7035
7036 \begin_layout List
7037 \labelwidthstring 00.00.0000
7038
7039 \series bold
7040 -mxa51
7041 \begin_inset LatexCommand \index{-mxa51}
7042
7043 \end_inset
7044
7045
7046 \series default
7047  Generate code for the Phillips XA51
7048 \begin_inset LatexCommand \index{XA51}
7049
7050 \end_inset
7051
7052  processor (Not maintained, not complete).
7053 \end_layout
7054
7055 \begin_layout Standard
7056 \begin_inset VSpace bigskip
7057 \end_inset
7058
7059
7060 \end_layout
7061
7062 \begin_layout Subsection
7063 Preprocessor Options
7064 \begin_inset LatexCommand \index{Options preprocessor}
7065
7066 \end_inset
7067
7068
7069 \begin_inset LatexCommand \index{Preprocessor options}
7070
7071 \end_inset
7072
7073
7074 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
7075
7076 \end_inset
7077
7078
7079 \end_layout
7080
7081 \begin_layout List
7082 \labelwidthstring 00.00.0000
7083
7084 \series bold
7085 -I<path>
7086 \begin_inset LatexCommand \index{-I<path>}
7087
7088 \end_inset
7089
7090
7091 \series default
7092  The additional location where the preprocessor will look for <..h> or 
7093 \begin_inset Quotes eld
7094 \end_inset
7095
7096 ..h
7097 \begin_inset Quotes erd
7098 \end_inset
7099
7100  files.
7101 \end_layout
7102
7103 \begin_layout List
7104 \labelwidthstring 00.00.0000
7105
7106 \series bold
7107 -D<macro[=value]>
7108 \begin_inset LatexCommand \index{-D<macro[=value]>}
7109
7110 \end_inset
7111
7112
7113 \series default
7114  Command line definition of macros.
7115  Passed to the preprocessor.
7116 \end_layout
7117
7118 \begin_layout List
7119 \labelwidthstring 00.00.0000
7120
7121 \series bold
7122 -M
7123 \begin_inset LatexCommand \index{-M}
7124
7125 \end_inset
7126
7127
7128 \series default
7129  Tell the preprocessor to output a rule suitable for make describing the
7130  dependencies of each object file.
7131  For each source file, the preprocessor outputs one make-rule whose target
7132  is the object file name for that source file and whose dependencies are
7133  all the files `#include'd in it.
7134  This rule may be a single line or may be continued with `
7135 \backslash
7136 '-newline if it is long.
7137  The list of rules is printed on standard output instead of the preprocessed
7138  C program.
7139  `-M' implies `-E
7140 \begin_inset LatexCommand \index{-E}
7141
7142 \end_inset
7143
7144 '.
7145 \end_layout
7146
7147 \begin_layout List
7148 \labelwidthstring 00.00.0000
7149
7150 \series bold
7151 -C
7152 \begin_inset LatexCommand \index{-C}
7153
7154 \end_inset
7155
7156
7157 \series default
7158  Tell the preprocessor not to discard comments.
7159  Used with the `-E' option.
7160 \end_layout
7161
7162 \begin_layout List
7163 \labelwidthstring 00.00.0000
7164
7165 \series bold
7166 -MM
7167 \begin_inset LatexCommand \index{-MM}
7168
7169 \end_inset
7170
7171
7172 \size large
7173 \bar under
7174  
7175 \series default
7176 \size default
7177 \bar default
7178 Like `-M' but the output mentions only the user header files included with
7179  `#include 
7180 \begin_inset Quotes eld
7181 \end_inset
7182
7183 file"'.
7184  System header files included with `#include <file>' are omitted.
7185 \end_layout
7186
7187 \begin_layout List
7188 \labelwidthstring 00.00.0000
7189
7190 \series bold
7191 -Aquestion(answer)
7192 \begin_inset LatexCommand \index{-Aquestion(answer)}
7193
7194 \end_inset
7195
7196
7197 \series default
7198  Assert the answer answer for question, in case it is tested with a preprocessor
7199  conditional such as `#if #question(answer)'.
7200  `-A-' disables the standard assertions that normally describe the target
7201  machine.
7202 \end_layout
7203
7204 \begin_layout List
7205 \labelwidthstring 00.00.0000
7206
7207 \series bold
7208 -Umacro
7209 \begin_inset LatexCommand \index{-Umacro}
7210
7211 \end_inset
7212
7213
7214 \series default
7215  Undefine macro macro.
7216  `-U' options are evaluated after all `-D' options, but before any `-include'
7217  and `-imacros' options.
7218 \end_layout
7219
7220 \begin_layout List
7221 \labelwidthstring 00.00.0000
7222
7223 \series bold
7224 -dM
7225 \begin_inset LatexCommand \index{-dM}
7226
7227 \end_inset
7228
7229
7230 \series default
7231  Tell the preprocessor to output only a list of the macro definitions that
7232  are in effect at the end of preprocessing.
7233  Used with the `-E' option.
7234 \end_layout
7235
7236 \begin_layout List
7237 \labelwidthstring 00.00.0000
7238
7239 \series bold
7240 -dD
7241 \begin_inset LatexCommand \index{-dD}
7242
7243 \end_inset
7244
7245
7246 \series default
7247  Tell the preprocessor to pass all macro definitions into the output, in
7248  their proper sequence in the rest of the output.
7249 \end_layout
7250
7251 \begin_layout List
7252 \labelwidthstring 00.00.0000
7253
7254 \series bold
7255 -dN
7256 \begin_inset LatexCommand \index{-dN}
7257
7258 \end_inset
7259
7260
7261 \size large
7262 \bar under
7263  
7264 \series default
7265 \size default
7266 \bar default
7267 Like `-dD' except that the macro arguments and contents are omitted.
7268  Only `#define name' is included in the output.
7269 \end_layout
7270
7271 \begin_layout List
7272 \labelwidthstring 00.00.0000
7273
7274 \series bold
7275 -pedantic-parse-number
7276 \begin_inset LatexCommand \index{pedantic}
7277
7278 \end_inset
7279
7280
7281 \begin_inset LatexCommand \index{-pedantic-parse-number}
7282
7283 \end_inset
7284
7285
7286 \size large
7287 \bar under
7288
7289 \begin_inset LatexCommand \label{lyx:-pedantic-parse-number}
7290
7291 \end_inset
7292
7293  
7294 \series default
7295 \size default
7296 \bar default
7297 Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed properly
7298  and the macro LO_B(3) gets expanded.
7299  See also #pragma pedantic_parse_number 
7300 \begin_inset LatexCommand \vpageref{ite:pedantic_parse_number}
7301
7302 \end_inset
7303
7304  in section
7305 \begin_inset LatexCommand \ref{sec:Pragmas}
7306
7307 \end_inset
7308
7309  
7310 \emph on
7311 Note: this functionality is not in conformance with C99 standard!
7312 \end_layout
7313
7314 \begin_layout List
7315 \labelwidthstring 00.00.0000
7316
7317 \series bold
7318 -Wp\InsetSpace ~
7319 preprocessorOption[,preprocessorOption]
7320 \series default
7321
7322 \begin_inset LatexCommand \index{-Wp preprocessorOption[,preprocessorOption]}
7323
7324 \end_inset
7325
7326 ...
7327  Pass the preprocessorOption to the preprocessor 
7328 \family typewriter
7329 sdcpp
7330 \family default
7331
7332 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
7333
7334 \end_inset
7335
7336 .
7337  SDCC uses an adapted version of the preprocessor 
7338 \emph on
7339 cpp
7340 \emph default
7341  of the GNU Compiler Collection
7342 \begin_inset LatexCommand \index{gcc (GNU Compiler Collection)}
7343
7344 \end_inset
7345
7346  (
7347 \emph on
7348 gcc
7349 \emph default
7350  
7351 \begin_inset LatexCommand \url{http://gcc.gnu.org/}
7352
7353 \end_inset
7354
7355 ), if you need more dedicated options please refer to the GCC\InsetSpace ~
7356 4.1.1\InsetSpace ~
7357 CPP\InsetSpace ~
7358 Manual
7359  at 
7360 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/software/gcc/onlinedocs/}
7361
7362 \end_inset
7363
7364 .
7365 \end_layout
7366
7367 \begin_layout Standard
7368 \begin_inset VSpace bigskip
7369 \end_inset
7370
7371
7372 \end_layout
7373
7374 \begin_layout Subsection
7375 Linker Options
7376 \begin_inset LatexCommand \index{Options linker}
7377
7378 \end_inset
7379
7380
7381 \begin_inset LatexCommand \index{Linker options}
7382
7383 \end_inset
7384
7385
7386 \end_layout
7387
7388 \begin_layout List
7389 \labelwidthstring 00.00.0000
7390
7391 \series bold
7392 -L\InsetSpace ~
7393 -
7394 \series default
7395
7396 \begin_inset ERT
7397 status collapsed
7398
7399 \begin_layout Standard
7400
7401
7402 \backslash
7403 /
7404 \end_layout
7405
7406 \end_inset
7407
7408
7409 \series bold
7410 -lib-path
7411 \begin_inset LatexCommand \index{-\/-lib-path <path>}
7412
7413 \end_inset
7414
7415
7416 \begin_inset LatexCommand \index{-L -\/-lib-path}
7417
7418 \end_inset
7419
7420
7421 \series default
7422 \InsetSpace ~
7423 <absolute path to additional libraries> This option is passed to the linkage
7424  editor's additional libraries
7425 \begin_inset LatexCommand \index{Libraries}
7426
7427 \end_inset
7428
7429  search path.
7430  The path name must be absolute.
7431  Additional library files may be specified in the command line.
7432  See section Compiling programs for more details.
7433 \end_layout
7434
7435 \begin_layout List
7436 \labelwidthstring 00.00.0000
7437
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 -xram-loc
7453 \series default
7454
7455 \begin_inset LatexCommand \index{-\/-xram-loc <Value>}
7456
7457 \end_inset
7458
7459 \InsetSpace ~
7460 <Value> The start location of the external ram
7461 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
7462
7463 \end_inset
7464
7465 , default value is 0.
7466  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7467 \begin_inset ERT
7468 status collapsed
7469
7470 \begin_layout Standard
7471
7472
7473 \backslash
7474 /
7475 \end_layout
7476
7477 \end_inset
7478
7479 -xram-loc 0x8000 or -
7480 \begin_inset ERT
7481 status collapsed
7482
7483 \begin_layout Standard
7484
7485
7486 \backslash
7487 /
7488 \end_layout
7489
7490 \end_inset
7491
7492 -xram-loc 32768.
7493 \end_layout
7494
7495 \begin_layout List
7496 \labelwidthstring 00.00.0000
7497
7498 \series bold
7499 -
7500 \begin_inset ERT
7501 status collapsed
7502
7503 \begin_layout Standard
7504
7505
7506 \backslash
7507 /
7508 \end_layout
7509
7510 \end_inset
7511
7512 -code-loc
7513 \series default
7514
7515 \begin_inset LatexCommand \index{-\/-code-loc <Value>}
7516
7517 \end_inset
7518
7519 \InsetSpace ~
7520 <Value> The start location of the code
7521 \begin_inset LatexCommand \index{code}
7522
7523 \end_inset
7524
7525  segment, default value 0.
7526  Note when this option is used the interrupt vector table
7527 \begin_inset LatexCommand \index{interrupt vector table}
7528
7529 \end_inset
7530
7531  is also relocated to the given address.
7532  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7533 \begin_inset ERT
7534 status collapsed
7535
7536 \begin_layout Standard
7537
7538
7539 \backslash
7540 /
7541 \end_layout
7542
7543 \end_inset
7544
7545 -code-loc 0x8000 or -
7546 \begin_inset ERT
7547 status collapsed
7548
7549 \begin_layout Standard
7550
7551
7552 \backslash
7553 /
7554 \end_layout
7555
7556 \end_inset
7557
7558 -code-loc 32768.
7559 \end_layout
7560
7561 \begin_layout List
7562 \labelwidthstring 00.00.0000
7563
7564 \series bold
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 -stack-loc
7579 \series default
7580
7581 \begin_inset LatexCommand \index{-\/-stack-loc <Value>}
7582
7583 \end_inset
7584
7585 \InsetSpace ~
7586 <Value> By default the stack
7587 \begin_inset LatexCommand \index{stack}
7588
7589 \end_inset
7590
7591  is placed after the data segment.
7592  Using this option the stack can be placed anywhere in the internal memory
7593  space of the 8051.
7594  The value entered can be in Hexadecimal or Decimal format, e.g.
7595  -
7596 \begin_inset ERT
7597 status collapsed
7598
7599 \begin_layout Standard
7600
7601
7602 \backslash
7603 /
7604 \end_layout
7605
7606 \end_inset
7607
7608 -stack-loc 0x20 or -
7609 \begin_inset ERT
7610 status collapsed
7611
7612 \begin_layout Standard
7613
7614
7615 \backslash
7616 /
7617 \end_layout
7618
7619 \end_inset
7620
7621 -stack-loc 32.
7622  Since the sp register is incremented before a push or call, the initial
7623  sp will be set to one byte prior the provided value.
7624  The provided value should not overlap any other memory areas such as used
7625  register banks or the data segment and with enough space for the current
7626  application.
7627  The 
7628 \series bold
7629 -
7630 \begin_inset ERT
7631 status collapsed
7632
7633 \begin_layout Standard
7634
7635
7636 \backslash
7637 /
7638 \end_layout
7639
7640 \end_inset
7641
7642 -pack-iram
7643 \series default
7644 \InsetSpace ~
7645
7646 \begin_inset LatexCommand \index{-\/-pack-iram}
7647
7648 \end_inset
7649
7650  option (which is now a default setting) will override this setting, so
7651  you should also specify the 
7652 \series bold
7653 -
7654 \begin_inset ERT
7655 status collapsed
7656
7657 \begin_layout Standard
7658
7659
7660 \backslash
7661 /
7662 \end_layout
7663
7664 \end_inset
7665
7666 -no-pack-iram
7667 \series default
7668 \InsetSpace ~
7669
7670 \begin_inset LatexCommand \index{-\/-no-pack-iram}
7671
7672 \end_inset
7673
7674  option if you need to manually place the stack.
7675 \end_layout
7676
7677 \begin_layout List
7678 \labelwidthstring 00.00.0000
7679
7680 \series bold
7681 -
7682 \begin_inset ERT
7683 status collapsed
7684
7685 \begin_layout Standard
7686
7687
7688 \backslash
7689 /
7690 \end_layout
7691
7692 \end_inset
7693
7694 -xstack-loc
7695 \series default
7696
7697 \begin_inset LatexCommand \index{-\/-xstack-loc <Value>}
7698
7699 \end_inset
7700
7701 \InsetSpace ~
7702 <Value> By default the external stack
7703 \begin_inset LatexCommand \index{xstack}
7704
7705 \end_inset
7706
7707  is placed after the pdata
7708 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
7709
7710 \end_inset
7711
7712  segment.
7713  Using this option the xstack can be placed anywhere in the external memory
7714  space of the 8051.
7715  The value entered can be in Hexadecimal or Decimal format, e.g.
7716  -
7717 \begin_inset ERT
7718 status collapsed
7719
7720 \begin_layout Standard
7721
7722
7723 \backslash
7724 /
7725 \end_layout
7726
7727 \end_inset
7728
7729 -xstack-loc 0x8000 or -
7730 \begin_inset ERT
7731 status collapsed
7732
7733 \begin_layout Standard
7734
7735
7736 \backslash
7737 /
7738 \end_layout
7739
7740 \end_inset
7741
7742 -stack-loc 32768.
7743  The provided value should not overlap any other memory areas such as the
7744  pdata or xdata segment and with enough space for the current application.
7745 \end_layout
7746
7747 \begin_layout List
7748 \labelwidthstring 00.00.0000
7749
7750 \series bold
7751 -
7752 \begin_inset ERT
7753 status collapsed
7754
7755 \begin_layout Standard
7756
7757
7758 \backslash
7759 /
7760 \end_layout
7761
7762 \end_inset
7763
7764 -data-loc
7765 \series default
7766
7767 \begin_inset LatexCommand \index{-\/-data-loc <Value>}
7768
7769 \end_inset
7770
7771 \InsetSpace ~
7772 <Value> The start location of the internal ram data
7773 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
7774
7775 \end_inset
7776
7777  segment.
7778  The value entered can be in Hexadecimal or Decimal format, eg.
7779  -
7780 \begin_inset ERT
7781 status collapsed
7782
7783 \begin_layout Standard
7784
7785
7786 \backslash
7787 /
7788 \end_layout
7789
7790 \end_inset
7791
7792 -data-loc 0x20 or -
7793 \begin_inset ERT
7794 status collapsed
7795
7796 \begin_layout Standard
7797
7798
7799 \backslash
7800 /
7801 \end_layout
7802
7803 \end_inset
7804
7805 -data-loc 32.
7806  (By default, the start location of the internal ram data segment  is set
7807  as low as possible in memory, taking into account the used register banks
7808  and the bit segment at address 0x20.
7809  For example if register banks 0 and 1 are used without bit variables, the
7810  data segment will be set, if -
7811 \begin_inset ERT
7812 status collapsed
7813
7814 \begin_layout Standard
7815
7816
7817 \backslash
7818 /
7819 \end_layout
7820
7821 \end_inset
7822
7823 -data-loc is not used, to location 0x10.)
7824 \end_layout
7825
7826 \begin_layout List
7827 \labelwidthstring 00.00.0000
7828
7829 \series bold
7830 -
7831 \begin_inset ERT
7832 status collapsed
7833
7834 \begin_layout Standard
7835
7836
7837 \backslash
7838 /
7839 \end_layout
7840
7841 \end_inset
7842
7843 -idata-loc
7844 \series default
7845
7846 \begin_inset LatexCommand \index{-\/-idata-loc <Value>}
7847
7848 \end_inset
7849
7850 \InsetSpace ~
7851 <Value> The start location of the indirectly addressable internal ram
7852 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
7853
7854 \end_inset
7855
7856  of the 8051, default value is 0x80.
7857  The value entered can be in Hexadecimal or Decimal format, eg.
7858  -
7859 \begin_inset ERT
7860 status collapsed
7861
7862 \begin_layout Standard
7863
7864
7865 \backslash
7866 /
7867 \end_layout
7868
7869 \end_inset
7870
7871 -idata-loc 0x88 or -
7872 \begin_inset ERT
7873 status collapsed
7874
7875 \begin_layout Standard
7876
7877
7878 \backslash
7879 /
7880 \end_layout
7881
7882 \end_inset
7883
7884 -idata-loc 136.
7885 \end_layout
7886
7887 \begin_layout List
7888 \labelwidthstring 00.00.0000
7889
7890 \series bold
7891 -
7892 \begin_inset ERT
7893 status collapsed
7894
7895 \begin_layout Standard
7896
7897
7898 \backslash
7899 /
7900 \end_layout
7901
7902 \end_inset
7903
7904 -bit-loc
7905 \series default
7906 \InsetSpace ~
7907 <Value> The start location of the bit
7908 \begin_inset LatexCommand \index{bit}
7909
7910 \end_inset
7911
7912  addressable internal ram of the 8051.
7913  This is 
7914 \emph on
7915 not
7916 \emph default
7917  implemented yet.
7918  Instead an option can be passed directly to the linker: -Wl\InsetSpace ~
7919 -bBSEG=<Value>.
7920 \end_layout
7921
7922 \begin_layout List
7923 \labelwidthstring 00.00.0000
7924
7925 \series bold
7926 -
7927 \begin_inset ERT
7928 status collapsed
7929
7930 \begin_layout Standard
7931
7932
7933 \backslash
7934 /
7935 \end_layout
7936
7937 \end_inset
7938
7939 -out-fmt-ihx
7940 \begin_inset LatexCommand \index{-\/-out-fmt-ihx}
7941
7942 \end_inset
7943
7944
7945 \bar under
7946  
7947 \series default
7948 \bar default
7949 The linker output (final object code) is in Intel Hex format.
7950 \begin_inset LatexCommand \index{Intel hex format}
7951
7952 \end_inset
7953
7954  This is the default option.
7955  The format itself is documented in the documentation of srecord
7956 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
7957
7958 \end_inset
7959
7960 .
7961 \end_layout
7962
7963 \begin_layout List
7964 \labelwidthstring 00.00.0000
7965
7966 \series bold
7967 -
7968 \begin_inset ERT
7969 status collapsed
7970
7971 \begin_layout Standard
7972
7973
7974 \backslash
7975 /
7976 \end_layout
7977
7978 \end_inset
7979
7980 -out-fmt-s19
7981 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
7982
7983 \end_inset
7984
7985
7986 \bar under
7987  
7988 \series default
7989 \bar default
7990 The linker output (final object code) is in Motorola S19 format
7991 \begin_inset LatexCommand \index{Motorola S19 format}
7992
7993 \end_inset
7994
7995 .
7996  The format itself is documented in the documentation of srecord.
7997 \end_layout
7998
7999 \begin_layout List
8000 \labelwidthstring 00.00.0000
8001
8002 \series bold
8003 -
8004 \begin_inset ERT
8005 status collapsed
8006
8007 \begin_layout Standard
8008
8009
8010 \backslash
8011 /
8012 \end_layout
8013
8014 \end_inset
8015
8016 -out-fmt-elf
8017 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
8018
8019 \end_inset
8020
8021
8022 \begin_inset LatexCommand \index{HC08!Options!-\/-out-fmt-elf}
8023
8024 \end_inset
8025
8026
8027 \bar under
8028  
8029 \series default
8030 \bar default
8031 The linker output (final object code) is in ELF format
8032 \begin_inset LatexCommand \index{ELF format}
8033
8034 \end_inset
8035
8036 .
8037  (Currently only supported for the HC08
8038 \begin_inset LatexCommand \index{HC08}
8039
8040 \end_inset
8041
8042  processors)
8043 \end_layout
8044
8045 \begin_layout List
8046 \labelwidthstring 00.00.0000
8047
8048 \series bold
8049 -Wl\InsetSpace ~
8050 linkOption[,linkOption]
8051 \series default
8052
8053 \begin_inset LatexCommand \index{-Wl linkOption[,linkOption]}
8054
8055 \end_inset
8056
8057
8058 \begin_inset LatexCommand \label{lyx:-Wl option}
8059
8060 \end_inset
8061
8062 ...
8063  Pass the linkOption to the linker.
8064  If a bootloader is used an option like 
8065 \begin_inset Quotes sld
8066 \end_inset
8067
8068 -Wl\InsetSpace ~
8069 -bCSEG=0x1000
8070 \begin_inset Quotes srd
8071 \end_inset
8072
8073  would be typical to set the start of the code segment.
8074  Either use the double quotes around this option or use no space (e.g.
8075  -Wl-bCSEG=0x1000).
8076  See also #pragma constseg and #pragma codeseg in section 
8077 \begin_inset LatexCommand \ref{sec:Pragmas}
8078
8079 \end_inset
8080
8081  .
8082  File sdcc/as/doc/asxhtm.html has more on linker options.
8083 \end_layout
8084
8085 \begin_layout Standard
8086 \begin_inset VSpace bigskip
8087 \end_inset
8088
8089
8090 \end_layout
8091
8092 \begin_layout Subsection
8093 MCS51 Options
8094 \begin_inset LatexCommand \index{Options MCS51}
8095
8096 \end_inset
8097
8098
8099 \begin_inset LatexCommand \index{MCS51 options}
8100
8101 \end_inset
8102
8103
8104 \end_layout
8105
8106 \begin_layout List
8107 \labelwidthstring 00.00.0000
8108
8109 \series bold
8110 -
8111 \begin_inset ERT
8112 status collapsed
8113
8114 \begin_layout Standard
8115
8116
8117 \backslash
8118 /
8119 \end_layout
8120
8121 \end_inset
8122
8123 -model-small
8124 \begin_inset LatexCommand \index{-\/-model-small}
8125
8126 \end_inset
8127
8128
8129 \series default
8130 \size large
8131 \emph on
8132  
8133 \size default
8134 \emph default
8135 Generate code for Small Model programs, see section Memory Models for more
8136  details.
8137  This is the default model.
8138 \end_layout
8139
8140 \begin_layout List
8141 \labelwidthstring 00.00.0000
8142
8143 \series bold
8144 -
8145 \begin_inset ERT
8146 status collapsed
8147
8148 \begin_layout Standard
8149
8150
8151 \backslash
8152 /
8153 \end_layout
8154
8155 \end_inset
8156
8157 -model-medium
8158 \begin_inset LatexCommand \index{-\/-model-medium}
8159
8160 \end_inset
8161
8162
8163 \series default
8164  Generate code for Medium model programs, see section Memory Models for
8165  more details.
8166  If this option is used all source files in the project have to be compiled
8167  with this option.
8168  It must also be used when invoking the linker.
8169 \end_layout
8170
8171 \begin_layout List
8172 \labelwidthstring 00.00.0000
8173
8174 \series bold
8175 -
8176 \begin_inset ERT
8177 status collapsed
8178
8179 \begin_layout Standard
8180
8181
8182 \backslash
8183 /
8184 \end_layout
8185
8186 \end_inset
8187
8188 -model-large
8189 \begin_inset LatexCommand \index{-\/-model-large}
8190
8191 \end_inset
8192
8193
8194 \series default
8195  Generate code for Large model programs, see section Memory Models for more
8196  details.
8197  If this option is used all source files in the project have to be compiled
8198  with this option.
8199  It must also be used when invoking the linker.
8200 \end_layout
8201
8202 \begin_layout List
8203 \labelwidthstring 00.00.0000
8204
8205 \series bold
8206 -
8207 \begin_inset ERT
8208 status collapsed
8209
8210 \begin_layout Standard
8211
8212
8213 \backslash
8214 /
8215 \end_layout
8216
8217 \end_inset
8218
8219 -xstack
8220 \begin_inset LatexCommand \index{-\/-xstack}
8221
8222 \end_inset
8223
8224
8225 \series default
8226  Uses a pseudo stack in the pdata
8227 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
8228
8229 \end_inset
8230
8231  area (usually the first 256 bytes in the external ram) for allocating variables
8232  and passing parameters.
8233  See section 
8234 \begin_inset LatexCommand \ref{sub:External-Stack}
8235
8236 \end_inset
8237
8238 \InsetSpace ~
8239  External Stack for more details.
8240 \end_layout
8241
8242 \begin_layout List
8243 \labelwidthstring 00.00.0000
8244
8245 \series bold
8246 -
8247 \begin_inset ERT
8248 status collapsed
8249
8250 \begin_layout Standard
8251
8252
8253 \backslash
8254 /
8255 \end_layout
8256
8257 \end_inset
8258
8259 -iram-size
8260 \series default
8261 \InsetSpace ~
8262 <Value>
8263 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
8264
8265 \end_inset
8266
8267  Causes the linker to check if the internal ram usage is within limits of
8268  the given value.
8269 \end_layout
8270
8271 \begin_layout List
8272 \labelwidthstring 00.00.0000
8273
8274 \series bold
8275 -
8276 \begin_inset ERT
8277 status collapsed
8278
8279 \begin_layout Standard
8280
8281
8282 \backslash
8283 /
8284 \end_layout
8285
8286 \end_inset
8287
8288 -xram-size
8289 \series default
8290 \InsetSpace ~
8291 <Value>
8292 \begin_inset LatexCommand \index{-\/-xram-size <Value>}
8293
8294 \end_inset
8295
8296  Causes the linker to check if the external ram usage is within limits of
8297  the given value.
8298 \end_layout
8299
8300 \begin_layout List
8301 \labelwidthstring 00.00.0000
8302
8303 \series bold
8304 -
8305 \begin_inset ERT
8306 status collapsed
8307
8308 \begin_layout Standard
8309
8310
8311 \backslash
8312 /
8313 \end_layout
8314
8315 \end_inset
8316
8317 -code-size
8318 \series default
8319 \InsetSpace ~
8320 <Value>
8321 \begin_inset LatexCommand \index{-\/-code-size <Value>}
8322
8323 \end_inset
8324
8325  Causes the linker to check if the code memory usage is within limits of
8326  the given value.
8327 \end_layout
8328
8329 \begin_layout List
8330 \labelwidthstring 00.00.0000
8331
8332 \series bold
8333 -
8334 \begin_inset ERT
8335 status collapsed
8336
8337 \begin_layout Standard
8338
8339
8340 \backslash
8341 /
8342 \end_layout
8343
8344 \end_inset
8345
8346 -stack-size
8347 \series default
8348 \InsetSpace ~
8349 <Value>
8350 \begin_inset LatexCommand \index{-\/-stack-size <Value>}
8351
8352 \end_inset
8353
8354  Causes the linker to check if there is at minimum <Value> bytes for stack.
8355 \end_layout
8356
8357 \begin_layout List
8358 \labelwidthstring 00.00.0000
8359
8360 \series bold
8361 -
8362 \begin_inset ERT
8363 status collapsed
8364
8365 \begin_layout Standard
8366
8367
8368 \backslash
8369 /
8370 \end_layout
8371
8372 \end_inset
8373
8374 -pack-iram
8375 \series default
8376 \InsetSpace ~
8377
8378 \begin_inset LatexCommand \index{-\/-pack-iram}
8379
8380 \end_inset
8381
8382  Causes the linker to use unused register banks for data variables and pack
8383  data, idata and stack together.
8384  This is the default now.
8385 \end_layout
8386
8387 \begin_layout List
8388 \labelwidthstring 00.00.0000
8389
8390 \series bold
8391 -
8392 \begin_inset ERT
8393 status collapsed
8394
8395 \begin_layout Standard
8396
8397
8398 \backslash
8399 /
8400 \end_layout
8401
8402 \end_inset
8403
8404 -no-pack-iram
8405 \series default
8406 \InsetSpace ~
8407
8408 \begin_inset LatexCommand \index{-\/-no-pack-iram}
8409
8410 \end_inset
8411
8412  Causes the linker to use old style for allocating memory areas.
8413 \end_layout
8414
8415 \begin_layout List
8416 \labelwidthstring 00.00.0000
8417
8418 \series bold
8419 -
8420 \begin_inset ERT
8421 status collapsed
8422
8423 \begin_layout Standard
8424
8425
8426 \backslash
8427 /
8428 \end_layout
8429
8430 \end_inset
8431
8432 -acall-ajmp
8433 \series default
8434 \InsetSpace ~
8435
8436 \begin_inset LatexCommand \index{-\/-acall-ajmp}
8437
8438 \end_inset
8439
8440  Replaces the three byte instructions lcall/ljmp with the two byte instructions
8441  acall/ajmp.
8442  Only use this option if your code is in the same 2k block of memory.
8443  You may need to use this option for some 8051 derivatives which lack the
8444  lcall/ljmp instructions..
8445 \end_layout
8446
8447 \begin_layout Standard
8448 \begin_inset VSpace bigskip
8449 \end_inset
8450
8451
8452 \end_layout
8453
8454 \begin_layout Subsection
8455 DS390 / DS400 Options
8456 \begin_inset LatexCommand \index{Options DS390}
8457
8458 \end_inset
8459
8460
8461 \begin_inset LatexCommand \index{DS390}
8462
8463 \end_inset
8464
8465
8466 \end_layout
8467
8468 \begin_layout List
8469 \labelwidthstring 00.00.0000
8470
8471 \series bold
8472 -
8473 \begin_inset ERT
8474 status collapsed
8475
8476 \begin_layout Standard
8477
8478
8479 \backslash
8480 /
8481 \end_layout
8482
8483 \end_inset
8484
8485 -model-flat24
8486 \series default
8487
8488 \begin_inset LatexCommand \index{DS390!Options!-\/-model-flat24}
8489
8490 \end_inset
8491
8492
8493 \size large
8494 \emph on
8495  
8496 \size default
8497 \emph default
8498 Generate 24-bit flat mode code.
8499  This is the one and only that the ds390 code generator supports right now
8500  and is default when using 
8501 \emph on
8502 -mds390
8503 \emph default
8504 .
8505  See section Memory Models for more details.
8506 \end_layout
8507
8508 \begin_layout List
8509 \labelwidthstring 00.00.0000
8510
8511 \series bold
8512 -
8513 \begin_inset ERT
8514 status collapsed
8515
8516 \begin_layout Standard
8517
8518
8519 \backslash
8520 /
8521 \end_layout
8522
8523 \end_inset
8524
8525 -protect-sp-update
8526 \begin_inset LatexCommand \index{DS390!Options!-\/-protect-sp-update}
8527
8528 \end_inset
8529
8530
8531 \series default
8532  disable interrupts during ESP:SP updates.
8533 \end_layout
8534
8535 \begin_layout List
8536 \labelwidthstring 00.00.0000
8537
8538 \series bold
8539 -
8540 \begin_inset ERT
8541 status collapsed
8542
8543 \begin_layout Standard
8544
8545
8546 \backslash
8547 /
8548 \end_layout
8549
8550 \end_inset
8551
8552 -stack-10bit
8553 \series default
8554
8555 \begin_inset LatexCommand \index{DS390!Options!-\/-stack-10bit}
8556
8557 \end_inset
8558
8559  Generate code for the 10 bit stack mode of the Dallas DS80C390 part.
8560  This is the one and only that the ds390 code generator supports right now
8561  and is default when using 
8562 \emph on
8563 -mds390
8564 \emph default
8565 .
8566  In this mode, the stack is located in the lower 1K of the internal RAM,
8567  which is mapped to 0x400000.
8568  Note that the support is incomplete, since it still uses a single byte
8569  as the stack pointer.
8570  This means that only the lower 256 bytes of the potential 1K stack space
8571  will actually be used.
8572  However, this does allow you to reclaim the precious 256 bytes of low RAM
8573  for use for the DATA and IDATA segments.
8574  The compiler will not generate any code to put the processor into 10 bit
8575  stack mode.
8576  It is important to ensure that the processor is in this mode before calling
8577  any re-entrant functions compiled with this option.
8578  In principle, this should work with the 
8579 \emph on
8580 -
8581 \begin_inset ERT
8582 status collapsed
8583
8584 \begin_layout Standard
8585
8586
8587 \backslash
8588 /
8589 \end_layout
8590
8591 \end_inset
8592
8593 -stack-auto
8594 \begin_inset LatexCommand \index{-\/-stack-auto}
8595
8596 \end_inset
8597
8598
8599 \emph default
8600  option, but that has not been tested.
8601  It is incompatible with the 
8602 \emph on
8603 -
8604 \begin_inset ERT
8605 status collapsed
8606
8607 \begin_layout Standard
8608
8609
8610 \backslash
8611 /
8612 \end_layout
8613
8614 \end_inset
8615
8616 -xstack
8617 \begin_inset LatexCommand \index{-\/-xstack}
8618
8619 \end_inset
8620
8621
8622 \emph default
8623  option.
8624  It also only makes sense if the processor is in 24 bit contiguous addressing
8625  mode (see the 
8626 \emph on
8627 -
8628 \begin_inset ERT
8629 status collapsed
8630
8631 \begin_layout Standard
8632
8633
8634 \backslash
8635 /
8636 \end_layout
8637
8638 \end_inset
8639
8640 -model-flat24 option
8641 \emph default
8642 ).
8643 \series bold
8644
8645 \begin_inset Note Note
8646 status collapsed
8647
8648 \begin_layout List
8649 \labelwidthstring 00.00.0000
8650
8651 \series bold
8652 -
8653 \begin_inset ERT
8654 status open
8655
8656 \begin_layout Standard
8657
8658
8659 \backslash
8660 /
8661 \end_layout
8662
8663 \end_inset
8664
8665 -stack-8-bit - switches off the 10-bit mode
8666 \end_layout
8667
8668 \end_inset
8669
8670
8671 \end_layout
8672
8673 \begin_layout List
8674 \labelwidthstring 00.00.0000
8675
8676 \series bold
8677 -
8678 \begin_inset ERT
8679 status collapsed
8680
8681 \begin_layout Standard
8682
8683
8684 \backslash
8685 /
8686 \end_layout
8687
8688 \end_inset
8689
8690 -stack-probe
8691 \begin_inset LatexCommand \index{DS390!Options!-\/-stack-probe}
8692
8693 \end_inset
8694
8695
8696 \series default
8697  insert call to function __stack_probe at each function prologue.
8698 \end_layout
8699
8700 \begin_layout List
8701 \labelwidthstring 00.00.0000
8702
8703 \series bold
8704 -
8705 \begin_inset ERT
8706 status open
8707
8708 \begin_layout Standard
8709
8710
8711 \backslash
8712 /
8713 \end_layout
8714
8715 \end_inset
8716
8717 -tini-libid
8718 \begin_inset LatexCommand \index{DS390!Options!-\/-tini-libid}
8719
8720 \end_inset
8721
8722
8723 \series default
8724  <nnnn> LibraryID used in -mTININative.
8725  
8726 \end_layout
8727
8728 \begin_layout List
8729 \labelwidthstring 00.00.0000
8730
8731 \series bold
8732 -
8733 \begin_inset ERT
8734 status collapsed
8735
8736 \begin_layout Standard
8737
8738
8739 \backslash
8740 /
8741 \end_layout
8742
8743 \end_inset
8744
8745 -use-accelerator
8746 \begin_inset LatexCommand \index{DS390!Options!-\/-use-accelerator}
8747
8748 \end_inset
8749
8750
8751 \series default
8752  generate code for DS390 Arithmetic Accelerator.
8753  
8754 \end_layout
8755
8756 \begin_layout Standard
8757 \begin_inset VSpace bigskip
8758 \end_inset
8759
8760
8761 \end_layout
8762
8763 \begin_layout Subsection
8764 Z80 Options
8765 \begin_inset LatexCommand \index{Options Z80}
8766
8767 \end_inset
8768
8769
8770 \begin_inset LatexCommand \index{Z80}
8771
8772 \end_inset
8773
8774
8775 \end_layout
8776
8777 \begin_layout List
8778 \labelwidthstring 00.00.0000
8779
8780 \series bold
8781 -
8782 \begin_inset ERT
8783 status collapsed
8784
8785 \begin_layout Standard
8786
8787
8788 \backslash
8789 /
8790 \end_layout
8791
8792 \end_inset
8793
8794 -callee-saves-bc
8795 \series default
8796
8797 \begin_inset LatexCommand \index{Z80!Options!-\/-callee-saves-bc}
8798
8799 \end_inset
8800
8801
8802 \size large
8803 \emph on
8804  
8805 \size default
8806 \emph default
8807 Force a called function to always save BC.
8808 \end_layout
8809
8810 \begin_layout List
8811 \labelwidthstring 00.00.0000
8812
8813 \series bold
8814 -
8815 \begin_inset ERT
8816 status collapsed
8817
8818 \begin_layout Standard
8819
8820
8821 \backslash
8822 /
8823 \end_layout
8824
8825 \end_inset
8826
8827 -no-std-crt0
8828 \series default
8829
8830 \begin_inset LatexCommand \index{Z80!Options!-\/-no-std-crt0}
8831
8832 \end_inset
8833
8834  When linking, skip the standard crt0.o object file.
8835  You must provide your own crt0.o for your system when linking.
8836 \end_layout
8837
8838 \begin_layout List
8839 \labelwidthstring 00.00.0000
8840
8841 \series bold
8842 -
8843 \begin_inset ERT
8844 status collapsed
8845
8846 \begin_layout Standard
8847
8848
8849 \backslash
8850 /
8851 \end_layout
8852
8853 \end_inset
8854
8855 -portmode=
8856 \series default
8857 <Value>
8858 \begin_inset LatexCommand \index{Z80!Options!-\/-portmode=<Value>}
8859
8860 \end_inset
8861
8862  Determinate PORT I/O mode (<Value> is z80 or z180).
8863 \end_layout
8864
8865 \begin_layout List
8866 \labelwidthstring 00.00.0000
8867
8868 \series bold
8869 -
8870 \begin_inset ERT
8871 status collapsed
8872
8873 \begin_layout Standard
8874
8875
8876 \backslash
8877 /
8878 \end_layout
8879
8880 \end_inset
8881
8882 -asm=
8883 \series default
8884 <Value>
8885 \begin_inset LatexCommand \index{Z80!Options!-\/-asm=<Value>}
8886
8887 \end_inset
8888
8889  Define assembler name (<Value> is rgbds, asxxxx, isas or z80asm).
8890 \end_layout
8891
8892 \begin_layout List
8893 \labelwidthstring 00.00.0000
8894
8895 \series bold
8896 -
8897 \begin_inset ERT
8898 status collapsed
8899
8900 \begin_layout Standard
8901
8902
8903 \backslash
8904 /
8905 \end_layout
8906
8907 \end_inset
8908
8909 -codeseg
8910 \series default
8911 \InsetSpace ~
8912 <Value>
8913 \begin_inset LatexCommand \index{Z80!Options!-\/-codeseg <Value>}
8914
8915 \end_inset
8916
8917  Use <Value> for the code segment name.
8918 \end_layout
8919
8920 \begin_layout List
8921 \labelwidthstring 00.00.0000
8922
8923 \series bold
8924 -
8925 \begin_inset ERT
8926 status collapsed
8927
8928 \begin_layout Standard
8929
8930
8931 \backslash
8932 /
8933 \end_layout
8934
8935 \end_inset
8936
8937 -constseg
8938 \series default
8939 \InsetSpace ~
8940 <Value>
8941 \begin_inset LatexCommand \index{Z80!Options!-\/-constseg <Value>}
8942
8943 \end_inset
8944
8945  Use <Value> for the const segment name.
8946 \end_layout
8947
8948 \begin_layout List
8949 \labelwidthstring 00.00.0000
8950 \begin_inset VSpace bigskip
8951 \end_inset
8952
8953
8954 \end_layout
8955
8956 \begin_layout Subsection
8957 GBZ80 Options
8958 \begin_inset LatexCommand \index{Options GBZ80}
8959
8960 \end_inset
8961
8962
8963 \begin_inset LatexCommand \index{GBZ80}
8964
8965 \end_inset
8966
8967
8968 \end_layout
8969
8970 \begin_layout List
8971 \labelwidthstring 00.00.0000
8972
8973 \series bold
8974 -
8975 \begin_inset ERT
8976 status collapsed
8977
8978 \begin_layout Standard
8979
8980
8981 \backslash
8982 /
8983 \end_layout
8984
8985 \end_inset
8986
8987 -callee-saves-bc
8988 \series default
8989
8990 \begin_inset LatexCommand \index{GBZ80!Options!-\/-callee-saves-bc}
8991
8992 \end_inset
8993
8994
8995 \size large
8996 \emph on
8997  
8998 \size default
8999 \emph default
9000 Force a called function to always save BC.
9001 \end_layout
9002
9003 \begin_layout List
9004 \labelwidthstring 00.00.0000
9005
9006 \series bold
9007 -
9008 \begin_inset ERT
9009 status collapsed
9010
9011 \begin_layout Standard
9012
9013
9014 \backslash
9015 /
9016 \end_layout
9017
9018 \end_inset
9019
9020 -no-std-crt0
9021 \series default
9022
9023 \begin_inset LatexCommand \index{Z80!Options!-\/-no-std-crt0}
9024
9025 \end_inset
9026
9027  When linking, skip the standard crt0.o object file.
9028  You must provide your own crt0.o for your system when linking.
9029 \end_layout
9030
9031 \begin_layout List
9032 \labelwidthstring 00.00.0000
9033
9034 \series bold
9035 -bo
9036 \series default
9037 \InsetSpace ~
9038 <Num>
9039 \begin_inset LatexCommand \index{GBZ80!Options!-bo <Num>}
9040
9041 \end_inset
9042
9043  Use code bank <Num>.
9044 \end_layout
9045
9046 \begin_layout List
9047 \labelwidthstring 00.00.0000
9048
9049 \series bold
9050 -ba
9051 \series default
9052 \InsetSpace ~
9053 <Num>
9054 \begin_inset LatexCommand \index{GBZ80!Options!-ba <Num>}
9055
9056 \end_inset
9057
9058  Use data bank <Num>.
9059 \end_layout
9060
9061 \begin_layout List
9062 \labelwidthstring 00.00.0000
9063
9064 \series bold
9065 -
9066 \begin_inset ERT
9067 status collapsed
9068
9069 \begin_layout Standard
9070
9071
9072 \backslash
9073 /
9074 \end_layout
9075
9076 \end_inset
9077
9078 -codeseg
9079 \series default
9080 \InsetSpace ~
9081 <Value>
9082 \begin_inset LatexCommand \index{GBZ80!Options!-\/-codeseg <Value>}
9083
9084 \end_inset
9085
9086  Use <Value> for the code segment name.
9087 \end_layout
9088
9089 \begin_layout List
9090 \labelwidthstring 00.00.0000
9091
9092 \series bold
9093 -
9094 \begin_inset ERT
9095 status collapsed
9096
9097 \begin_layout Standard
9098
9099
9100 \backslash
9101 /
9102 \end_layout
9103
9104 \end_inset
9105
9106 -constseg
9107 \series default
9108 \InsetSpace ~
9109 <Value>
9110 \begin_inset LatexCommand \index{GBZ80!Options!-\/-constseg <Value>}
9111
9112 \end_inset
9113
9114  Use <Value> for the const segment name.
9115 \end_layout
9116
9117 \begin_layout Standard
9118 \begin_inset VSpace bigskip
9119 \end_inset
9120
9121
9122 \end_layout
9123
9124 \begin_layout Subsection
9125 Optimization Options
9126 \begin_inset LatexCommand \index{Options optimization}
9127
9128 \end_inset
9129
9130
9131 \begin_inset LatexCommand \index{Optimization options}
9132
9133 \end_inset
9134
9135
9136 \end_layout
9137
9138 \begin_layout List
9139 \labelwidthstring 00.00.0000
9140
9141 \series bold
9142 -
9143 \begin_inset ERT
9144 status collapsed
9145
9146 \begin_layout Standard
9147
9148
9149 \backslash
9150 /
9151 \end_layout
9152
9153 \end_inset
9154
9155 -nogcse
9156 \begin_inset LatexCommand \index{-\/-nogcse}
9157
9158 \end_inset
9159
9160
9161 \series default
9162  Will not do global subexpression elimination, this option may be used when
9163  the compiler creates undesirably large stack/data spaces to store compiler
9164  temporaries (
9165 \emph on
9166 s
9167 \emph default
9168 pill 
9169 \emph on
9170 loc
9171 \emph default
9172 ations, sloc
9173 \begin_inset LatexCommand \index{sloc (spill location)}
9174
9175 \end_inset
9176
9177 ).
9178  A warning message will be generated when this happens and the compiler
9179  will indicate the number of extra bytes it allocated.
9180  It is recommended that this option NOT be used, #pragma\InsetSpace ~
9181 nogcse
9182 \begin_inset LatexCommand \index{\#pragma nogcse}
9183
9184 \end_inset
9185
9186  can be used to turn off global subexpression elimination
9187 \begin_inset LatexCommand \index{Subexpression elimination}
9188
9189 \end_inset
9190
9191  for a given function only.
9192 \end_layout
9193
9194 \begin_layout List
9195 \labelwidthstring 00.00.0000
9196
9197 \series bold
9198 -
9199 \begin_inset ERT
9200 status collapsed
9201
9202 \begin_layout Standard
9203
9204
9205 \backslash
9206 /
9207 \end_layout
9208
9209 \end_inset
9210
9211 -noinvariant
9212 \begin_inset LatexCommand \index{-\/-noinvariant}
9213
9214 \end_inset
9215
9216
9217 \series default
9218  Will not do loop invariant optimizations, this may be turned off for reasons
9219  explained for the previous option.
9220  For more details of loop optimizations performed see Loop Invariants in
9221  section 
9222 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
9223
9224 \end_inset
9225
9226 .
9227  It is recommended that this option NOT be used, #pragma\InsetSpace ~
9228 noinvariant
9229 \begin_inset LatexCommand \index{\#pragma noinvariant}
9230
9231 \end_inset
9232
9233  can be used to turn off invariant optimizations for a given function only.
9234 \end_layout
9235
9236 \begin_layout List
9237 \labelwidthstring 00.00.0000
9238
9239 \series bold
9240 -
9241 \begin_inset ERT
9242 status collapsed
9243
9244 \begin_layout Standard
9245
9246
9247 \backslash
9248 /
9249 \end_layout
9250
9251 \end_inset
9252
9253 -noinduction
9254 \begin_inset LatexCommand \index{-\/-noinduction}
9255
9256 \end_inset
9257
9258
9259 \series default
9260  Will not do loop induction optimizations, see section strength reduction
9261  for more details.
9262  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9263 noinduction
9264 \begin_inset LatexCommand \index{\#pragma noinduction}
9265
9266 \end_inset
9267
9268  can be used to turn off induction optimizations for a given function only.
9269 \end_layout
9270
9271 \begin_layout List
9272 \labelwidthstring 00.00.0000
9273
9274 \series bold
9275 -
9276 \begin_inset ERT
9277 status collapsed
9278
9279 \begin_layout Standard
9280
9281
9282 \backslash
9283 /
9284 \end_layout
9285
9286 \end_inset
9287
9288 -nojtbound
9289 \begin_inset LatexCommand \index{-\/-nojtbound}
9290
9291 \end_inset
9292
9293
9294 \size large
9295 \bar under
9296  
9297 \series default
9298 \size default
9299 \bar default
9300  Will not generate boundary condition check when switch statements
9301 \begin_inset LatexCommand \index{switch statement}
9302
9303 \end_inset
9304
9305  are implemented using jump-tables.
9306  See section 
9307 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
9308
9309 \end_inset
9310
9311 \InsetSpace ~
9312 Switch Statements for more details.
9313  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9314 nojtbound
9315 \begin_inset LatexCommand \index{\#pragma nojtbound}
9316
9317 \end_inset
9318
9319  can be used to turn off boundary checking for jump tables for a given function
9320  only.
9321 \end_layout
9322
9323 \begin_layout List
9324 \labelwidthstring 00.00.0000
9325
9326 \series bold
9327 -
9328 \begin_inset ERT
9329 status collapsed
9330
9331 \begin_layout Standard
9332
9333
9334 \backslash
9335 /
9336 \end_layout
9337
9338 \end_inset
9339
9340 -noloopreverse
9341 \begin_inset LatexCommand \index{-\/-noloopreverse}
9342
9343 \end_inset
9344
9345
9346 \series default
9347 \size large
9348  
9349 \size default
9350 Will not do loop reversal 
9351 \begin_inset LatexCommand \index{Loop reversing}
9352
9353 \end_inset
9354
9355 optimization.
9356 \end_layout
9357
9358 \begin_layout List
9359 \labelwidthstring 00.00.0000
9360 -
9361 \begin_inset ERT
9362 status collapsed
9363
9364 \begin_layout Standard
9365
9366
9367 \backslash
9368 /
9369 \end_layout
9370
9371 \end_inset
9372
9373 -
9374 \series bold
9375 nolabelopt
9376 \series default
9377  
9378 \begin_inset LatexCommand \index{-\/-nolabelopt }
9379
9380 \end_inset
9381
9382 Will not optimize labels (makes the dumpfiles more readable).
9383 \end_layout
9384
9385 \begin_layout List
9386 \labelwidthstring 00.00.0000
9387
9388 \series bold
9389 -
9390 \begin_inset ERT
9391 status collapsed
9392
9393 \begin_layout Standard
9394
9395
9396 \backslash
9397 /
9398 \end_layout
9399
9400 \end_inset
9401
9402 -no-xinit-opt
9403 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
9404
9405 \end_inset
9406
9407
9408 \series default
9409  Will not memcpy initialized data from code space into xdata space.
9410  This saves a few bytes in code space if you don't have initialized data
9411 \begin_inset LatexCommand \index{Variable initialization}
9412
9413 \end_inset
9414
9415 .
9416 \end_layout
9417
9418 \begin_layout List
9419 \labelwidthstring 00.00.0000
9420
9421 \series bold
9422 -
9423 \begin_inset ERT
9424 status collapsed
9425
9426 \begin_layout Standard
9427
9428
9429 \backslash
9430 /
9431 \end_layout
9432
9433 \end_inset
9434
9435 -nooverlay
9436 \begin_inset LatexCommand \index{-\/-nooverlay}
9437
9438 \end_inset
9439
9440
9441 \series default
9442   The compiler will not overlay parameters and local variables of any function,
9443  see section Parameters and local variables for more details.
9444 \end_layout
9445
9446 \begin_layout List
9447 \labelwidthstring 00.00.0000
9448
9449 \series bold
9450 -
9451 \begin_inset ERT
9452 status collapsed
9453
9454 \begin_layout Standard
9455
9456
9457 \backslash
9458 /
9459 \end_layout
9460
9461 \end_inset
9462
9463 -no-peep
9464 \begin_inset LatexCommand \index{-\/-no-peep}
9465
9466 \end_inset
9467
9468
9469 \series default
9470  Disable peep-hole optimization with built-in rules.
9471 \end_layout
9472
9473 \begin_layout List
9474 \labelwidthstring 00.00.0000
9475
9476 \series bold
9477 -
9478 \begin_inset ERT
9479 status collapsed
9480
9481 \begin_layout Standard
9482
9483
9484 \backslash
9485 /
9486 \end_layout
9487
9488 \end_inset
9489
9490 -peep-file
9491 \series default
9492
9493 \begin_inset LatexCommand \index{-\/-peep-file}
9494
9495 \end_inset
9496
9497 \InsetSpace ~
9498 <filename> This option can be used to use additional rules to be used by
9499  the peep hole optimizer.
9500  See section 
9501 \begin_inset LatexCommand \ref{sub:Peephole-Optimizer}
9502
9503 \end_inset
9504
9505 \InsetSpace ~
9506 Peep Hole optimizations for details on how to write these rules.
9507 \end_layout
9508
9509 \begin_layout List
9510 \labelwidthstring 00.00.0000
9511
9512 \series bold
9513 -
9514 \begin_inset ERT
9515 status collapsed
9516
9517 \begin_layout Standard
9518
9519
9520 \backslash
9521 /
9522 \end_layout
9523
9524 \end_inset
9525
9526 -peep-asm
9527 \begin_inset LatexCommand \index{-\/-peep-asm}
9528
9529 \end_inset
9530
9531
9532 \series default
9533  Pass the inline assembler code through the peep hole optimizer.
9534  This can cause unexpected changes to inline assembler code, please go through
9535  the peephole optimizer
9536 \begin_inset LatexCommand \index{Peephole optimizer}
9537
9538 \end_inset
9539
9540  rules defined in the source file tree '<target>/peeph.def' before using
9541  this option.
9542 \end_layout
9543
9544 \begin_layout List
9545 \labelwidthstring 00.00.0000
9546
9547 \series bold
9548 -
9549 \begin_inset ERT
9550 status collapsed
9551
9552 \begin_layout Standard
9553
9554
9555 \backslash
9556 /
9557 \end_layout
9558
9559 \end_inset
9560
9561 -opt-code-speed
9562 \begin_inset LatexCommand \index{-\/-opt-code-speed}
9563
9564 \end_inset
9565
9566
9567 \series default
9568  The compiler will optimize code generation towards fast code, possibly
9569  at the expense of code size.
9570 \end_layout
9571
9572 \begin_layout List
9573 \labelwidthstring 00.00.0000
9574
9575 \series bold
9576 -
9577 \begin_inset ERT
9578 status collapsed
9579
9580 \begin_layout Standard
9581
9582
9583 \backslash
9584 /
9585 \end_layout
9586
9587 \end_inset
9588
9589 -opt-code-size
9590 \begin_inset LatexCommand \index{-\/-opt-code-size}
9591
9592 \end_inset
9593
9594
9595 \series default
9596  The compiler will optimize code generation towards compact code, possibly
9597  at the expense of code speed.
9598 \end_layout
9599
9600 \begin_layout Standard
9601 \begin_inset VSpace bigskip
9602 \end_inset
9603
9604
9605 \end_layout
9606
9607 \begin_layout Subsection
9608 Other Options
9609 \begin_inset LatexCommand \index{Options other}
9610
9611 \end_inset
9612
9613
9614 \end_layout
9615
9616 \begin_layout List
9617 \labelwidthstring 00.00.0000
9618
9619 \series bold
9620 -c\InsetSpace ~
9621 -
9622 \begin_inset ERT
9623 status collapsed
9624
9625 \begin_layout Standard
9626
9627
9628 \backslash
9629 /
9630 \end_layout
9631
9632 \end_inset
9633
9634 -compile-only
9635 \begin_inset LatexCommand \index{-\/-compile-only}
9636
9637 \end_inset
9638
9639
9640 \begin_inset LatexCommand \index{-c -\/-compile-only}
9641
9642 \end_inset
9643
9644
9645 \series default
9646  will compile and assemble the source, but will not call the linkage editor.
9647 \end_layout
9648
9649 \begin_layout List
9650 \labelwidthstring 00.00.0000
9651
9652 \series bold
9653 -
9654 \series default
9655
9656 \begin_inset ERT
9657 status collapsed
9658
9659 \begin_layout Standard
9660
9661
9662 \backslash
9663 /
9664 \end_layout
9665
9666 \end_inset
9667
9668
9669 \series bold
9670 -c1mode
9671 \begin_inset LatexCommand \index{-\/-c1mode}
9672
9673 \end_inset
9674
9675
9676 \series default
9677  reads the preprocessed source from standard input and compiles it.
9678  The file name for the assembler output must be specified using the -o option.
9679 \end_layout
9680
9681 \begin_layout List
9682 \labelwidthstring 00.00.0000
9683
9684 \series bold
9685 -E
9686 \begin_inset LatexCommand \index{-E}
9687
9688 \end_inset
9689
9690
9691 \series default
9692  Run only the C preprocessor.
9693  Preprocess all the C source files specified and output the results to standard
9694  output.
9695 \end_layout
9696
9697 \begin_layout List
9698 \labelwidthstring 00.00.0000
9699
9700 \series bold
9701 -o\InsetSpace ~
9702 <path/file>
9703 \begin_inset LatexCommand \index{-o <path/file>}
9704
9705 \end_inset
9706
9707  
9708 \series default
9709 The output path where everything will be placed or the file name used for
9710  all generated output files.
9711  If the parameter is a path, it must have a trailing slash (or backslash
9712  for the Windows binaries) to be recognized as a path.
9713
9714 \emph on
9715  
9716 \emph default
9717 Note for Windows users: if the path contains spaces, it should be surrounded
9718  by quotes.
9719  The trailing backslash should be doubled in order to prevent escaping the
9720  final quote, for example: 
9721 \emph on
9722 -o 
9723 \begin_inset Quotes sld
9724 \end_inset
9725
9726 F:
9727 \backslash
9728 Projects
9729 \backslash
9730 test3
9731 \backslash
9732 output 1
9733 \backslash
9734
9735 \backslash
9736
9737 \begin_inset Quotes srd
9738 \end_inset
9739
9740
9741 \emph default
9742  or put after the final quote, for example: 
9743 \emph on
9744 -o 
9745 \begin_inset Quotes sld
9746 \end_inset
9747
9748 F:
9749 \backslash
9750 Projects
9751 \backslash
9752 test3
9753 \backslash
9754 output 1
9755 \begin_inset Quotes srd
9756 \end_inset
9757
9758
9759 \backslash
9760
9761 \emph default
9762 .
9763  The path using slashes for directory delimiters can be used too, for example:
9764  
9765 \emph on
9766 -o 
9767 \begin_inset Quotes sld
9768 \end_inset
9769
9770 F:/Projects/test3/output 1/
9771 \begin_inset Quotes srd
9772 \end_inset
9773
9774
9775 \emph default
9776 .
9777 \end_layout
9778
9779 \begin_layout List
9780 \labelwidthstring 00.00.0000
9781
9782 \series bold
9783 -
9784 \begin_inset ERT
9785 status collapsed
9786
9787 \begin_layout Standard
9788
9789
9790 \backslash
9791 /
9792 \end_layout
9793
9794 \end_inset
9795
9796 -stack-auto
9797 \begin_inset LatexCommand \index{-\/-stack-auto}
9798
9799 \end_inset
9800
9801
9802 \series default
9803 \size large
9804 \emph on
9805  
9806 \size default
9807 \emph default
9808 All functions in the source file will be compiled as 
9809 \emph on
9810 reentrant
9811 \emph default
9812
9813 \begin_inset LatexCommand \index{reentrant}
9814
9815 \end_inset
9816
9817 , i.e.
9818  the parameters and local variables will be allocated on the stack
9819 \begin_inset LatexCommand \index{stack}
9820
9821 \end_inset
9822
9823 .
9824  See section 
9825 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
9826
9827 \end_inset
9828
9829  Parameters and Local Variables for more details.
9830  If this option is used all source files in the project should be compiled
9831  with this option.
9832  It automatically implies -
9833 \series bold
9834
9835 \begin_inset ERT
9836 status open
9837
9838 \begin_layout Standard
9839
9840
9841 \backslash
9842 /
9843 \end_layout
9844
9845 \end_inset
9846
9847
9848 \series default
9849 -int-long-reent and -
9850 \series bold
9851
9852 \begin_inset ERT
9853 status open
9854
9855 \begin_layout Standard
9856
9857
9858 \backslash
9859 /
9860 \end_layout
9861
9862 \end_inset
9863
9864
9865 \series default
9866 -float-reent.
9867  
9868 \end_layout
9869
9870 \begin_layout List
9871 \labelwidthstring 00.00.0000
9872
9873 \series bold
9874 -
9875 \begin_inset ERT
9876 status collapsed
9877
9878 \begin_layout Standard
9879
9880
9881 \backslash
9882 /
9883 \end_layout
9884
9885 \end_inset
9886
9887 -callee-saves
9888 \begin_inset LatexCommand \index{-\/-callee-saves}
9889
9890 \end_inset
9891
9892  
9893 \begin_inset LatexCommand \label{lyx:--callee-saves-function1[,function2][,function3]...}
9894
9895 \end_inset
9896
9897 function1[,function2][,function3]....
9898
9899 \series default
9900  The compiler by default uses a caller saves convention for register saving
9901  across function calls, however this can cause unnecessary register pushing
9902  and popping when calling small functions from larger functions.
9903  This option can be used to switch the register saving convention for the
9904  function names specified.
9905  The compiler will not save registers when calling these functions, no extra
9906  code will be generated at the entry and exit (function prologue
9907 \series bold
9908
9909 \begin_inset LatexCommand \index{function prologue}
9910
9911 \end_inset
9912
9913
9914 \series default
9915  and epilogue
9916 \series bold
9917
9918 \begin_inset LatexCommand \index{function epilogue}
9919
9920 \end_inset
9921
9922
9923 \series default
9924 ) for these functions to save and restore the registers used by these functions,
9925  this can SUBSTANTIALLY reduce code and improve run time performance of
9926  the generated code.
9927  In the future the compiler (with inter procedural analysis) will be able
9928  to determine the appropriate scheme to use for each function call.
9929  DO NOT use this option for built-in functions such as _mulint..., if this
9930  option is used for a library function the appropriate library function
9931  needs to be recompiled with the same option.
9932  If the project consists of multiple source files then all the source file
9933  should be compiled with the same -
9934 \begin_inset ERT
9935 status collapsed
9936
9937 \begin_layout Standard
9938
9939
9940 \backslash
9941 /
9942 \end_layout
9943
9944 \end_inset
9945
9946 -callee-saves option string.
9947  Also see #pragma\InsetSpace ~
9948 callee_saves 
9949 \begin_inset LatexCommand \index{\#pragma callee\_saves}
9950
9951 \end_inset
9952
9953  
9954 \begin_inset LatexCommand \vpageref{ite:callee_saves-function1[,function2[,function3...]]--}
9955
9956 \end_inset
9957
9958 .
9959 \end_layout
9960
9961 \begin_layout List
9962 \labelwidthstring 00.00.0000
9963
9964 \series bold
9965 -
9966 \begin_inset ERT
9967 status collapsed
9968
9969 \begin_layout Standard
9970
9971
9972 \backslash
9973 /
9974 \end_layout
9975
9976 \end_inset
9977
9978 -all-callee-saves
9979 \begin_inset LatexCommand \index{-\/-all-callee-saves}
9980
9981 \end_inset
9982
9983  
9984 \series default
9985 Function of
9986 \series bold
9987  
9988 \series default
9989 -
9990 \begin_inset ERT
9991 status collapsed
9992
9993 \begin_layout Standard
9994
9995
9996 \backslash
9997 /
9998 \end_layout
9999
10000 \end_inset
10001
10002 -callee-saves will be applied to all functions by default.
10003 \end_layout
10004
10005 \begin_layout List
10006 \labelwidthstring 00.00.0000
10007
10008 \series bold
10009 -
10010 \begin_inset ERT
10011 status collapsed
10012
10013 \begin_layout Standard
10014
10015
10016 \backslash
10017 /
10018 \end_layout
10019
10020 \end_inset
10021
10022 -debug
10023 \begin_inset LatexCommand \index{-\/-debug}
10024
10025 \end_inset
10026
10027
10028 \bar under
10029  
10030 \series default
10031 \bar default
10032 When this option is used the compiler will generate debug information.
10033  The debug information collected in a file with .cdb extension can be used
10034  with the SDCDB.
10035  For more information see documentation for SDCDB.
10036  Another file with no extension contains debug information in AOMF or AOMF51
10037 \begin_inset LatexCommand \index{AOMF, AOMF51}
10038
10039 \end_inset
10040
10041  format which is commonly used by third party tools.
10042 \end_layout
10043
10044 \begin_layout List
10045 \labelwidthstring 00.00.0000
10046
10047 \series bold
10048 -S
10049 \begin_inset LatexCommand \index{-S}
10050
10051 \end_inset
10052
10053
10054 \size large
10055 \bar under
10056  
10057 \series default
10058 \size default
10059 \bar default
10060 Stop after the stage of compilation proper; do not assemble.
10061  The output is an assembler code file for the input file specified.
10062 \end_layout
10063
10064 \begin_layout List
10065 \labelwidthstring 00.00.0000
10066
10067 \series bold
10068 -
10069 \begin_inset ERT
10070 status collapsed
10071
10072 \begin_layout Standard
10073
10074
10075 \backslash
10076 /
10077 \end_layout
10078
10079 \end_inset
10080
10081 -int-long-reent
10082 \begin_inset LatexCommand \index{-\/-int-long-reent}
10083
10084 \end_inset
10085
10086
10087 \series default
10088  Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
10089  Note by default these libraries are compiled as non-reentrant.
10090  See section Installation for more details.
10091 \end_layout
10092
10093 \begin_layout List
10094 \labelwidthstring 00.00.0000
10095
10096 \series bold
10097 -
10098 \begin_inset ERT
10099 status collapsed
10100
10101 \begin_layout Standard
10102
10103
10104 \backslash
10105 /
10106 \end_layout
10107
10108 \end_inset
10109
10110 -cyclomatic
10111 \begin_inset LatexCommand \index{-\/-cyclomatic}
10112
10113 \end_inset
10114
10115
10116 \bar under
10117  
10118 \series default
10119 \bar default
10120 This option will cause the compiler to generate an information message for
10121  each function in the source file.
10122  The message contains some 
10123 \emph on
10124 important
10125 \emph default
10126  information about the function.
10127  The number of edges and nodes the compiler detected in the control flow
10128  graph of the function, and most importantly the 
10129 \emph on
10130 cyclomatic complexity
10131 \begin_inset LatexCommand \index{Cyclomatic complexity}
10132
10133 \end_inset
10134
10135
10136 \emph default
10137  see section on Cyclomatic Complexity for more details.
10138 \end_layout
10139
10140 \begin_layout List
10141 \labelwidthstring 00.00.0000
10142
10143 \series bold
10144 -
10145 \begin_inset ERT
10146 status collapsed
10147
10148 \begin_layout Standard
10149
10150
10151 \backslash
10152 /
10153 \end_layout
10154
10155 \end_inset
10156
10157 -float-reent
10158 \begin_inset LatexCommand \index{-\/-float-reent}
10159
10160 \end_inset
10161
10162
10163 \series default
10164  Floating point library is compiled as reentrant
10165 \begin_inset LatexCommand \index{reentrant}
10166
10167 \end_inset
10168
10169 .
10170  See section Installation for more details.
10171 \end_layout
10172
10173 \begin_layout List
10174 \labelwidthstring 00.00.0000
10175
10176 \series bold
10177 -
10178 \begin_inset ERT
10179 status collapsed
10180
10181 \begin_layout Standard
10182
10183
10184 \backslash
10185 /
10186 \end_layout
10187
10188 \end_inset
10189
10190 -funsigned-char
10191 \begin_inset LatexCommand \index{-\/-funsigned-char}
10192
10193 \end_inset
10194
10195
10196 \series default
10197  The default signedness for every type is
10198 \family typewriter
10199  signed
10200 \family default
10201 .
10202  In some embedded environments the default signedness of
10203 \family typewriter
10204  char
10205 \family default
10206  is
10207 \family typewriter
10208  unsigned
10209 \family default
10210 .
10211  To set the signess for characters to unsigned, use the option -
10212 \series bold
10213
10214 \begin_inset ERT
10215 status open
10216
10217 \begin_layout Standard
10218
10219
10220 \backslash
10221 /
10222 \end_layout
10223
10224 \end_inset
10225
10226
10227 \series default
10228 -funsigned-char.
10229  If this option is set and no signedness keyword (unsigned/signed) is given,
10230  a char will be signed.
10231  All other types are unaffected.
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 -main-return
10252 \begin_inset LatexCommand \index{-\/-main-return}
10253
10254 \end_inset
10255
10256
10257 \series default
10258  This option can be used if the code generated is called by a monitor program
10259  or if the main routine includes an endless loop.
10260  This option results in slightly smaller code and saves two bytes of stack
10261  space.
10262  The return from the 'main'
10263 \begin_inset LatexCommand \index{main return}
10264
10265 \end_inset
10266
10267  function will return to the function calling main.
10268  The default setting is to lock up i.e.
10269  generate a '
10270 \family typewriter
10271 sjmp .
10272 \family default
10273 '.
10274 \end_layout
10275
10276 \begin_layout List
10277 \labelwidthstring 00.00.0000
10278
10279 \series bold
10280 -
10281 \begin_inset ERT
10282 status collapsed
10283
10284 \begin_layout Standard
10285
10286
10287 \backslash
10288 /
10289 \end_layout
10290
10291 \end_inset
10292
10293 -nostdinc
10294 \begin_inset LatexCommand \index{-\/-nostdinc}
10295
10296 \end_inset
10297
10298
10299 \series default
10300  This will prevent the compiler from passing on the default include path
10301  to the preprocessor.
10302 \end_layout
10303
10304 \begin_layout List
10305 \labelwidthstring 00.00.0000
10306
10307 \series bold
10308 -
10309 \begin_inset ERT
10310 status collapsed
10311
10312 \begin_layout Standard
10313
10314
10315 \backslash
10316 /
10317 \end_layout
10318
10319 \end_inset
10320
10321 -nostdlib
10322 \begin_inset LatexCommand \index{-\/-nostdlib}
10323
10324 \end_inset
10325
10326
10327 \series default
10328  This will prevent the compiler from passing on the default library
10329 \begin_inset LatexCommand \index{Libraries}
10330
10331 \end_inset
10332
10333  path to the linker.
10334 \end_layout
10335
10336 \begin_layout List
10337 \labelwidthstring 00.00.0000
10338
10339 \series bold
10340 -
10341 \begin_inset ERT
10342 status collapsed
10343
10344 \begin_layout Standard
10345
10346
10347 \backslash
10348 /
10349 \end_layout
10350
10351 \end_inset
10352
10353 -verbose
10354 \begin_inset LatexCommand \index{-\/-verbose}
10355
10356 \end_inset
10357
10358
10359 \series default
10360  Shows the various actions the compiler is performing.
10361 \end_layout
10362
10363 \begin_layout List
10364 \labelwidthstring 00.00.0000
10365
10366 \series bold
10367 -V
10368 \begin_inset LatexCommand \index{-V}
10369
10370 \end_inset
10371
10372
10373 \series default
10374  Shows the actual commands the compiler is executing.
10375 \end_layout
10376
10377 \begin_layout List
10378 \labelwidthstring 00.00.0000
10379
10380 \series bold
10381 -
10382 \begin_inset ERT
10383 status collapsed
10384
10385 \begin_layout Standard
10386
10387
10388 \backslash
10389 /
10390 \end_layout
10391
10392 \end_inset
10393
10394 -no-c-code-in-asm
10395 \begin_inset LatexCommand \index{-\/-no-c-code-in-asm}
10396
10397 \end_inset
10398
10399
10400 \series default
10401  Hides your ugly and inefficient c-code from the asm file, so you can always
10402  blame the compiler :)
10403 \end_layout
10404
10405 \begin_layout List
10406 \labelwidthstring 00.00.0000
10407
10408 \series bold
10409 -
10410 \begin_inset ERT
10411 status collapsed
10412
10413 \begin_layout Standard
10414
10415
10416 \backslash
10417 /
10418 \end_layout
10419
10420 \end_inset
10421
10422 -fverbose-asm
10423 \begin_inset LatexCommand \index{-\/-no-gen-comments}
10424
10425 \end_inset
10426
10427
10428 \series default
10429  Include code generator and peep-hole comments in the generated asm files.
10430 \end_layout
10431
10432 \begin_layout List
10433 \labelwidthstring 00.00.0000
10434
10435 \series bold
10436 -
10437 \begin_inset ERT
10438 status collapsed
10439
10440 \begin_layout Standard
10441
10442
10443 \backslash
10444 /
10445 \end_layout
10446
10447 \end_inset
10448
10449 -no-peep-comments
10450 \begin_inset LatexCommand \index{-\/-no-peep-comments}
10451
10452 \end_inset
10453
10454
10455 \series default
10456  Don't include peep-hole comments in the generated asm files even if -
10457 \series bold
10458
10459 \begin_inset ERT
10460 status open
10461
10462 \begin_layout Standard
10463
10464
10465 \backslash
10466 /
10467 \end_layout
10468
10469 \end_inset
10470
10471
10472 \series default
10473 -fverbose-asm option is specified.
10474 \end_layout
10475
10476 \begin_layout List
10477 \labelwidthstring 00.00.0000
10478
10479 \series bold
10480 -
10481 \begin_inset ERT
10482 status collapsed
10483
10484 \begin_layout Standard
10485
10486
10487 \backslash
10488 /
10489 \end_layout
10490
10491 \end_inset
10492
10493 -i-code-in-asm
10494 \begin_inset LatexCommand \index{-\/-i-code-in-asm}
10495
10496 \end_inset
10497
10498
10499 \series default
10500  Include i-codes in the asm file.
10501  Sounds like noise but is most helpful for debugging the compiler itself.
10502 \end_layout
10503
10504 \begin_layout List
10505 \labelwidthstring 00.00.0000
10506
10507 \series bold
10508 -
10509 \begin_inset ERT
10510 status collapsed
10511
10512 \begin_layout Standard
10513
10514
10515 \backslash
10516 /
10517 \end_layout
10518
10519 \end_inset
10520
10521 -less-pedantic
10522 \begin_inset LatexCommand \index{pedantic}
10523
10524 \end_inset
10525
10526
10527 \begin_inset LatexCommand \index{-\/-less-pedantic}
10528
10529 \end_inset
10530
10531
10532 \series default
10533
10534 \begin_inset LatexCommand \label{lyx:--less-pedantic}
10535
10536 \end_inset
10537
10538  Disable some of the more pedantic warnings
10539 \begin_inset LatexCommand \index{Warnings}
10540
10541 \end_inset
10542
10543 .
10544  For more details, see the less_pedantic pragma 
10545 \begin_inset LatexCommand \vpageref{ite:less_pedantic}
10546
10547 \end_inset
10548
10549 .
10550 \end_layout
10551
10552 \begin_layout List
10553 \labelwidthstring 00.00.0000
10554
10555 \series bold
10556 -
10557 \begin_inset ERT
10558 status collapsed
10559
10560 \begin_layout Standard
10561
10562
10563 \backslash
10564 /
10565 \end_layout
10566
10567 \end_inset
10568
10569 -disable-warning\InsetSpace ~
10570 <nnnn>
10571 \begin_inset LatexCommand \index{-\/-disable-warning}
10572
10573 \end_inset
10574
10575
10576 \series default
10577  Disable specific warning with number <nnnn>.
10578 \end_layout
10579
10580 \begin_layout List
10581 \labelwidthstring 00.00.0000
10582
10583 \series bold
10584 -
10585 \begin_inset ERT
10586 status collapsed
10587
10588 \begin_layout Standard
10589
10590
10591 \backslash
10592 /
10593 \end_layout
10594
10595 \end_inset
10596
10597 -Werror
10598 \begin_inset LatexCommand \index{-\/-Werror}
10599
10600 \end_inset
10601
10602
10603 \series default
10604  Treat all warnings as errors.
10605 \end_layout
10606
10607 \begin_layout List
10608 \labelwidthstring 00.00.0000
10609
10610 \series bold
10611 -
10612 \begin_inset ERT
10613 status collapsed
10614
10615 \begin_layout Standard
10616
10617
10618 \backslash
10619 /
10620 \end_layout
10621
10622 \end_inset
10623
10624 -print-search-dirs
10625 \begin_inset LatexCommand \index{-\/-print-search-dirs}
10626
10627 \end_inset
10628
10629
10630 \series default
10631  Display the directories in the compiler's search path
10632 \end_layout
10633
10634 \begin_layout List
10635 \labelwidthstring 00.00.0000
10636
10637 \series bold
10638 -
10639 \begin_inset ERT
10640 status collapsed
10641
10642 \begin_layout Standard
10643
10644
10645 \backslash
10646 /
10647 \end_layout
10648
10649 \end_inset
10650
10651 -vc
10652 \begin_inset LatexCommand \index{-\/-vc}
10653
10654 \end_inset
10655
10656
10657 \series default
10658  Display errors and warnings using MSVC style, so you can use SDCC with
10659  the visual studio IDE
10660 \begin_inset LatexCommand \index{IDE}
10661
10662 \end_inset
10663
10664 .
10665  With SDCC both offering a GCC-like (the default) and a MSVC-like
10666 \begin_inset LatexCommand \index{MSVC output style}
10667
10668 \end_inset
10669
10670  output style, integration into most programming editors should be straightforwa
10671 rd.
10672 \end_layout
10673
10674 \begin_layout List
10675 \labelwidthstring 00.00.0000
10676
10677 \series bold
10678 -
10679 \begin_inset ERT
10680 status collapsed
10681
10682 \begin_layout Standard
10683
10684
10685 \backslash
10686 /
10687 \end_layout
10688
10689 \end_inset
10690
10691 -use-stdout
10692 \begin_inset LatexCommand \index{-\/-use-stdout}
10693
10694 \end_inset
10695
10696
10697 \series default
10698  Send errors and warnings to stdout instead of stderr.
10699 \end_layout
10700
10701 \begin_layout List
10702 \labelwidthstring 00.00.0000
10703
10704 \series bold
10705 -Wa\InsetSpace ~
10706 asmOption[,asmOption]
10707 \series default
10708
10709 \begin_inset LatexCommand \index{-Wa asmOption[,asmOption]}
10710
10711 \end_inset
10712
10713 ...
10714  Pass the asmOption to the assembler
10715 \begin_inset LatexCommand \index{Options assembler}
10716
10717 \end_inset
10718
10719
10720 \begin_inset LatexCommand \index{Assembler options}
10721
10722 \end_inset
10723
10724 .
10725  See file sdcc/as/doc/asxhtm.html for assembler options.cd
10726 \end_layout
10727
10728 \begin_layout List
10729 \labelwidthstring 00.00.0000
10730
10731 \series bold
10732 -
10733 \begin_inset ERT
10734 status collapsed
10735
10736 \begin_layout Standard
10737
10738
10739 \backslash
10740 /
10741 \end_layout
10742
10743 \end_inset
10744
10745 -std-sdcc89
10746 \begin_inset LatexCommand \index{-\/-std-sdcc89}
10747
10748 \end_inset
10749
10750
10751 \series default
10752  Generally follow the C89 standard, but allow SDCC features that conflict
10753  with the standard (default).
10754 \end_layout
10755
10756 \begin_layout List
10757 \labelwidthstring 00.00.0000
10758
10759 \series bold
10760 -
10761 \begin_inset ERT
10762 status collapsed
10763
10764 \begin_layout Standard
10765
10766
10767 \backslash
10768 /
10769 \end_layout
10770
10771 \end_inset
10772
10773 -std-c89
10774 \begin_inset LatexCommand \index{-\/-std-c89}
10775
10776 \end_inset
10777
10778
10779 \series default
10780  Follow the C89 standard and disable SDCC features that conflict with the
10781  standard.
10782 \end_layout
10783
10784 \begin_layout List
10785 \labelwidthstring 00.00.0000
10786
10787 \series bold
10788 -
10789 \begin_inset ERT
10790 status collapsed
10791
10792 \begin_layout Standard
10793
10794
10795 \backslash
10796 /
10797 \end_layout
10798
10799 \end_inset
10800
10801 -std-sdcc99
10802 \begin_inset LatexCommand \index{-\/-std-sdcc99}
10803
10804 \end_inset
10805
10806
10807 \series default
10808  Generally follow the C99 standard, but allow SDCC features that conflict
10809  with the standard (incomplete support).
10810 \end_layout
10811
10812 \begin_layout List
10813 \labelwidthstring 00.00.0000
10814
10815 \series bold
10816 -
10817 \begin_inset ERT
10818 status collapsed
10819
10820 \begin_layout Standard
10821
10822
10823 \backslash
10824 /
10825 \end_layout
10826
10827 \end_inset
10828
10829 -std-c99
10830 \begin_inset LatexCommand \index{-\/-std-sdcc99}
10831
10832 \end_inset
10833
10834
10835 \series default
10836  Follow the C99 standard and disable SDCC features that conflict with the
10837  standard (incomplete support).
10838 \end_layout
10839
10840 \begin_layout List
10841 \labelwidthstring 00.00.0000
10842
10843 \series bold
10844 -
10845 \begin_inset ERT
10846 status collapsed
10847
10848 \begin_layout Standard
10849
10850
10851 \backslash
10852 /
10853 \end_layout
10854
10855 \end_inset
10856
10857 -codeseg
10858 \series default
10859
10860 \begin_inset LatexCommand \index{-\/-codeseg <Value>}
10861
10862 \end_inset
10863
10864
10865 \begin_inset LatexCommand \label{lyx:-codeseg}
10866
10867 \end_inset
10868
10869 \InsetSpace ~
10870 <Name> The name to be used for the code
10871 \begin_inset LatexCommand \index{code}
10872
10873 \end_inset
10874
10875  segment, default CSEG.
10876  This is useful if you need to tell the compiler to put the code in a special
10877  segment so you can later on tell the linker to put this segment in a special
10878  place in memory.
10879  Can be used for instance when using bank switching to put the code in a
10880  bank.
10881 \end_layout
10882
10883 \begin_layout List
10884 \labelwidthstring 00.00.0000
10885
10886 \series bold
10887 -
10888 \begin_inset ERT
10889 status collapsed
10890
10891 \begin_layout Standard
10892
10893
10894 \backslash
10895 /
10896 \end_layout
10897
10898 \end_inset
10899
10900 -constseg
10901 \series default
10902
10903 \begin_inset LatexCommand \index{-\/-constseg <Value>}
10904
10905 \end_inset
10906
10907 \InsetSpace ~
10908 <Name> The name to be used for the const
10909 \begin_inset LatexCommand \index{const}
10910
10911 \end_inset
10912
10913  segment, default CONST.
10914  This is useful if you need to tell the compiler to put the const data in
10915  a special segment so you can later on tell the linker to put this segment
10916  in a special place in memory.
10917  Can be used for instance when using bank switching to put the const data
10918  in a bank.
10919 \end_layout
10920
10921 \begin_layout List
10922 \labelwidthstring 00.00.0000
10923
10924 \series bold
10925 -
10926 \begin_inset ERT
10927 status collapsed
10928
10929 \begin_layout Standard
10930
10931
10932 \backslash
10933 /
10934 \end_layout
10935
10936 \end_inset
10937
10938 -fdollars-in-identifiers
10939 \begin_inset LatexCommand \index{-\/-fdollars-in-identifiers}
10940
10941 \end_inset
10942
10943
10944 \series default
10945  Permit '$' as an identifier character.
10946 \end_layout
10947
10948 \begin_layout List
10949 \labelwidthstring 00.00.0000
10950
10951 \series bold
10952 -
10953 \begin_inset ERT
10954 status collapsed
10955
10956 \begin_layout Standard
10957
10958
10959 \backslash
10960 /
10961 \end_layout
10962
10963 \end_inset
10964
10965 -more-pedantic
10966 \series default
10967
10968 \begin_inset LatexCommand \index{-\/-more-pedantic}
10969
10970 \end_inset
10971
10972
10973 \begin_inset LatexCommand \index{pedantic}
10974
10975 \end_inset
10976
10977  Actually this is 
10978 \series bold
10979 \emph on
10980 not
10981 \series default
10982 \emph default
10983  a SDCC compiler option but if you want 
10984 \emph on
10985 more
10986 \emph default
10987  warnings you can use a separate tool dedicated to syntax checking like
10988  splint
10989 \begin_inset LatexCommand \label{lyx:more-pedantic-SPLINT}
10990
10991 \end_inset
10992
10993
10994 \begin_inset LatexCommand \index{lint (syntax checking tool)}
10995
10996 \end_inset
10997
10998  
10999 \begin_inset LatexCommand \url{http://www.splint.org}
11000
11001 \end_inset
11002
11003 .
11004  To make your source files parseable by splint you will have to include
11005  
11006 \family sans
11007 lint.h
11008 \family default
11009
11010 \begin_inset LatexCommand \index{splint (syntax checking tool)}
11011
11012 \end_inset
11013
11014  in your source file and add brackets around extended keywords (like 
11015 \family sans
11016
11017 \begin_inset Quotes sld
11018 \end_inset
11019
11020 __at\InsetSpace ~
11021
11022 \series bold
11023 (
11024 \series default
11025 0xab
11026 \series bold
11027 )
11028 \series default
11029
11030 \begin_inset Quotes srd
11031 \end_inset
11032
11033
11034 \family default
11035  and 
11036 \family sans
11037
11038 \begin_inset Quotes sld
11039 \end_inset
11040
11041 __interrupt\InsetSpace ~
11042 (2)
11043 \begin_inset Quotes srd
11044 \end_inset
11045
11046
11047 \family default
11048 ).
11049  
11050 \newline
11051 Splint has an excellent on line manual at 
11052 \begin_inset LatexCommand \url{http://www.splint.org/manual/}
11053
11054 \end_inset
11055
11056  and it's capabilities go beyond pure syntax checking.
11057  You'll need to tell splint the location of SDCC's include files so a typical
11058  command line could look like this: 
11059 \newline
11060
11061 \family sans
11062 splint\InsetSpace ~
11063 -I\InsetSpace ~
11064 /usr/local/share/sdcc/include/mcs51/\InsetSpace ~
11065 \InsetSpace ~
11066 myprogram.c
11067 \end_layout
11068
11069 \begin_layout List
11070 \labelwidthstring 00.00.0000
11071
11072 \series bold
11073 -
11074 \begin_inset ERT
11075 status collapsed
11076
11077 \begin_layout Standard
11078
11079
11080 \backslash
11081 /
11082 \end_layout
11083
11084 \end_inset
11085
11086 -short-is-8bits
11087 \series default
11088
11089 \begin_inset LatexCommand \index{-\/-short-is-8bits}
11090
11091 \end_inset
11092
11093
11094 \begin_inset LatexCommand \label{lyx:--short-is-8bits}
11095
11096 \end_inset
11097
11098  Treat short as 8-bit (for backward compatibility with older versions of
11099  compiler - see section 
11100 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
11101
11102 \end_inset
11103
11104 )
11105 \end_layout
11106
11107 \begin_layout Standard
11108 \begin_inset VSpace bigskip
11109 \end_inset
11110
11111
11112 \end_layout
11113
11114 \begin_layout Subsection
11115 Intermediate Dump Options
11116 \begin_inset LatexCommand \label{sub:Intermediate-Dump-Options}
11117
11118 \end_inset
11119
11120
11121 \begin_inset LatexCommand \index{Options intermediate dump}
11122
11123 \end_inset
11124
11125
11126 \begin_inset LatexCommand \index{Intermediate dump options}
11127
11128 \end_inset
11129
11130
11131 \end_layout
11132
11133 \begin_layout Standard
11134 The following options are provided for the purpose of retargetting and debugging
11135  the compiler.
11136  They provide a means to dump the intermediate code (iCode
11137 \begin_inset LatexCommand \index{iCode}
11138
11139 \end_inset
11140
11141 ) generated by the compiler in human readable form at various stages of
11142  the compilation process.
11143  More on iCodes see chapter 
11144 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
11145
11146 \end_inset
11147
11148  
11149 \begin_inset Quotes srd
11150 \end_inset
11151
11152 The anatomy of the compiler
11153 \begin_inset Quotes srd
11154 \end_inset
11155
11156 .
11157 \end_layout
11158
11159 \begin_layout List
11160 \labelwidthstring 00.00.0000
11161
11162 \series bold
11163 -
11164 \begin_inset ERT
11165 status collapsed
11166
11167 \begin_layout Standard
11168
11169
11170 \backslash
11171 /
11172 \end_layout
11173
11174 \end_inset
11175
11176 -dumpraw
11177 \begin_inset LatexCommand \index{-\/-dumpraw}
11178
11179 \end_inset
11180
11181
11182 \series default
11183  This option will cause the compiler to dump the intermediate code into
11184  a file of named 
11185 \emph on
11186 <source filename>.dumpraw
11187 \emph default
11188  just after the intermediate code has been generated for a function, i.e.
11189  before any optimizations are done.
11190  The basic blocks
11191 \begin_inset LatexCommand \index{Basic blocks}
11192
11193 \end_inset
11194
11195  at this stage ordered in the depth first number, so they may not be in
11196  sequence of execution.
11197 \end_layout
11198
11199 \begin_layout List
11200 \labelwidthstring 00.00.0000
11201
11202 \series bold
11203 -
11204 \begin_inset ERT
11205 status collapsed
11206
11207 \begin_layout Standard
11208
11209
11210 \backslash
11211 /
11212 \end_layout
11213
11214 \end_inset
11215
11216 -dumpgcse
11217 \begin_inset LatexCommand \index{-\/-dumpgcse}
11218
11219 \end_inset
11220
11221
11222 \series default
11223  Will create a dump of iCodes, after global subexpression elimination
11224 \begin_inset LatexCommand \index{Global subexpression elimination}
11225
11226 \end_inset
11227
11228 , into a file named 
11229 \emph on
11230 <source filename>.dumpgcse.
11231 \end_layout
11232
11233 \begin_layout List
11234 \labelwidthstring 00.00.0000
11235
11236 \series bold
11237 -
11238 \begin_inset ERT
11239 status collapsed
11240
11241 \begin_layout Standard
11242
11243
11244 \backslash
11245 /
11246 \end_layout
11247
11248 \end_inset
11249
11250 -dumpdeadcode
11251 \begin_inset LatexCommand \index{-\/-dumpdeadcode}
11252
11253 \end_inset
11254
11255
11256 \series default
11257  Will create a dump of iCodes, after deadcode elimination
11258 \begin_inset LatexCommand \index{Dead-code elimination}
11259
11260 \end_inset
11261
11262 , into a file named 
11263 \emph on
11264 <source filename>.dumpdeadcode.
11265 \end_layout
11266
11267 \begin_layout List
11268 \labelwidthstring 00.00.0000
11269
11270 \series bold
11271 -
11272 \begin_inset ERT
11273 status collapsed
11274
11275 \begin_layout Standard
11276
11277
11278 \backslash
11279 /
11280 \end_layout
11281
11282 \end_inset
11283
11284 -dumploop
11285 \begin_inset LatexCommand \index{-\/-dumploop}
11286
11287 \end_inset
11288
11289
11290 \series default
11291 \size large
11292  
11293 \size default
11294 Will create a dump of iCodes, after loop optimizations
11295 \begin_inset LatexCommand \index{Loop optimization}
11296
11297 \end_inset
11298
11299 , into a file named 
11300 \emph on
11301 <source filename>.dumploop.
11302 \end_layout
11303
11304 \begin_layout List
11305 \labelwidthstring 00.00.0000
11306
11307 \series bold
11308 -
11309 \begin_inset ERT
11310 status collapsed
11311
11312 \begin_layout Standard
11313
11314
11315 \backslash
11316 /
11317 \end_layout
11318
11319 \end_inset
11320
11321 -dumprange
11322 \begin_inset LatexCommand \index{-\/-dumprange}
11323
11324 \end_inset
11325
11326
11327 \series default
11328 \size large
11329  
11330 \size default
11331 Will create a dump of iCodes, after live range analysis
11332 \begin_inset LatexCommand \index{Live range analysis}
11333
11334 \end_inset
11335
11336 , into a file named 
11337 \emph on
11338 <source filename>.dumprange.
11339 \end_layout
11340
11341 \begin_layout List
11342 \labelwidthstring 00.00.0000
11343
11344 \series bold
11345 -
11346 \begin_inset ERT
11347 status collapsed
11348
11349 \begin_layout Standard
11350
11351
11352 \backslash
11353 /
11354 \end_layout
11355
11356 \end_inset
11357
11358 -dumlrange
11359 \begin_inset LatexCommand \index{-\/-dumlrange}
11360
11361 \end_inset
11362
11363
11364 \series default
11365  Will dump the life ranges
11366 \begin_inset LatexCommand \index{Live range analysis}
11367
11368 \end_inset
11369
11370  for all symbols.
11371 \end_layout
11372
11373 \begin_layout List
11374 \labelwidthstring 00.00.0000
11375
11376 \series bold
11377 -
11378 \begin_inset ERT
11379 status collapsed
11380
11381 \begin_layout Standard
11382
11383
11384 \backslash
11385 /
11386 \end_layout
11387
11388 \end_inset
11389
11390 -dumpregassign
11391 \begin_inset LatexCommand \index{-\/-dumpregassign}
11392
11393 \end_inset
11394
11395
11396 \bar under
11397  
11398 \series default
11399 \bar default
11400 Will create a dump of iCodes, after register assignment
11401 \begin_inset LatexCommand \index{Register assignment}
11402
11403 \end_inset
11404
11405 , into a file named 
11406 \emph on
11407 <source filename>.dumprassgn.
11408 \end_layout
11409
11410 \begin_layout List
11411 \labelwidthstring 00.00.0000
11412
11413 \series bold
11414 -
11415 \begin_inset ERT
11416 status collapsed
11417
11418 \begin_layout Standard
11419
11420
11421 \backslash
11422 /
11423 \end_layout
11424
11425 \end_inset
11426
11427 -dumplrange
11428 \begin_inset LatexCommand \index{-\/-dumplrange}
11429
11430 \end_inset
11431
11432
11433 \series default
11434  Will create a dump of the live ranges of iTemp's
11435 \end_layout
11436
11437 \begin_layout List
11438 \labelwidthstring 00.00.0000
11439
11440 \series bold
11441 -
11442 \begin_inset ERT
11443 status collapsed
11444
11445 \begin_layout Standard
11446
11447
11448 \backslash
11449 /
11450 \end_layout
11451
11452 \end_inset
11453
11454 -dumpall
11455 \begin_inset LatexCommand \index{-\/-dumpall}
11456
11457 \end_inset
11458
11459
11460 \size large
11461 \bar under
11462  
11463 \series default
11464 \size default
11465 \bar default
11466 Will cause all the above mentioned dumps to be created.
11467 \end_layout
11468
11469 \begin_layout Standard
11470 \begin_inset VSpace bigskip
11471 \end_inset
11472
11473
11474 \end_layout
11475
11476 \begin_layout Subsection
11477 Redirecting output on Windows Shells
11478 \end_layout
11479
11480 \begin_layout Standard
11481 By default SDCC writes its error messages to 
11482 \begin_inset Quotes sld
11483 \end_inset
11484
11485 standard error
11486 \begin_inset Quotes srd
11487 \end_inset
11488
11489 .
11490  To force all messages to 
11491 \begin_inset Quotes sld
11492 \end_inset
11493
11494 standard output
11495 \begin_inset Quotes srd
11496 \end_inset
11497
11498  use 
11499 \series bold
11500 -
11501 \series default
11502 \emph on
11503
11504 \begin_inset ERT
11505 status collapsed
11506
11507 \begin_layout Standard
11508
11509
11510 \backslash
11511 /
11512 \end_layout
11513
11514 \end_inset
11515
11516
11517 \series bold
11518 \emph default
11519 -
11520 \series default
11521 use-stdout
11522 \begin_inset LatexCommand \index{-\/-use-stdout}
11523
11524 \end_inset
11525
11526 .
11527  Additionally, if you happen to have visual studio installed in your windows
11528  machine, you can use it to compile your sources using a custom build and
11529  the SDCC -
11530 \emph on
11531
11532 \begin_inset ERT
11533 status collapsed
11534
11535 \begin_layout Standard
11536
11537
11538 \backslash
11539 /
11540 \end_layout
11541
11542 \end_inset
11543
11544
11545 \emph default
11546 -vc
11547 \begin_inset LatexCommand \index{-\/-vc}
11548
11549 \end_inset
11550
11551  option.
11552  Something like this should work:
11553 \newline
11554
11555 \newline
11556
11557 \series bold
11558 c:
11559 \backslash
11560 sdcc
11561 \backslash
11562 bin
11563 \backslash
11564 sdcc.exe -
11565 \series default
11566 \emph on
11567
11568 \begin_inset ERT
11569 status collapsed
11570
11571 \begin_layout Standard
11572
11573
11574 \backslash
11575 /
11576 \end_layout
11577
11578 \end_inset
11579
11580
11581 \series bold
11582 \emph default
11583 -vc -
11584 \series default
11585 \emph on
11586
11587 \begin_inset ERT
11588 status collapsed
11589
11590 \begin_layout Standard
11591
11592
11593 \backslash
11594 /
11595 \end_layout
11596
11597 \end_inset
11598
11599
11600 \series bold
11601 \emph default
11602 -model-large -c $(InputPath)
11603 \series default
11604
11605 \begin_inset VSpace bigskip
11606 \end_inset
11607
11608
11609 \end_layout
11610
11611 \begin_layout Section
11612 Environment variables
11613 \begin_inset LatexCommand \index{Environment variables}
11614
11615 \end_inset
11616
11617
11618 \end_layout
11619
11620 \begin_layout Standard
11621 SDCC recognizes the following environment variables:
11622 \end_layout
11623
11624 \begin_layout List
11625 \labelwidthstring 00.00.0000
11626
11627 \series bold
11628 SDCC_LEAVE_SIGNALS
11629 \begin_inset LatexCommand \index{SDCC\_LEAVE\_SIGNALS}
11630
11631 \end_inset
11632
11633
11634 \series default
11635  SDCC installs a signal handler
11636 \begin_inset LatexCommand \index{signal handler}
11637
11638 \end_inset
11639
11640  to be able to delete temporary files after an user break (^C) or an exception.
11641  If this environment variable is set, SDCC won't install the signal handler
11642  in order to be able to debug SDCC.
11643 \end_layout
11644
11645 \begin_layout List
11646 \labelwidthstring 00.00.0000
11647
11648 \series bold
11649 TMP,\InsetSpace ~
11650 TEMP,\InsetSpace ~
11651 TMPDIR
11652 \begin_inset LatexCommand \index{TMP, TEMP, TMPDIR}
11653
11654 \end_inset
11655
11656
11657 \series default
11658  Path, where temporary files will be created.
11659  The order of the variables is the search order.
11660  In a standard *nix environment these variables are not set, and there's
11661  no need to set them.
11662  On Windows it's recommended to set one of them.
11663 \end_layout
11664
11665 \begin_layout List
11666 \labelwidthstring 00.00.0000
11667
11668 \series bold
11669 SDCC_HOME
11670 \begin_inset LatexCommand \index{SDCC\_HOME}
11671
11672 \end_inset
11673
11674
11675 \series default
11676  Path, see section 
11677 \begin_inset LatexCommand \ref{sub:Install-paths}
11678
11679 \end_inset
11680
11681 \InsetSpace ~
11682
11683 \begin_inset Quotes sld
11684 \end_inset
11685
11686  Install Paths
11687 \begin_inset Quotes srd
11688 \end_inset
11689
11690 .
11691 \end_layout
11692
11693 \begin_layout List
11694 \labelwidthstring 00.00.0000
11695
11696 \series bold
11697 SDCC_INCLUDE
11698 \begin_inset LatexCommand \index{SDCC\_INCLUDE}
11699
11700 \end_inset
11701
11702
11703 \series default
11704  Path, see section 
11705 \begin_inset LatexCommand \ref{sub:Search-Paths}
11706
11707 \end_inset
11708
11709 \InsetSpace ~
11710
11711 \begin_inset Quotes sld
11712 \end_inset
11713
11714 Search Paths
11715 \begin_inset Quotes srd
11716 \end_inset
11717
11718 .
11719 \end_layout
11720
11721 \begin_layout List
11722 \labelwidthstring 00.00.0000
11723
11724 \series bold
11725 SDCC_LIB
11726 \begin_inset LatexCommand \index{SDCC\_LIB}
11727
11728 \end_inset
11729
11730
11731 \series default
11732  Path, see section 
11733 \begin_inset LatexCommand \ref{sub:Search-Paths}
11734
11735 \end_inset
11736
11737 \InsetSpace ~
11738
11739 \begin_inset Quotes sld
11740 \end_inset
11741
11742 Search Paths
11743 \begin_inset Quotes srd
11744 \end_inset
11745
11746 ..
11747 \end_layout
11748
11749 \begin_layout Standard
11750 There are some more environment variables recognized by SDCC, but these
11751  are solely used for debugging purposes.
11752  They can change or disappear very quickly, and will never be documented.
11753 \begin_inset VSpace bigskip
11754 \end_inset
11755
11756
11757 \end_layout
11758
11759 \begin_layout Section
11760 Storage Class Language Extensions
11761 \end_layout
11762
11763 \begin_layout Subsection
11764 MCS51/DS390 Storage Class
11765 \begin_inset LatexCommand \index{Storage class}
11766
11767 \end_inset
11768
11769  Language Extensions
11770 \end_layout
11771
11772 \begin_layout Standard
11773 In addition to the ANSI storage classes SDCC allows the following MCS51
11774  specific storage classes:
11775 \end_layout
11776
11777 \begin_layout Subsubsection
11778 data
11779 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
11780
11781 \end_inset
11782
11783
11784 \begin_inset LatexCommand \index{\_\_data (mcs51, ds390 storage class)}
11785
11786 \end_inset
11787
11788  / near
11789 \begin_inset LatexCommand \index{near (storage class)}
11790
11791 \end_inset
11792
11793
11794 \begin_inset LatexCommand \index{\_\_near (storage class)}
11795
11796 \end_inset
11797
11798
11799 \end_layout
11800
11801 \begin_layout Standard
11802 This is the 
11803 \series bold
11804 default
11805 \series default
11806  storage class for the Small Memory model (
11807 \emph on
11808 data
11809 \emph default
11810  and 
11811 \emph on
11812 near
11813 \emph default
11814  or the more ANSI-C compliant forms 
11815 \emph on
11816 __data
11817 \emph default
11818  and 
11819 \emph on
11820 __near
11821 \emph default
11822  can be used synonymously).
11823  Variables declared with this storage class will be allocated in the directly
11824  addressable portion of the internal RAM of a 8051, e.g.:
11825 \end_layout
11826
11827 \begin_layout Verse
11828
11829 \family typewriter
11830 __data unsigned char test_data;
11831 \end_layout
11832
11833 \begin_layout Standard
11834 Writing 0x01 to this variable generates the assembly code:
11835 \end_layout
11836
11837 \begin_layout Verse
11838
11839 \family typewriter
11840 75*00 01\InsetSpace ~
11841 \InsetSpace ~
11842 \InsetSpace ~
11843 mov\InsetSpace ~
11844 \InsetSpace ~
11845 _test_data,#0x01
11846 \end_layout
11847
11848 \begin_layout Subsubsection
11849 xdata
11850 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
11851
11852 \end_inset
11853
11854
11855 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
11856
11857 \end_inset
11858
11859  / far
11860 \begin_inset LatexCommand \index{far (storage class)}
11861
11862 \end_inset
11863
11864
11865 \begin_inset LatexCommand \index{\_\_far (storage class)}
11866
11867 \end_inset
11868
11869
11870 \end_layout
11871
11872 \begin_layout Standard
11873 Variables declared with this storage class will be placed in the external
11874  RAM.
11875  This is the 
11876 \series bold
11877 default
11878 \series default
11879  storage class for the Large Memory model, e.g.:
11880 \end_layout
11881
11882 \begin_layout Verse
11883
11884 \family typewriter
11885 __xdata unsigned char test_xdata;
11886 \end_layout
11887
11888 \begin_layout Standard
11889 Writing 0x01 to this variable generates the assembly code:
11890 \end_layout
11891
11892 \begin_layout Verse
11893
11894 \family typewriter
11895 90s00r00\InsetSpace ~
11896 \InsetSpace ~
11897 \InsetSpace ~
11898 mov\InsetSpace ~
11899 \InsetSpace ~
11900 dptr,#_test_xdata 
11901 \newline
11902 74\InsetSpace ~
11903 01\InsetSpace ~
11904 \InsetSpace ~
11905 \InsetSpace ~
11906 \InsetSpace ~
11907 \InsetSpace ~
11908 \InsetSpace ~
11909 mov\InsetSpace ~
11910 \InsetSpace ~
11911 a,#0x01 
11912 \newline
11913 F0\InsetSpace ~
11914 \InsetSpace ~
11915 \InsetSpace ~
11916 \InsetSpace ~
11917 \InsetSpace ~
11918 \InsetSpace ~
11919 \InsetSpace ~
11920 \InsetSpace ~
11921 \InsetSpace ~
11922 movx\InsetSpace ~
11923 @dptr,a 
11924 \end_layout
11925
11926 \begin_layout Subsubsection
11927 idata
11928 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
11929
11930 \end_inset
11931
11932
11933 \begin_inset LatexCommand \index{\_\_idata (mcs51, ds390 storage class)}
11934
11935 \end_inset
11936
11937
11938 \end_layout
11939
11940 \begin_layout Standard
11941 Variables declared with this storage class will be allocated into the indirectly
11942  addressable portion of the internal ram of a 8051, e.g.:
11943 \end_layout
11944
11945 \begin_layout Verse
11946
11947 \family typewriter
11948 __idata unsigned char test_idata;
11949 \end_layout
11950
11951 \begin_layout Standard
11952 Writing 0x01 to this variable generates the assembly code:
11953 \end_layout
11954
11955 \begin_layout Verse
11956
11957 \family typewriter
11958 78r00\InsetSpace ~
11959 \InsetSpace ~
11960 \InsetSpace ~
11961 \InsetSpace ~
11962 \InsetSpace ~
11963 \InsetSpace ~
11964 \InsetSpace ~
11965 mov\InsetSpace ~
11966 \InsetSpace ~
11967 r0,#_test_idata
11968 \newline
11969 76\InsetSpace ~
11970 01\InsetSpace ~
11971 \InsetSpace ~
11972 \InsetSpace ~
11973 \InsetSpace ~
11974 \InsetSpace ~
11975 \InsetSpace ~
11976 \InsetSpace ~
11977 mov\InsetSpace ~
11978 \InsetSpace ~
11979 @r0,#0x01
11980 \end_layout
11981
11982 \begin_layout Standard
11983 Please note, the first 128 byte of idata physically access the same RAM
11984  as the data memory.
11985  The original 8051 had 128 byte idata memory, nowadays most devices have
11986  256 byte idata memory.
11987  The stack
11988 \begin_inset LatexCommand \index{stack}
11989
11990 \end_inset
11991
11992  is located in idata memory.
11993 \end_layout
11994
11995 \begin_layout Subsubsection
11996 pdata
11997 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
11998
11999 \end_inset
12000
12001
12002 \begin_inset LatexCommand \index{\_\_pdata (mcs51, ds390 storage class)}
12003
12004 \end_inset
12005
12006
12007 \end_layout
12008
12009 \begin_layout Standard
12010 Paged xdata access is just as straightforward as using the other addressing
12011  modes of a 8051.
12012  It is typically located at the start of xdata and has a maximum size of
12013  256 bytes.
12014  The following example writes 0x01 to the pdata variable.
12015  Please note, pdata access physically accesses xdata memory.
12016  The high byte of the address is determined by port P2 
12017 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
12018
12019 \end_inset
12020
12021 (or in case of some 8051 variants by a separate Special Function Register,
12022  see section 
12023 \begin_inset LatexCommand \ref{sub:MCS51-variants}
12024
12025 \end_inset
12026
12027 ).
12028  This is the 
12029 \series bold
12030 default
12031 \series default
12032  storage class for the Medium Memory model, e.g.:
12033 \end_layout
12034
12035 \begin_layout Verse
12036
12037 \family typewriter
12038 __pdata unsigned char test_pdata;
12039 \end_layout
12040
12041 \begin_layout Standard
12042 Writing 0x01 to this variable generates the assembly code:
12043 \end_layout
12044
12045 \begin_layout Verse
12046
12047 \family typewriter
12048 78r00\InsetSpace ~
12049 \InsetSpace ~
12050 \InsetSpace ~
12051 \InsetSpace ~
12052 \InsetSpace ~
12053 \InsetSpace ~
12054 mov r0,#_test_pdata
12055 \newline
12056 74 01\InsetSpace ~
12057 \InsetSpace ~
12058 \InsetSpace ~
12059 \InsetSpace ~
12060 \InsetSpace ~
12061 \InsetSpace ~
12062 mov a,#0x01 
12063 \newline
12064 F2\InsetSpace ~
12065 \InsetSpace ~
12066 \InsetSpace ~
12067 \InsetSpace ~
12068 \InsetSpace ~
12069 \InsetSpace ~
12070 \InsetSpace ~
12071 \InsetSpace ~
12072 \InsetSpace ~
12073 movx @r0,a
12074 \end_layout
12075
12076 \begin_layout Standard
12077 If the -
12078 \begin_inset ERT
12079 status collapsed
12080
12081 \begin_layout Standard
12082
12083
12084 \backslash
12085 /
12086 \end_layout
12087
12088 \end_inset
12089
12090 -xstack
12091 \begin_inset LatexCommand \index{-\/-xstack}
12092
12093 \end_inset
12094
12095  option is used the pdata memory area is followed by the xstack memory area
12096  and the sum of their sizes is limited to 256 bytes.
12097 \end_layout
12098
12099 \begin_layout Subsubsection
12100 code
12101 \begin_inset LatexCommand \index{code}
12102
12103 \end_inset
12104
12105
12106 \begin_inset LatexCommand \index{\_\_code}
12107
12108 \end_inset
12109
12110
12111 \end_layout
12112
12113 \begin_layout Standard
12114 'Variables' declared with this storage class will be placed in the code
12115  memory:
12116 \end_layout
12117
12118 \begin_layout Verse
12119
12120 \family typewriter
12121 __code unsigned char test_code;
12122 \end_layout
12123
12124 \begin_layout Standard
12125 Read access to this variable generates the assembly code:
12126 \end_layout
12127
12128 \begin_layout Verse
12129
12130 \family typewriter
12131 90s00r6F\InsetSpace ~
12132 \InsetSpace ~
12133 \InsetSpace ~
12134 mov dptr,#_test_code
12135 \newline
12136 E4\InsetSpace ~
12137 \InsetSpace ~
12138 \InsetSpace ~
12139 \InsetSpace ~
12140 \InsetSpace ~
12141 \InsetSpace ~
12142 \InsetSpace ~
12143 \InsetSpace ~
12144 \InsetSpace ~
12145 clr a
12146 \newline
12147 93\InsetSpace ~
12148 \InsetSpace ~
12149 \InsetSpace ~
12150 \InsetSpace ~
12151 \InsetSpace ~
12152 \InsetSpace ~
12153 \InsetSpace ~
12154 \InsetSpace ~
12155 \InsetSpace ~
12156 movc a,@a+dptr 
12157 \end_layout
12158
12159 \begin_layout Standard
12160
12161 \family typewriter
12162 char
12163 \family default
12164  indexed arrays of characters in code memory can be accessed efficiently:
12165 \end_layout
12166
12167 \begin_layout Verse
12168
12169 \family typewriter
12170 __code char test_array[] = {'c','h','e','a','p'}; 
12171 \end_layout
12172
12173 \begin_layout Standard
12174 Read access to this array using an 8-bit unsigned index generates the assembly
12175  code:
12176 \end_layout
12177
12178 \begin_layout Verse
12179
12180 \family typewriter
12181 E5*00\InsetSpace ~
12182 \InsetSpace ~
12183 \InsetSpace ~
12184 \InsetSpace ~
12185 \InsetSpace ~
12186 \InsetSpace ~
12187 mov a,_index 
12188 \end_layout
12189
12190 \begin_layout Verse
12191
12192 \family typewriter
12193 90s00r41\InsetSpace ~
12194 \InsetSpace ~
12195 \InsetSpace ~
12196 mov dptr,#_test_array
12197 \end_layout
12198
12199 \begin_layout Verse
12200
12201 \family typewriter
12202 93\InsetSpace ~
12203 \InsetSpace ~
12204 \InsetSpace ~
12205 \InsetSpace ~
12206 \InsetSpace ~
12207 \InsetSpace ~
12208 \InsetSpace ~
12209 \InsetSpace ~
12210 \InsetSpace ~
12211 movc a,@a+dptr 
12212 \end_layout
12213
12214 \begin_layout Subsubsection
12215 bit
12216 \begin_inset LatexCommand \index{bit}
12217
12218 \end_inset
12219
12220
12221 \begin_inset LatexCommand \index{\_\_bit}
12222
12223 \end_inset
12224
12225
12226 \end_layout
12227
12228 \begin_layout Standard
12229 This is a data-type and a storage class specifier.
12230  When a variable is declared as a bit, it is allocated into the bit addressable
12231  memory of 8051, e.g.:
12232 \end_layout
12233
12234 \begin_layout Verse
12235
12236 \family typewriter
12237 __bit test_bit;
12238 \end_layout
12239
12240 \begin_layout Standard
12241 Writing 1 to this variable generates the assembly code:
12242 \end_layout
12243
12244 \begin_layout Verse
12245
12246 \family typewriter
12247 D2*00\InsetSpace ~
12248 \InsetSpace ~
12249 \InsetSpace ~
12250 \InsetSpace ~
12251 \InsetSpace ~
12252 \InsetSpace ~
12253 \InsetSpace ~
12254 setb\InsetSpace ~
12255 _test_bit
12256 \end_layout
12257
12258 \begin_layout Standard
12259 The bit addressable memory consists of 128 bits which are located from 0x20
12260  to 0x2f in data memory.
12261  
12262 \newline
12263 Apart from this 8051 specific storage class most architectures support
12264  ANSI-C bitfields
12265 \begin_inset LatexCommand \index{bitfields}
12266
12267 \end_inset
12268
12269
12270 \begin_inset Foot
12271 status open
12272
12273 \begin_layout Standard
12274 Not really meant as examples, but nevertheless showing what bitfields are
12275  about: device/include/mc68hc908qy.h and support/regression/tests/bitfields.c
12276 \end_layout
12277
12278 \end_inset
12279
12280 .
12281  In accordance with ISO/IEC 9899 bits and bitfields without an explicit
12282  signed modifier are implemented as unsigned.
12283 \end_layout
12284
12285 \begin_layout Subsubsection
12286 sfr
12287 \begin_inset LatexCommand \index{sfr}
12288
12289 \end_inset
12290
12291
12292 \begin_inset LatexCommand \index{\_\_sfr}
12293
12294 \end_inset
12295
12296  / sfr16
12297 \begin_inset LatexCommand \index{sfr16}
12298
12299 \end_inset
12300
12301
12302 \begin_inset LatexCommand \index{\_\_sfr16}
12303
12304 \end_inset
12305
12306  / sfr32
12307 \begin_inset LatexCommand \index{sfr32}
12308
12309 \end_inset
12310
12311
12312 \begin_inset LatexCommand \index{\_\_sfr32}
12313
12314 \end_inset
12315
12316  / sbit
12317 \begin_inset LatexCommand \index{\_\_sbit}
12318
12319 \end_inset
12320
12321
12322 \begin_inset LatexCommand \index{sbit}
12323
12324 \end_inset
12325
12326
12327 \end_layout
12328
12329 \begin_layout Standard
12330 Like the bit keyword, 
12331 \emph on
12332 sfr / sfr16 / sfr32 / sbit 
12333 \emph default
12334 signify both a data-type and storage class, they are used to describe the
12335  
12336 \emph on
12337 s
12338 \emph default
12339 pecial 
12340 \emph on
12341 f
12342 \emph default
12343 unction 
12344 \emph on
12345 r
12346 \emph default
12347 egisters and 
12348 \emph on
12349 s
12350 \emph default
12351 pecial 
12352 \emph on
12353 bit
12354 \emph default
12355  variables of a 8051, eg:
12356 \end_layout
12357
12358 \begin_layout Verse
12359
12360 \family typewriter
12361 __sfr __at
12362 \begin_inset LatexCommand \index{at}
12363
12364 \end_inset
12365
12366
12367 \begin_inset LatexCommand \index{\_\_at}
12368
12369 \end_inset
12370
12371  (0x80) P0;\InsetSpace ~
12372  /* special function register P0 at location 0x80 */
12373 \newline
12374
12375 \newline
12376 /* 16 bit
12377  special function register combination for timer 0
12378 \newline
12379 \InsetSpace ~
12380 \InsetSpace ~
12381  with the high byte at
12382  location 0x8C and the low byte at location 0x8A */
12383 \newline
12384 __sfr16 __at (0x8C8A)
12385  TMR0;
12386 \newline
12387
12388 \newline
12389 __sbit __at
12390 \begin_inset LatexCommand \index{at}
12391
12392 \end_inset
12393
12394
12395 \begin_inset LatexCommand \index{\_\_at}
12396
12397 \end_inset
12398
12399  (0xd7) CY;\InsetSpace ~
12400  /* CY (Carry Flag
12401 \begin_inset LatexCommand \index{Flags}
12402
12403 \end_inset
12404
12405
12406 \begin_inset LatexCommand \index{Carry flag}
12407
12408 \end_inset
12409
12410 ) */
12411 \end_layout
12412
12413 \begin_layout Standard
12414 Special function registers which are located on an address dividable by
12415  8 are bit-addressable, an
12416 \emph on
12417  sbit
12418 \emph default
12419  addresses a specific bit within these sfr.
12420 \newline
12421 16 Bit and 32 bit special function
12422  register combinations which require a certain access order are better not
12423  declared using 
12424 \emph on
12425 sfr16
12426 \emph default
12427  or 
12428 \emph on
12429 sfr32.
12430
12431 \emph default
12432  Allthough SDCC usually accesses them Least Significant Byte (LSB) first,
12433  this is not guaranteed.
12434 \newline
12435
12436 \end_layout
12437
12438 \begin_layout Standard
12439 Please note, if you use a header file which was written for another compiler
12440  then the sfr / sfr16 / sfr32 / sbit Storage Class extensions will most
12441  likely be 
12442 \emph on
12443 not 
12444 \emph default
12445 compatible.
12446  Specifically the syntax 
12447 \family typewriter
12448 \InsetSpace ~
12449 sfr P0 = 0x80;\InsetSpace ~
12450
12451 \family default
12452  is compiled 
12453 \emph on
12454 without warning
12455 \emph default
12456  by SDCC to an assignment of 0x80 to a variable called P0 
12457 \family typewriter
12458
12459 \begin_inset Marginal
12460 status collapsed
12461
12462 \begin_layout Standard
12463
12464 \series bold
12465 \InsetSpace ~
12466 !
12467 \end_layout
12468
12469 \end_inset
12470
12471 .
12472  
12473 \family default
12474 Nevertheless it is possible to write header files
12475 \begin_inset LatexCommand \index{Header files}
12476
12477 \end_inset
12478
12479
12480 \begin_inset LatexCommand \index{Include files}
12481
12482 \end_inset
12483
12484  which can be shared among different compilers (see section 
12485 \begin_inset LatexCommand \ref{sec:Porting-code-to-other-compilers}
12486
12487 \end_inset
12488
12489 ).
12490  
12491 \end_layout
12492
12493 \begin_layout Subsubsection
12494 Pointers
12495 \begin_inset LatexCommand \index{Pointer}
12496
12497 \end_inset
12498
12499  to MCS51/DS390 specific memory spaces
12500 \end_layout
12501
12502 \begin_layout Standard
12503 SDCC allows (via language extensions) pointers to explicitly point to any
12504  of the memory spaces
12505 \begin_inset LatexCommand \index{Memory model}
12506
12507 \end_inset
12508
12509  of the 8051.
12510  In addition to the explicit pointers, the compiler uses (by default) generic
12511  pointers which can be used to point to any of the memory spaces.
12512 \newline
12513
12514 \newline
12515 Pointer
12516  declaration examples:
12517 \end_layout
12518
12519 \begin_layout Verse
12520
12521 \family typewriter
12522 /* pointer physically in internal ram pointing to object in external ram
12523  */ 
12524 \newline
12525 __xdata unsigned char * __data p;
12526 \newline
12527
12528 \newline
12529 /* pointer physically in external ram
12530  pointing to object in internal ram */ 
12531 \newline
12532 __data unsigned char * __xdata p;
12533 \newline
12534
12535 \newline
12536 /*
12537  pointer physically in code rom pointing to data in xdata space */ 
12538 \newline
12539 __xdata
12540  unsigned char * __code p;
12541 \newline
12542
12543 \newline
12544 /* pointer physically in code space pointing to
12545  data in code space */ 
12546 \newline
12547 __code unsigned char * __code p;
12548 \newline
12549
12550 \newline
12551 /* generic pointer
12552  physically located in xdata space */
12553 \newline
12554 unsigned char * __xdata p;
12555 \newline
12556
12557 \newline
12558 /* generic
12559  pointer physically located in default memory space */
12560 \newline
12561 unsigned char * p;
12562 \newline
12563
12564 \newline
12565 /*
12566  the following is a function pointer
12567 \begin_inset LatexCommand \index{function pointer}
12568
12569 \end_inset
12570
12571  physically located in data space */
12572 \newline
12573 char (* __data fp)(void);
12574 \end_layout
12575
12576 \begin_layout Standard
12577 Well you get the idea.
12578  
12579 \newline
12580
12581 \newline
12582 All unqualified pointers are treated as 3-byte (4-byte for the ds390) 
12583 \emph on
12584 generic
12585 \emph default
12586  pointers.
12587  
12588 \size small
12589
12590 \newline
12591
12592 \newline
12593
12594 \size default
12595 The highest order byte of the 
12596 \emph on
12597 generic
12598 \emph default
12599  pointers contains the data space information.
12600  Assembler support routines are called whenever data is stored or retrieved
12601  using 
12602 \emph on
12603 generic
12604 \emph default
12605  pointers.
12606  These are useful for developing reusable library
12607 \begin_inset LatexCommand \index{Libraries}
12608
12609 \end_inset
12610
12611  routines.
12612  Explicitly specifying the pointer
12613 \begin_inset LatexCommand \index{pointer}
12614
12615 \end_inset
12616
12617  type will generate the most efficient code.
12618 \end_layout
12619
12620 \begin_layout Subsubsection
12621 Notes on MCS51 memory
12622 \begin_inset LatexCommand \index{MCS51 memory}
12623
12624 \end_inset
12625
12626  layout
12627 \end_layout
12628
12629 \begin_layout Standard
12630 The 8051 family of microcontrollers have a minimum of 128 bytes of internal
12631  RAM memory which is structured as follows:
12632 \newline
12633
12634 \newline
12635 - Bytes 00-1F - 32 bytes to hold
12636  up to 4 banks of the registers R0 to R7, 
12637 \newline
12638 - Bytes 20-2F - 16 bytes to hold
12639  128 bit
12640 \begin_inset LatexCommand \index{bit}
12641
12642 \end_inset
12643
12644  variables and, 
12645 \newline
12646 - Bytes 30-7F - 80 bytes for general purpose use.
12647 \newline
12648
12649 \end_layout
12650
12651 \begin_layout Standard
12652 Additionally some members of the MCS51 family may have up to 128 bytes of
12653  additional, indirectly addressable, internal RAM memory (
12654 \emph on
12655 idata
12656 \emph default
12657
12658 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
12659
12660 \end_inset
12661
12662
12663 \begin_inset LatexCommand \index{\_\_idata (mcs51, ds390 storage class)}
12664
12665 \end_inset
12666
12667 ).
12668  Furthermore, some chips may have some built in external memory (
12669 \emph on
12670 xdata
12671 \emph default
12672
12673 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
12674
12675 \end_inset
12676
12677
12678 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
12679
12680 \end_inset
12681
12682 ) which should not be confused with the internal, directly addressable RAM
12683  memory (
12684 \emph on
12685 data
12686 \emph default
12687
12688 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
12689
12690 \end_inset
12691
12692
12693 \begin_inset LatexCommand \index{\_\_data (mcs51, ds390 storage class)}
12694
12695 \end_inset
12696
12697 ).
12698  Sometimes this built in 
12699 \emph on
12700 xdata
12701 \emph default
12702  memory has to be activated before using it (you can probably find this
12703  information on the datasheet of the microcontroller your are using, see
12704  also section 
12705 \begin_inset LatexCommand \ref{sub:Startup-Code}
12706
12707 \end_inset
12708
12709 \InsetSpace ~
12710 Startup-Code).
12711 \end_layout
12712
12713 \begin_layout Standard
12714 Normally SDCC will only use the first bank
12715 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
12716
12717 \end_inset
12718
12719  of registers (register bank 0), but it is possible to specify that other
12720  banks of registers (keyword 
12721 \emph on
12722 using
12723 \emph default
12724  
12725 \emph on
12726
12727 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
12728
12729 \end_inset
12730
12731
12732 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
12733
12734 \end_inset
12735
12736
12737 \emph default
12738 ) should be used for example in interrupt
12739 \begin_inset LatexCommand \index{interrupt}
12740
12741 \end_inset
12742
12743
12744 \begin_inset LatexCommand \index{\_\_interrupt}
12745
12746 \end_inset
12747
12748  routines.
12749  By default, the compiler will place the stack after the last byte of allocated
12750  memory for variables.
12751  For example, if the first 2 banks of registers are used, and only four
12752  bytes are used for 
12753 \emph on
12754 data
12755 \emph default
12756  variables, it will position the base of the internal stack at address 20
12757  (0x14).
12758  This implies that as the stack
12759 \begin_inset LatexCommand \index{stack}
12760
12761 \end_inset
12762
12763  grows, it will use up the remaining register banks, and the 16 bytes used
12764  by the 128 bit variables, and 80 bytes for general purpose use.
12765  If any bit variables are used, the data variables will be placed in unused
12766  register banks and after the byte holding the last bit variable.
12767  For example, if register banks 0 and 1 are used, and there are 9 bit variables
12768  (two bytes used), 
12769 \emph on
12770 data
12771 \emph default
12772  variables will be placed starting from address 0x10 to 0x20 and continue
12773  at address 0x22.
12774  You can also use -
12775 \begin_inset ERT
12776 status collapsed
12777
12778 \begin_layout Standard
12779
12780
12781 \backslash
12782 /
12783 \end_layout
12784
12785 \end_inset
12786
12787 -data-loc
12788 \begin_inset LatexCommand \index{-\/-data-loc <Value>}
12789
12790 \end_inset
12791
12792  to specify the start address of the 
12793 \emph on
12794 data
12795 \emph default
12796  and -
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 -iram-size
12810 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
12811
12812 \end_inset
12813
12814  to specify the size of the total internal RAM (
12815 \emph on
12816 data
12817 \emph default
12818 +
12819 \emph on
12820 idata
12821 \emph default
12822 ).
12823  
12824 \newline
12825
12826 \end_layout
12827
12828 \begin_layout Standard
12829 By default the 8051 linker will place the stack after the last byte of (i)data
12830  variables.
12831  Option -
12832 \begin_inset ERT
12833 status collapsed
12834
12835 \begin_layout Standard
12836
12837
12838 \backslash
12839 /
12840 \end_layout
12841
12842 \end_inset
12843
12844 -stack-loc
12845 \begin_inset LatexCommand \index{-\/-stack-loc <Value>}
12846
12847 \end_inset
12848
12849  allows you to specify the start of the stack, i.e.
12850  you could start it after any data in the general purpose area.
12851  If your microcontroller has additional indirectly addressable internal
12852  RAM (
12853 \emph on
12854 idata
12855 \emph default
12856 ) you can place the stack on it.
12857  You may also need to use -
12858 \begin_inset ERT
12859 status collapsed
12860
12861 \begin_layout Standard
12862
12863
12864 \backslash
12865 /
12866 \end_layout
12867
12868 \end_inset
12869
12870 -xdata-loc
12871 \begin_inset LatexCommand \index{-\/-xdata-loc<Value>}
12872
12873 \end_inset
12874
12875  to set the start address of the external RAM (
12876 \emph on
12877 xdata
12878 \emph default
12879 ) and -
12880 \begin_inset ERT
12881 status collapsed
12882
12883 \begin_layout Standard
12884
12885
12886 \backslash
12887 /
12888 \end_layout
12889
12890 \end_inset
12891
12892 -xram-size
12893 \begin_inset LatexCommand \index{-\/-xram-size <Value>}
12894
12895 \end_inset
12896
12897  to specify its size.
12898  Same goes for the code memory, using -
12899 \begin_inset ERT
12900 status collapsed
12901
12902 \begin_layout Standard
12903
12904
12905 \backslash
12906 /
12907 \end_layout
12908
12909 \end_inset
12910
12911 -code-loc
12912 \begin_inset LatexCommand \index{-\/-code-loc <Value>}
12913
12914 \end_inset
12915
12916  and -
12917 \begin_inset ERT
12918 status collapsed
12919
12920 \begin_layout Standard
12921
12922
12923 \backslash
12924 /
12925 \end_layout
12926
12927 \end_inset
12928
12929 -code-size
12930 \begin_inset LatexCommand \index{-\/-code-size <Value>}
12931
12932 \end_inset
12933
12934 .
12935  If in doubt, don't specify any options and see if the resulting memory
12936  layout is appropriate, then you can adjust it.
12937 \end_layout
12938
12939 \begin_layout Standard
12940 The linker generates two files with memory allocation information.
12941  The first, with extension .map
12942 \begin_inset LatexCommand \index{<file>.map}
12943
12944 \end_inset
12945
12946  shows all the variables and segments.
12947  The second with extension .mem
12948 \begin_inset LatexCommand \index{<file>.mem}
12949
12950 \end_inset
12951
12952  shows the final memory layout.
12953  The linker will complain either if memory segments overlap, there is not
12954  enough memory, or there is not enough space for stack.
12955  If you get any linking warnings and/or errors related to stack or segments
12956  allocation, take a look at either the .map or .mem files to find out what
12957  the problem is.
12958  The .mem file may even suggest a solution to the problem.
12959 \begin_inset VSpace bigskip
12960 \end_inset
12961
12962
12963 \end_layout
12964
12965 \begin_layout Subsection
12966 Z80/Z180 Storage Class
12967 \begin_inset LatexCommand \index{Z80!Storage class}
12968
12969 \end_inset
12970
12971  Language Extensions
12972 \end_layout
12973
12974 \begin_layout Subsubsection
12975 sfr
12976 \begin_inset LatexCommand \index{sfr}
12977
12978 \end_inset
12979
12980
12981 \begin_inset LatexCommand \index{\_\_sfr}
12982
12983 \end_inset
12984
12985  (in/out to 8-bit addresses)
12986 \end_layout
12987
12988 \begin_layout Standard
12989 The Z80
12990 \begin_inset LatexCommand \index{Z80}
12991
12992 \end_inset
12993
12994  family has separate address spaces for memory and 
12995 \emph on
12996 i
12997 \emph default
12998 nput/
12999 \emph on
13000 o
13001 \emph default
13002 utput memory.
13003  I/O memory
13004 \begin_inset LatexCommand \index{I/O memory (Z80, Z180)}
13005
13006 \end_inset
13007
13008
13009 \begin_inset LatexCommand \index{Z80!I/O memory}
13010
13011 \end_inset
13012
13013
13014 \begin_inset LatexCommand \index{Z180!I/O memory}
13015
13016 \end_inset
13017
13018  is accessed with special instructions, e.g.:
13019 \end_layout
13020
13021 \begin_layout Verse
13022
13023 \family typewriter
13024 sfr at 0x78 IoPort;\InsetSpace ~
13025 \InsetSpace ~
13026 /* define a var in I/O space at 78h called IoPort */
13027  
13028 \end_layout
13029
13030 \begin_layout Standard
13031 Writing 0x01 to this variable generates the assembly code:
13032 \end_layout
13033
13034 \begin_layout Verse
13035
13036 \family typewriter
13037 3E 01\InsetSpace ~
13038 \InsetSpace ~
13039 \InsetSpace ~
13040 \InsetSpace ~
13041 \InsetSpace ~
13042 \InsetSpace ~
13043 ld a,#0x01
13044 \newline
13045 D3 78\InsetSpace ~
13046 \InsetSpace ~
13047 \InsetSpace ~
13048 \InsetSpace ~
13049 \InsetSpace ~
13050 \InsetSpace ~
13051 out (_IoPort),a 
13052 \end_layout
13053
13054 \begin_layout Subsubsection
13055 banked sfr
13056 \begin_inset LatexCommand \index{sfr}
13057
13058 \end_inset
13059
13060
13061 \begin_inset LatexCommand \index{\_\_sfr}
13062
13063 \end_inset
13064
13065  (in/out to 16-bit addresses)
13066 \end_layout
13067
13068 \begin_layout Standard
13069 The keyword 
13070 \emph on
13071 banked
13072 \emph default
13073  is used to support 16 bit addresses in I/O memory e.g.:
13074 \end_layout
13075
13076 \begin_layout Verse
13077
13078 \family typewriter
13079 sfr banked at
13080 \begin_inset LatexCommand \index{at}
13081
13082 \end_inset
13083
13084
13085 \begin_inset LatexCommand \index{\_\_at}
13086
13087 \end_inset
13088
13089  0x123 IoPort; 
13090 \end_layout
13091
13092 \begin_layout Standard
13093 Writing 0x01 to this variable generates the assembly code:
13094 \end_layout
13095
13096 \begin_layout Verse
13097
13098 \family typewriter
13099 01 23 01\InsetSpace ~
13100 \InsetSpace ~
13101 \InsetSpace ~
13102 ld bc,#_IoPort
13103 \newline
13104 3E 01\InsetSpace ~
13105 \InsetSpace ~
13106 \InsetSpace ~
13107 \InsetSpace ~
13108 \InsetSpace ~
13109 \InsetSpace ~
13110 ld a,#0x01 
13111 \newline
13112 ED 79\InsetSpace ~
13113 \InsetSpace ~
13114 \InsetSpace ~
13115 \InsetSpace ~
13116 \InsetSpace ~
13117 \InsetSpace ~
13118 out (c),a 
13119 \end_layout
13120
13121 \begin_layout Subsubsection
13122 sfr
13123 \begin_inset LatexCommand \index{sfr}
13124
13125 \end_inset
13126
13127
13128 \begin_inset LatexCommand \index{\_\_sfr}
13129
13130 \end_inset
13131
13132  (in0/out0 to 8 bit addresses on Z180
13133 \begin_inset LatexCommand \index{Z180}
13134
13135 \end_inset
13136
13137 /HD64180
13138 \begin_inset LatexCommand \index{HD64180 (see Z180)}
13139
13140 \end_inset
13141
13142 )
13143 \end_layout
13144
13145 \begin_layout Standard
13146 The compiler option -
13147 \begin_inset ERT
13148 status collapsed
13149
13150 \begin_layout Standard
13151
13152
13153 \backslash
13154 /
13155 \end_layout
13156
13157 \end_inset
13158
13159 -portmode
13160 \begin_inset LatexCommand \index{Z180!Options!-\/-portmode}
13161
13162 \end_inset
13163
13164 =180 (80) and a compiler #pragma\InsetSpace ~
13165 portmode
13166 \begin_inset LatexCommand \index{Z180!Pragmas!\#pragma portmode}
13167
13168 \end_inset
13169
13170  z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructio
13171 ns 
13172 \family typewriter
13173 in0/out0
13174 \family default
13175  instead of 
13176 \family typewriter
13177 in/out
13178 \family default
13179 .
13180  If you include the file z180.h this will be set automatically.
13181 \begin_inset VSpace bigskip
13182 \end_inset
13183
13184
13185 \end_layout
13186
13187 \begin_layout Subsection
13188 HC08 Storage Class
13189 \begin_inset LatexCommand \index{HC08!Storage class}
13190
13191 \end_inset
13192
13193  Language Extensions
13194 \end_layout
13195
13196 \begin_layout Subsubsection
13197 data
13198 \begin_inset LatexCommand \index{data (hc08 storage class)}
13199
13200 \end_inset
13201
13202
13203 \begin_inset LatexCommand \index{\_\_data (hc08 storage class)}
13204
13205 \end_inset
13206
13207  
13208 \end_layout
13209
13210 \begin_layout Standard
13211 The data storage class declares a variable that resides in the first 256
13212  bytes of memory (the direct page).
13213  The HC08
13214 \begin_inset LatexCommand \index{HC08}
13215
13216 \end_inset
13217
13218  is most efficient at accessing variables (especially pointers) stored here.
13219 \end_layout
13220
13221 \begin_layout Subsubsection
13222 xdata
13223 \begin_inset LatexCommand \index{xdata (hc08 storage class)}
13224
13225 \end_inset
13226
13227
13228 \begin_inset LatexCommand \index{\_\_xdata (hc08 storage class)}
13229
13230 \end_inset
13231
13232  
13233 \end_layout
13234
13235 \begin_layout Standard
13236 The xdata storage class declares a variable that can reside anywhere in
13237  memory.
13238  This is the default if no storage class is specified.
13239  
13240 \begin_inset VSpace bigskip
13241 \end_inset
13242
13243
13244 \end_layout
13245
13246 \begin_layout Section
13247 Other SDCC language extensions
13248 \begin_inset LatexCommand \index{Other SDCC language extensions}
13249
13250 \end_inset
13251
13252
13253 \end_layout
13254
13255 \begin_layout Subsection
13256 Binary constants
13257 \end_layout
13258
13259 \begin_layout Standard
13260 SDCC supports the use of binary constants, such as 0b01100010.
13261  This feature is only enabled when the compiler is invoked using --std-sdccxx.
13262 \end_layout
13263
13264 \begin_layout Standard
13265 \begin_inset VSpace bigskip
13266 \end_inset
13267
13268
13269 \end_layout
13270
13271 \begin_layout Section
13272 Absolute Addressing
13273 \begin_inset LatexCommand \index{Absolute addressing}
13274
13275 \end_inset
13276
13277
13278 \end_layout
13279
13280 \begin_layout Standard
13281 Data items can be assigned an absolute address with the 
13282 \emph on
13283 at
13284 \begin_inset LatexCommand \index{at}
13285
13286 \end_inset
13287
13288
13289 \begin_inset LatexCommand \index{\_\_at}
13290
13291 \end_inset
13292
13293  <address>
13294 \emph default
13295  keyword, in addition to a storage class, e.g.:
13296 \end_layout
13297
13298 \begin_layout Verse
13299
13300 \family typewriter
13301 xdata
13302 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
13303
13304 \end_inset
13305
13306
13307 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
13308
13309 \end_inset
13310
13311  at
13312 \begin_inset LatexCommand \index{at}
13313
13314 \end_inset
13315
13316
13317 \begin_inset LatexCommand \index{\_\_at}
13318
13319 \end_inset
13320
13321  0x7ffe unsigned int chksum;
13322 \end_layout
13323
13324 \begin_layout Standard
13325 or, better conforming to ISO/IEC 9899 C:
13326 \end_layout
13327
13328 \begin_layout Verse
13329
13330 \family typewriter
13331 __xdata __at (0x7ffe) unsigned int chksum;
13332 \end_layout
13333
13334 \begin_layout Standard
13335 In the above example the variable chksum will be located at 0x7ffe and 0x7fff
13336  of the external ram.
13337  The compiler does 
13338 \emph on
13339 not
13340 \emph default
13341  reserve any space for variables declared in this way
13342 \begin_inset Marginal
13343 status collapsed
13344
13345 \begin_layout Standard
13346
13347 \series bold
13348 \InsetSpace ~
13349 !
13350 \end_layout
13351
13352 \end_inset
13353
13354  (they are implemented with an equate in the assembler).
13355  Thus it is left to the programmer to make sure there are no overlaps with
13356  other variables that are declared without the absolute address.
13357  The assembler listing file (.lst
13358 \begin_inset LatexCommand \index{<file>.lst}
13359
13360 \end_inset
13361
13362 ) and the linker output files (.rst
13363 \begin_inset LatexCommand \index{<file>.rst}
13364
13365 \end_inset
13366
13367 ) and (.map
13368 \begin_inset LatexCommand \index{<file>.map}
13369
13370 \end_inset
13371
13372 ) are good places to look for such overlaps.
13373 \end_layout
13374
13375 \begin_layout Standard
13376 If however you provide an initializer
13377 \begin_inset LatexCommand \index{Variable initialization}
13378
13379 \end_inset
13380
13381  actual memory allocation will take place and overlaps will be detected
13382  by the linker.
13383  E.g.:
13384 \end_layout
13385
13386 \begin_layout Verse
13387
13388 \family typewriter
13389 __code __at (0x7ff0) char Id[5] = 
13390 \begin_inset Quotes sld
13391 \end_inset
13392
13393 SDCC
13394 \begin_inset Quotes srd
13395 \end_inset
13396
13397 ;
13398 \end_layout
13399
13400 \begin_layout Standard
13401 In the above example the variable Id will be located from 0x7ff0 to 0x7ff4
13402  in code memory.
13403 \end_layout
13404
13405 \begin_layout Standard
13406 In case of memory mapped I/O devices the keyword 
13407 \emph on
13408 volatile
13409 \emph default
13410  has to be used to tell the compiler that accesses might not be removed:
13411 \end_layout
13412
13413 \begin_layout Verse
13414
13415 \family typewriter
13416 volatile
13417 \begin_inset LatexCommand \index{volatile}
13418
13419 \end_inset
13420
13421  __xdata
13422 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
13423
13424 \end_inset
13425
13426  __at
13427 \begin_inset LatexCommand \index{at}
13428
13429 \end_inset
13430
13431  (0x8000) unsigned char PORTA_8255;
13432 \end_layout
13433
13434 \begin_layout Standard
13435 For some architectures (mcs51) array accesses are more efficient if an (xdata/fa
13436 r) array
13437 \family typewriter
13438 \size footnotesize
13439
13440 \begin_inset LatexCommand \index{Aligned array}
13441
13442 \end_inset
13443
13444
13445 \family default
13446 \size default
13447  starts at a block (256 byte) boundary
13448 \begin_inset LatexCommand \index{block boundary}
13449
13450 \end_inset
13451
13452  (section 
13453 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
13454
13455 \end_inset
13456
13457  has an example).
13458 \newline
13459 Absolute addresses can be specified for variables in all
13460  storage classes, e.g.:
13461 \end_layout
13462
13463 \begin_layout Verse
13464
13465 \family typewriter
13466 __bit
13467 \begin_inset LatexCommand \index{bit}
13468
13469 \end_inset
13470
13471  __at
13472 \begin_inset LatexCommand \index{at}
13473
13474 \end_inset
13475
13476  (0x02) bvar;
13477 \end_layout
13478
13479 \begin_layout Standard
13480 The above example will allocate the variable at offset 0x02 in the bit-addressab
13481 le space.
13482  There is no real advantage to assigning absolute addresses to variables
13483  in this manner, unless you want strict control over all the variables allocated.
13484  One possible use would be to write hardware portable code.
13485  For example, if you have a routine that uses one or more of the microcontroller
13486  I/O pins, and such pins are different for two different hardwares, you
13487  can declare the I/O pins in your routine using:
13488 \end_layout
13489
13490 \begin_layout Verse
13491
13492 \family typewriter
13493 extern volatile
13494 \begin_inset LatexCommand \index{volatile}
13495
13496 \end_inset
13497
13498  __bit MOSI;\InsetSpace ~
13499 \InsetSpace ~
13500 \InsetSpace ~
13501 \InsetSpace ~
13502 /* master out, slave in */
13503 \newline
13504 extern volatile __bit MISO;\InsetSpace ~
13505 \InsetSpace ~
13506 \InsetSpace ~
13507 \InsetSpace ~
13508 /* master
13509  in, slave out */
13510 \newline
13511 extern volatile __bit MCLK;\InsetSpace ~
13512 \InsetSpace ~
13513 \InsetSpace ~
13514 \InsetSpace ~
13515 /* master clock */
13516 \newline
13517
13518 \newline
13519 /* Input and
13520  Output of a byte on a 3-wire serial bus.
13521 \newline
13522 \InsetSpace ~
13523 \InsetSpace ~
13524 \InsetSpace ~
13525 If needed adapt polarity of clock,
13526  polarity of data and bit order
13527 \newline
13528 \InsetSpace ~
13529 */
13530 \newline
13531 unsigned char spi_io(unsigned char out_byte)
13532  
13533 \newline
13534
13535 \newline
13536 \InsetSpace ~
13537 \InsetSpace ~
13538 \InsetSpace ~
13539 \InsetSpace ~
13540 unsigned char i=8;
13541 \newline
13542 \InsetSpace ~
13543 \InsetSpace ~
13544 \InsetSpace ~
13545 \InsetSpace ~
13546 do { 
13547 \newline
13548 \InsetSpace ~
13549 \InsetSpace ~
13550 \InsetSpace ~
13551 \InsetSpace ~
13552 \InsetSpace ~
13553 \InsetSpace ~
13554 \InsetSpace ~
13555 \InsetSpace ~
13556 MOSI = out_byte & 0x80; 
13557 \newline
13558 \InsetSpace ~
13559 \InsetSpace ~
13560 \InsetSpace ~
13561 \InsetSpace ~
13562 \InsetSpace ~
13563 \InsetSpace ~
13564 \InsetSpace ~
13565 \InsetSpace ~
13566 out_byte <<= 1;
13567 \newline
13568 \InsetSpace ~
13569 \InsetSpace ~
13570 \InsetSpace ~
13571 \InsetSpace ~
13572 \InsetSpace ~
13573 \InsetSpace ~
13574 \InsetSpace ~
13575 \InsetSpace ~
13576 MCLK =
13577  1; 
13578 \newline
13579 \InsetSpace ~
13580 \InsetSpace ~
13581 \InsetSpace ~
13582 \InsetSpace ~
13583 \InsetSpace ~
13584 \InsetSpace ~
13585 \InsetSpace ~
13586 \InsetSpace ~
13587 /* _asm nop _endasm; */\InsetSpace ~
13588 \InsetSpace ~
13589 \InsetSpace ~
13590 \InsetSpace ~
13591 \InsetSpace ~
13592 \InsetSpace ~
13593 \InsetSpace ~
13594 \InsetSpace ~
13595 /* for slow peripherals */
13596 \newline
13597 \InsetSpace ~
13598 \InsetSpace ~
13599 \InsetSpace ~
13600 \InsetSpace ~
13601 \InsetSpace ~
13602 \InsetSpace ~
13603 \InsetSpace ~
13604 \InsetSpace ~
13605 if(MISO) 
13606 \newline
13607 \InsetSpace ~
13608 \InsetSpace ~
13609 \InsetSpace ~
13610 \InsetSpace ~
13611 \InsetSpace ~
13612 \InsetSpace ~
13613 \InsetSpace ~
13614 \InsetSpace ~
13615 \InsetSpace ~
13616 \InsetSpace ~
13617 \InsetSpace ~
13618 \InsetSpace ~
13619 out_byte +=
13620  1; 
13621 \newline
13622 \InsetSpace ~
13623 \InsetSpace ~
13624 \InsetSpace ~
13625 \InsetSpace ~
13626 \InsetSpace ~
13627 \InsetSpace ~
13628 \InsetSpace ~
13629 \InsetSpace ~
13630 MCLK = 0; 
13631 \newline
13632 \InsetSpace ~
13633 \InsetSpace ~
13634 \InsetSpace ~
13635 \InsetSpace ~
13636 } while(--i);
13637 \newline
13638 \InsetSpace ~
13639 \InsetSpace ~
13640 \InsetSpace ~
13641 \InsetSpace ~
13642 return out_byte; 
13643 \newline
13644 }
13645 \end_layout
13646
13647 \begin_layout Standard
13648 Then, someplace in the code for the first hardware you would use
13649 \end_layout
13650
13651 \begin_layout Verse
13652
13653 \family typewriter
13654 __bit __at
13655 \begin_inset LatexCommand \index{at}
13656
13657 \end_inset
13658
13659
13660 \begin_inset LatexCommand \index{\_\_at}
13661
13662 \end_inset
13663
13664  (0x80) MOSI;\InsetSpace ~
13665 \InsetSpace ~
13666 \InsetSpace ~
13667 \InsetSpace ~
13668 /* I/O port 0, bit 0 */
13669 \newline
13670 __bit __at (0x81) MISO;\InsetSpace ~
13671 \InsetSpace ~
13672 \InsetSpace ~
13673 \InsetSpace ~
13674 /* I/O port 0,
13675  bit 1 */
13676 \newline
13677 __bit __at (0x82) MCLK;\InsetSpace ~
13678 \InsetSpace ~
13679 \InsetSpace ~
13680 \InsetSpace ~
13681 /* I/O port 0, bit 2 */
13682 \end_layout
13683
13684 \begin_layout Standard
13685 Similarly, for the second hardware you would use
13686 \end_layout
13687
13688 \begin_layout Verse
13689
13690 \family typewriter
13691 __bit __at (0x83) MOSI;\InsetSpace ~
13692 \InsetSpace ~
13693 \InsetSpace ~
13694 \InsetSpace ~
13695 /* I/O port 0, bit 3 */
13696 \newline
13697 __bit __at (0x91) MISO;\InsetSpace ~
13698 \InsetSpace ~
13699 \InsetSpace ~
13700 \InsetSpace ~
13701 /*
13702  I/O port 1, bit 1 */
13703 \newline
13704 __bit
13705 \begin_inset LatexCommand \index{bit}
13706
13707 \end_inset
13708
13709  __at (0x92) MCLK;\InsetSpace ~
13710 \InsetSpace ~
13711 \InsetSpace ~
13712 \InsetSpace ~
13713 /* I/O port 1, bit 2 */
13714 \end_layout
13715
13716 \begin_layout Standard
13717 and you can use the same hardware dependent routine without changes, as
13718  for example in a library.
13719  This is somehow similar to sbit, but only one absolute address has to be
13720  specified in the whole project.
13721 \begin_inset VSpace bigskip
13722 \end_inset
13723
13724
13725 \end_layout
13726
13727 \begin_layout Section
13728 Parameters
13729 \begin_inset LatexCommand \index{Parameters}
13730
13731 \end_inset
13732
13733
13734 \begin_inset LatexCommand \index{function parameter}
13735
13736 \end_inset
13737
13738  & Local Variables
13739 \begin_inset LatexCommand \index{local variables}
13740
13741 \end_inset
13742
13743
13744 \begin_inset LatexCommand \label{sec:Parameters-and-Local-Variables}
13745
13746 \end_inset
13747
13748
13749 \end_layout
13750
13751 \begin_layout Standard
13752 Automatic (local) variables and parameters to functions can either be placed
13753  on the stack or in data-space.
13754  The default action of the compiler is to place these variables in the internal
13755  RAM (for small model) or external RAM (for medium or large model).
13756  This in fact makes them similar to 
13757 \emph on
13758 static
13759 \begin_inset LatexCommand \index{static}
13760
13761 \end_inset
13762
13763
13764 \emph default
13765  so by default functions are non-reentrant
13766 \begin_inset LatexCommand \index{reentrant}
13767
13768 \end_inset
13769
13770 .
13771  
13772 \newline
13773
13774 \newline
13775 They can be placed on the stack
13776 \begin_inset LatexCommand \index{stack}
13777
13778 \end_inset
13779
13780  by using the
13781 \emph on
13782  -
13783 \begin_inset ERT
13784 status collapsed
13785
13786 \begin_layout Standard
13787
13788
13789 \backslash
13790 /
13791 \end_layout
13792
13793 \end_inset
13794
13795 -stack-auto
13796 \begin_inset LatexCommand \index{-\/-stack-auto}
13797
13798 \end_inset
13799
13800
13801 \emph default
13802  option, by using 
13803 \emph on
13804 #pragma\InsetSpace ~
13805 stackauto
13806 \emph default
13807
13808 \begin_inset LatexCommand \index{\#pragma stackauto}
13809
13810 \end_inset
13811
13812  or by using the 
13813 \emph on
13814 reentrant
13815 \begin_inset LatexCommand \index{reentrant}
13816
13817 \end_inset
13818
13819
13820 \emph default
13821  keyword in the function declaration, e.g.:
13822 \end_layout
13823
13824 \begin_layout Verse
13825
13826 \family typewriter
13827 unsigned char foo(char i) __reentrant 
13828 \newline
13829
13830 \newline
13831 \InsetSpace ~
13832 \InsetSpace ~
13833 \InsetSpace ~
13834 \InsetSpace ~
13835 ...
13836  
13837 \newline
13838 }
13839 \end_layout
13840
13841 \begin_layout Standard
13842 Since stack space on 8051 is limited, the 
13843 \emph on
13844 reentrant 
13845 \emph default
13846 keyword or the
13847 \emph on
13848  -
13849 \begin_inset ERT
13850 status collapsed
13851
13852 \begin_layout Standard
13853
13854
13855 \backslash
13856 /
13857 \end_layout
13858
13859 \end_inset
13860
13861 -stack-auto
13862 \emph default
13863  option should be used sparingly.
13864  Note that the reentrant keyword just means that the parameters & local
13865  variables will be allocated to the stack, it 
13866 \emph on
13867 does not
13868 \emph default
13869  mean that the function is register bank
13870 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
13871
13872 \end_inset
13873
13874  independent.
13875 \newline
13876
13877 \newline
13878 Local variables
13879 \begin_inset LatexCommand \index{local variables}
13880
13881 \end_inset
13882
13883  can be assigned storage classes and absolute
13884 \begin_inset LatexCommand \index{Absolute addressing}
13885
13886 \end_inset
13887
13888  addresses, e.g.: 
13889 \end_layout
13890
13891 \begin_layout Verse
13892
13893 \family typewriter
13894 unsigned char foo() 
13895 \newline
13896 {
13897 \newline
13898 \InsetSpace ~
13899 \InsetSpace ~
13900 \InsetSpace ~
13901 \InsetSpace ~
13902 __xdata unsigned char i;
13903 \newline
13904 \InsetSpace ~
13905 \InsetSpace ~
13906 \InsetSpace ~
13907 \InsetSpace ~
13908 __bit bvar;
13909 \newline
13910 \InsetSpace ~
13911 \InsetSpace ~
13912 \InsetSpace ~
13913 \InsetSpace ~
13914 __data __at
13915 \begin_inset LatexCommand \index{at}
13916
13917 \end_inset
13918
13919  (0x31) unsigned char j;
13920 \newline
13921 \InsetSpace ~
13922 \InsetSpace ~
13923 \InsetSpace ~
13924 \InsetSpace ~
13925 ...
13926  
13927 \newline
13928 }
13929 \end_layout
13930
13931 \begin_layout Standard
13932 In the above example the variable 
13933 \emph on
13934 i
13935 \emph default
13936  will be allocated in the external ram, 
13937 \emph on
13938 bvar
13939 \emph default
13940  in bit addressable space and
13941 \emph on
13942  j
13943 \emph default
13944  in internal ram.
13945  When compiled with 
13946 \emph on
13947 -
13948 \begin_inset ERT
13949 status collapsed
13950
13951 \begin_layout Standard
13952
13953
13954 \backslash
13955 /
13956 \end_layout
13957
13958 \end_inset
13959
13960 -stack-auto
13961 \emph default
13962  or when a function is declared as 
13963 \emph on
13964 reentrant
13965 \emph default
13966  this should only be done for static variables.
13967 \end_layout
13968
13969 \begin_layout Standard
13970 Parameters
13971 \begin_inset LatexCommand \index{function parameter}
13972
13973 \end_inset
13974
13975  however are not allowed any storage class
13976 \begin_inset LatexCommand \index{Storage class}
13977
13978 \end_inset
13979
13980 , (storage classes for parameters will be ignored), their allocation is
13981  governed by the memory model in use, and the reentrancy options.
13982 \end_layout
13983
13984 \begin_layout Standard
13985 It is however allowed to use bit parameters in reentrant functions and also
13986  non-static local bit variables are supported.
13987  Efficient use is limited to 8 semi-bitregisters in bit space.
13988  They are pushed and popped to stack
13989 \begin_inset LatexCommand \index{stack}
13990
13991 \end_inset
13992
13993  as a single byte just like the normal registers.
13994 \end_layout
13995
13996 \begin_layout Section
13997 Overlaying
13998 \begin_inset LatexCommand \label{sub:Overlaying}
13999
14000 \end_inset
14001
14002
14003 \begin_inset LatexCommand \index{Overlaying}
14004
14005 \end_inset
14006
14007
14008 \end_layout
14009
14010 \begin_layout Standard
14011 For non-reentrant
14012 \begin_inset LatexCommand \index{reentrant}
14013
14014 \end_inset
14015
14016  functions SDCC will try to reduce internal ram space usage by overlaying
14017  parameters and local variables of a function (if possible).
14018  Parameters and local variables
14019 \begin_inset LatexCommand \index{local variables}
14020
14021 \end_inset
14022
14023  of a function will be allocated to an overlayable segment if the function
14024  has 
14025 \emph on
14026 no other function calls and the function is non-reentrant and the memory
14027  model
14028 \begin_inset LatexCommand \index{Memory model}
14029
14030 \end_inset
14031
14032  is small.
14033
14034 \emph default
14035  If an explicit storage class
14036 \begin_inset LatexCommand \index{Storage class}
14037
14038 \end_inset
14039
14040  is specified for a local variable, it will NOT be overlayed.
14041 \end_layout
14042
14043 \begin_layout Standard
14044 Note that the compiler (not the linkage editor) makes the decision for overlayin
14045 g the data items.
14046  Functions that are called from an interrupt service routine
14047 \begin_inset Marginal
14048 status collapsed
14049
14050 \begin_layout Standard
14051
14052 \series bold
14053 !
14054 \end_layout
14055
14056 \end_inset
14057
14058  should be preceded by a #pragma\InsetSpace ~
14059 nooverlay
14060 \begin_inset LatexCommand \index{\#pragma nooverlay}
14061
14062 \end_inset
14063
14064  if they are not reentrant.
14065 \end_layout
14066
14067 \begin_layout Standard
14068 Also note that the compiler does not do any processing of inline assembler
14069  code, so the compiler might incorrectly assign local variables and parameters
14070  of a function into the overlay segment if the inline assembler code calls
14071  other c-functions that might use the overlay.
14072  In that case the #pragma\InsetSpace ~
14073 nooverlay should be used.
14074 \end_layout
14075
14076 \begin_layout Standard
14077 Parameters and local variables of functions that contain 16 or 32 bit multiplica
14078 tion
14079 \begin_inset LatexCommand \index{Multiplication}
14080
14081 \end_inset
14082
14083  or division
14084 \begin_inset LatexCommand \index{Division}
14085
14086 \end_inset
14087
14088  will NOT be overlayed since these are implemented using external functions,
14089  e.g.:
14090 \end_layout
14091
14092 \begin_layout Verse
14093
14094 \family typewriter
14095 #pragma save 
14096 \newline
14097 #pragma nooverlay
14098 \begin_inset LatexCommand \index{\#pragma nooverlay}
14099
14100 \end_inset
14101
14102  
14103 \newline
14104 void set_error(unsigned char errcd) 
14105 \newline
14106 {
14107 \newline
14108 \InsetSpace ~
14109 \InsetSpace ~
14110 \InsetSpace ~
14111 \InsetSpace ~
14112 P3 = errcd;
14113 \newline
14114
14115 \newline
14116 #pragma restore 
14117 \newline
14118
14119 \newline
14120 void
14121  some_isr () __interrupt
14122 \begin_inset LatexCommand \index{interrupt}
14123
14124 \end_inset
14125
14126  (2)
14127 \newline
14128 {
14129 \newline
14130 \InsetSpace ~
14131 \InsetSpace ~
14132 \InsetSpace ~
14133 \InsetSpace ~
14134 ...
14135 \newline
14136 \InsetSpace ~
14137 \InsetSpace ~
14138 \InsetSpace ~
14139 \InsetSpace ~
14140 set_error(10);
14141 \newline
14142 \InsetSpace ~
14143 \InsetSpace ~
14144 \InsetSpace ~
14145 \InsetSpace ~
14146 ...
14147  
14148 \newline
14149 }
14150 \end_layout
14151
14152 \begin_layout Standard
14153 In the above example the parameter 
14154 \emph on
14155 errcd
14156 \emph default
14157  for the function 
14158 \emph on
14159 set_error
14160 \emph default
14161  would be assigned to the overlayable segment if the #pragma\InsetSpace ~
14162 nooverlay was
14163  not present, this could cause unpredictable runtime behavior when called
14164  from an interrupt service routine.
14165  The #pragma\InsetSpace ~
14166 nooverlay ensures that the parameters and local variables for
14167  the function are NOT overlayed.
14168 \begin_inset VSpace bigskip
14169 \end_inset
14170
14171
14172 \end_layout
14173
14174 \begin_layout Section
14175 Interrupt Service Routines
14176 \begin_inset LatexCommand \label{sub:Interrupt-Service-Routines}
14177
14178 \end_inset
14179
14180
14181 \end_layout
14182
14183 \begin_layout Subsection
14184 General Information
14185 \end_layout
14186
14187 \begin_layout Standard
14188 SDCC allows 
14189 \emph on
14190 i
14191 \emph default
14192 nterrupt 
14193 \emph on
14194 s
14195 \emph default
14196 ervice 
14197 \emph on
14198 r
14199 \emph default
14200 outines to be coded in C, with some extended keywords.
14201 \end_layout
14202
14203 \begin_layout Verse
14204
14205 \family typewriter
14206 void timer_isr (void) __interrupt (1) __using (1) 
14207 \newline
14208
14209 \newline
14210 \InsetSpace ~
14211 \InsetSpace ~
14212 \InsetSpace ~
14213 \InsetSpace ~
14214 ...
14215  
14216 \newline
14217 }
14218 \end_layout
14219
14220 \begin_layout Standard
14221 The optional number following the 
14222 \emph on
14223 interrupt
14224 \begin_inset LatexCommand \index{interrupt}
14225
14226 \end_inset
14227
14228
14229 \begin_inset LatexCommand \index{\_\_interrupt}
14230
14231 \end_inset
14232
14233
14234 \emph default
14235  keyword is the interrupt number this routine will service.
14236  When present, the compiler will insert a call to this routine in the interrupt
14237  vector table
14238 \begin_inset LatexCommand \index{interrupt vector table}
14239
14240 \end_inset
14241
14242  for the interrupt number specified.
14243  If you have multiple source files in your project, interrupt service routines
14244  can be present in any of them, but a prototype of the isr MUST be present
14245  or included in the file that contains the function 
14246 \emph on
14247 main
14248 \emph default
14249 .
14250  The optional (8051 specific) keyword 
14251 \emph on
14252 using
14253 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
14254
14255 \end_inset
14256
14257
14258 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
14259
14260 \end_inset
14261
14262
14263 \emph default
14264  can be used to tell the compiler to use the specified register bank when
14265  generating code for this function.
14266  
14267 \newline
14268 Interrupt service routines open the door for some very interesting bugs:
14269 \end_layout
14270
14271 \begin_layout Subsubsection
14272 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-volatile}
14273
14274 \end_inset
14275
14276 Common interrupt pitfall: variable not declared 
14277 \emph on
14278 volatile
14279 \end_layout
14280
14281 \begin_layout Standard
14282 If an interrupt service routine changes variables which are accessed by
14283  other functions these variables have to be declared 
14284 \emph on
14285 volatile
14286 \emph default
14287
14288 \begin_inset LatexCommand \index{volatile}
14289
14290 \end_inset
14291
14292 .
14293  See 
14294 \begin_inset LatexCommand \url{http://en.wikipedia.org/wiki/Volatile_variable}
14295
14296 \end_inset
14297
14298  .
14299 \end_layout
14300
14301 \begin_layout Subsubsection
14302 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-atomic}
14303
14304 \end_inset
14305
14306 Common interrupt pitfall: 
14307 \emph on
14308 non-atomic access
14309 \end_layout
14310
14311 \begin_layout Standard
14312 If the access to these variables is not 
14313 \emph on
14314 atomic
14315 \begin_inset LatexCommand \index{atomic}
14316
14317 \end_inset
14318
14319
14320 \emph default
14321  (i.e.
14322  the processor needs more than one instruction for the access and could
14323  be interrupted while accessing the variable) the interrupt must be disabled
14324  during the access to avoid inconsistent data.
14325  
14326 \newline
14327 Access to 16 or 32 bit variables is obviously not atomic on 8 bit CPUs
14328  and should be protected by disabling interrupts.
14329  You're not automatically on the safe side if you use 8 bit variables though.
14330  We need an example here: f.e.
14331  on the 8051 the harmless looking 
14332 \begin_inset Quotes srd
14333 \end_inset
14334
14335
14336 \family typewriter
14337 flags\InsetSpace ~
14338 |=\InsetSpace ~
14339 0x80;
14340 \family default
14341
14342 \begin_inset Quotes sld
14343 \end_inset
14344
14345  is not atomic if 
14346 \family typewriter
14347 flags
14348 \family default
14349  resides in xdata.
14350  Setting 
14351 \begin_inset Quotes srd
14352 \end_inset
14353
14354
14355 \family typewriter
14356 flags\InsetSpace ~
14357 |=\InsetSpace ~
14358 0x40;
14359 \family default
14360
14361 \begin_inset Quotes sld
14362 \end_inset
14363
14364  from within an interrupt routine might get lost if the interrupt occurs
14365  at the wrong time.
14366  
14367 \begin_inset Quotes sld
14368 \end_inset
14369
14370
14371 \family typewriter
14372 counter\InsetSpace ~
14373 +=\InsetSpace ~
14374 8;
14375 \family default
14376
14377 \begin_inset Quotes srd
14378 \end_inset
14379
14380  is not atomic on the 8051 even if 
14381 \family typewriter
14382 counter
14383 \family default
14384  is located in data memory.
14385 \newline
14386 Bugs like these are hard to reproduce and can
14387  cause a lot of trouble.
14388  
14389 \end_layout
14390
14391 \begin_layout Subsubsection
14392 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-stack-overflow}
14393
14394 \end_inset
14395
14396 Common interrupt pitfall: 
14397 \emph on
14398 stack overflow
14399 \end_layout
14400
14401 \begin_layout Standard
14402 The return address and the registers used in the interrupt service routine
14403  are saved on the stack
14404 \begin_inset LatexCommand \index{stack}
14405
14406 \end_inset
14407
14408  so there must be sufficient stack space.
14409  If there isn't variables or registers (or even the return address itself)
14410  will be corrupted.
14411  This 
14412 \emph on
14413 stack overflow
14414 \emph default
14415
14416 \begin_inset LatexCommand \index{stack overflow}
14417
14418 \end_inset
14419
14420  is most likely to happen if the interrupt occurs during the 
14421 \begin_inset Quotes sld
14422 \end_inset
14423
14424 deepest
14425 \begin_inset Quotes srd
14426 \end_inset
14427
14428  subroutine when the stack is already in use for f.e.
14429  many return addresses.
14430 \end_layout
14431
14432 \begin_layout Subsubsection
14433 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-reentrant}
14434
14435 \end_inset
14436
14437 Common interrupt pitfall: 
14438 \emph on
14439 use of non-reentrant functions
14440 \end_layout
14441
14442 \begin_layout Standard
14443 A special note here, int (16 bit) and long (32 bit) integer division
14444 \begin_inset LatexCommand \index{Division}
14445
14446 \end_inset
14447
14448 , multiplication
14449 \begin_inset LatexCommand \index{Multiplication}
14450
14451 \end_inset
14452
14453  & modulus
14454 \begin_inset LatexCommand \index{Modulus}
14455
14456 \end_inset
14457
14458  and floating-point
14459 \begin_inset LatexCommand \index{Floating point support}
14460
14461 \end_inset
14462
14463  operations are implemented using external support routines.
14464  If an interrupt service routine needs to do any of these operations then
14465  the support routines (as mentioned in a following section) will have to
14466  be recompiled using the
14467 \emph on
14468  -
14469 \begin_inset ERT
14470 status collapsed
14471
14472 \begin_layout Standard
14473
14474
14475 \backslash
14476 /
14477 \end_layout
14478
14479 \end_inset
14480
14481 -stack-auto
14482 \begin_inset LatexCommand \index{-\/-stack-auto}
14483
14484 \end_inset
14485
14486
14487 \emph default
14488  option and the source file will need to be compiled using the 
14489 \emph on
14490 -
14491 \begin_inset ERT
14492 status collapsed
14493
14494 \begin_layout Standard
14495
14496
14497 \backslash
14498 /
14499 \end_layout
14500
14501 \end_inset
14502
14503 -int-long-reent
14504 \emph default
14505
14506 \begin_inset LatexCommand \index{-\/-int-long-reent}
14507
14508 \end_inset
14509
14510  compiler option.
14511  
14512 \newline
14513 Note, the type promotion
14514 \begin_inset LatexCommand \index{type promotion}
14515
14516 \end_inset
14517
14518  required by ANSI C can cause 16 bit routines to be used
14519 \begin_inset Marginal
14520 status collapsed
14521
14522 \begin_layout Standard
14523
14524 \series bold
14525 \InsetSpace ~
14526 !
14527 \end_layout
14528
14529 \end_inset
14530
14531  without the programmer being aware of it.
14532  See f.e.
14533  the cast 
14534 \family typewriter
14535 (unsigned char)(tail-1)
14536 \family default
14537  within the if clause in section 
14538 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
14539
14540 \end_inset
14541
14542 .
14543 \end_layout
14544
14545 \begin_layout Standard
14546 Calling other functions from an interrupt service routine is not recommended,
14547  avoid it if possible.
14548  Note that when some function is called from an interrupt service routine
14549  it should be preceded by a #pragma\InsetSpace ~
14550 nooverlay
14551 \begin_inset LatexCommand \index{\#pragma nooverlay}
14552
14553 \end_inset
14554
14555  if it is not reentrant.
14556  Furthermore nonreentrant functions should not be called from the main program
14557  while the interrupt service routine might be active.
14558  They also must not be called from low priority interrupt service routines
14559  while a high priority interrupt service routine might be active.
14560  You could use semaphores or make the function
14561 \emph on
14562  critical
14563 \emph default
14564  if all parameters are passed in registers.
14565 \newline
14566  Also see section 
14567 \begin_inset LatexCommand \ref{sub:Overlaying}
14568
14569 \end_inset
14570
14571 \InsetSpace ~
14572 about Overlaying and section 
14573 \begin_inset LatexCommand \ref{sub:Functions-using-private-banks}
14574
14575 \end_inset
14576
14577 \InsetSpace ~
14578 about Functions using private register banks.
14579 \begin_inset VSpace bigskip
14580 \end_inset
14581
14582
14583 \end_layout
14584
14585 \begin_layout Subsection
14586 MCS51/DS390 Interrupt Service Routines
14587 \end_layout
14588
14589 \begin_layout Standard
14590 Interrupt
14591 \begin_inset LatexCommand \index{interrupt}
14592
14593 \end_inset
14594
14595  numbers and the corresponding address & descriptions for the Standard 8051/8052
14596  are listed below.
14597  SDCC will automatically adjust the 
14598 \begin_inset LatexCommand \index{interrupt vector table}
14599
14600 \end_inset
14601
14602  to the maximum interrupt number specified.
14603 \newline
14604
14605 \end_layout
14606
14607 \begin_layout Standard
14608 \align center
14609 \begin_inset Tabular
14610 <lyxtabular version="3" rows="9" columns="3">
14611 <features>
14612 <column alignment="center" valignment="top" leftline="true" width="0in">
14613 <column alignment="left" valignment="top" leftline="true" width="0in">
14614 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0in">
14615 <row topline="true" bottomline="true">
14616 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14617 \begin_inset Text
14618
14619 \begin_layout Standard
14620 Interrupt #
14621 \end_layout
14622
14623 \end_inset
14624 </cell>
14625 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14626 \begin_inset Text
14627
14628 \begin_layout Standard
14629 Description
14630 \end_layout
14631
14632 \end_inset
14633 </cell>
14634 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14635 \begin_inset Text
14636
14637 \begin_layout Standard
14638 Vector Address
14639 \end_layout
14640
14641 \end_inset
14642 </cell>
14643 </row>
14644 <row topline="true">
14645 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14646 \begin_inset Text
14647
14648 \begin_layout Standard
14649 0
14650 \end_layout
14651
14652 \end_inset
14653 </cell>
14654 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14655 \begin_inset Text
14656
14657 \begin_layout Standard
14658 External 0
14659 \end_layout
14660
14661 \end_inset
14662 </cell>
14663 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14664 \begin_inset Text
14665
14666 \begin_layout Standard
14667 0x0003
14668 \end_layout
14669
14670 \end_inset
14671 </cell>
14672 </row>
14673 <row topline="true">
14674 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14675 \begin_inset Text
14676
14677 \begin_layout Standard
14678 1
14679 \end_layout
14680
14681 \end_inset
14682 </cell>
14683 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14684 \begin_inset Text
14685
14686 \begin_layout Standard
14687 Timer 0
14688 \end_layout
14689
14690 \end_inset
14691 </cell>
14692 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14693 \begin_inset Text
14694
14695 \begin_layout Standard
14696 0x000b
14697 \end_layout
14698
14699 \end_inset
14700 </cell>
14701 </row>
14702 <row topline="true">
14703 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14704 \begin_inset Text
14705
14706 \begin_layout Standard
14707 2
14708 \end_layout
14709
14710 \end_inset
14711 </cell>
14712 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14713 \begin_inset Text
14714
14715 \begin_layout Standard
14716 External 1
14717 \end_layout
14718
14719 \end_inset
14720 </cell>
14721 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14722 \begin_inset Text
14723
14724 \begin_layout Standard
14725 0x0013
14726 \end_layout
14727
14728 \end_inset
14729 </cell>
14730 </row>
14731 <row topline="true">
14732 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14733 \begin_inset Text
14734
14735 \begin_layout Standard
14736 3
14737 \end_layout
14738
14739 \end_inset
14740 </cell>
14741 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14742 \begin_inset Text
14743
14744 \begin_layout Standard
14745 Timer 1
14746 \end_layout
14747
14748 \end_inset
14749 </cell>
14750 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14751 \begin_inset Text
14752
14753 \begin_layout Standard
14754 0x001b
14755 \end_layout
14756
14757 \end_inset
14758 </cell>
14759 </row>
14760 <row topline="true">
14761 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14762 \begin_inset Text
14763
14764 \begin_layout Standard
14765 4
14766 \end_layout
14767
14768 \end_inset
14769 </cell>
14770 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14771 \begin_inset Text
14772
14773 \begin_layout Standard
14774 Serial
14775 \end_layout
14776
14777 \end_inset
14778 </cell>
14779 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14780 \begin_inset Text
14781
14782 \begin_layout Standard
14783 0x0023
14784 \end_layout
14785
14786 \end_inset
14787 </cell>
14788 </row>
14789 <row topline="true">
14790 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14791 \begin_inset Text
14792
14793 \begin_layout Standard
14794 5
14795 \end_layout
14796
14797 \end_inset
14798 </cell>
14799 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14800 \begin_inset Text
14801
14802 \begin_layout Standard
14803 Timer 2 (8052)
14804 \end_layout
14805
14806 \end_inset
14807 </cell>
14808 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14809 \begin_inset Text
14810
14811 \begin_layout Standard
14812 0x002b
14813 \end_layout
14814
14815 \end_inset
14816 </cell>
14817 </row>
14818 <row topline="true">
14819 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14820 \begin_inset Text
14821
14822 \begin_layout Standard
14823 ...
14824 \end_layout
14825
14826 \end_inset
14827 </cell>
14828 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14829 \begin_inset Text
14830
14831 \begin_layout Standard
14832
14833 \end_layout
14834
14835 \end_inset
14836 </cell>
14837 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14838 \begin_inset Text
14839
14840 \begin_layout Standard
14841 ...
14842 \end_layout
14843
14844 \end_inset
14845 </cell>
14846 </row>
14847 <row topline="true" bottomline="true">
14848 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14849 \begin_inset Text
14850
14851 \begin_layout Standard
14852 n
14853 \end_layout
14854
14855 \end_inset
14856 </cell>
14857 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14858 \begin_inset Text
14859
14860 \begin_layout Standard
14861
14862 \end_layout
14863
14864 \end_inset
14865 </cell>
14866 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14867 \begin_inset Text
14868
14869 \begin_layout Standard
14870 0x0003 + 8*n
14871 \end_layout
14872
14873 \end_inset
14874 </cell>
14875 </row>
14876 </lyxtabular>
14877
14878 \end_inset
14879
14880
14881 \newline
14882
14883 \end_layout
14884
14885 \begin_layout Standard
14886 If the interrupt service routine is defined without 
14887 \emph on
14888 using
14889 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
14890
14891 \end_inset
14892
14893
14894 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
14895
14896 \end_inset
14897
14898
14899 \emph default
14900  a register bank or with register bank 0 (
14901 \emph on
14902 using
14903 \emph default
14904  0), the compiler will save the registers used by itself on the stack upon
14905  entry and restore them at exit, however if such an interrupt service routine
14906  calls another function then the entire register bank will be saved on the
14907  stack.
14908  This scheme may be advantageous for small interrupt service routines which
14909  have low register usage.
14910 \end_layout
14911
14912 \begin_layout Standard
14913 If the interrupt service routine is defined to be using a specific register
14914  bank then only 
14915 \emph on
14916 a, b, dptr
14917 \emph default
14918  & psw are saved and restored, if such an interrupt service routine calls
14919  another function (using another register bank) then the entire register
14920  bank of the called function will be saved on the stack
14921 \begin_inset LatexCommand \index{stack}
14922
14923 \end_inset
14924
14925 .
14926  This scheme is recommended for larger interrupt service routines.
14927 \begin_inset VSpace bigskip
14928 \end_inset
14929
14930
14931 \end_layout
14932
14933 \begin_layout Subsection
14934 HC08
14935 \begin_inset LatexCommand \index{HC08}
14936
14937 \end_inset
14938
14939  Interrupt Service Routines
14940 \end_layout
14941
14942 \begin_layout Standard
14943 Since the number of interrupts
14944 \begin_inset LatexCommand \index{HC08!interrupt}
14945
14946 \end_inset
14947
14948  available is chip specific and the interrupt vector table always ends at
14949  the last byte of memory, the interrupt numbers corresponds to the interrupt
14950  vectors in reverse order of address.
14951  For example, interrupt 1 will use the interrupt vector at 0xfffc, interrupt
14952  2 will use the interrupt vector at 0xfffa, and so on.
14953  However, interrupt 0 (the reset vector at 0xfffe) is not redefinable in
14954  this way; instead see section 
14955 \begin_inset LatexCommand \ref{sub:Startup-Code}
14956
14957 \end_inset
14958
14959  for details on customizing startup.
14960 \begin_inset VSpace bigskip
14961 \end_inset
14962
14963
14964 \end_layout
14965
14966 \begin_layout Subsection
14967 Z80 Interrupt Service Routines
14968 \end_layout
14969
14970 \begin_layout Standard
14971 The Z80
14972 \begin_inset LatexCommand \index{Z80}
14973
14974 \end_inset
14975
14976  uses several different methods for determining the correct interrupt
14977 \begin_inset LatexCommand \index{Z80!interrupt}
14978
14979 \end_inset
14980
14981  vector depending on the hardware implementation.
14982  Therefore, SDCC ignores the optional interrupt number and does not attempt
14983  to generate an interrupt vector table.
14984 \end_layout
14985
14986 \begin_layout Standard
14987 By default, SDCC generates code for a maskable interrupt, which uses a RETI
14988  instruction to return from the interrupt.
14989  To write an interrupt handler for the non-maskable interrupt, which needs
14990  a RETN instruction instead, add the 
14991 \emph on
14992 critical
14993 \emph default
14994  keyword:
14995 \end_layout
14996
14997 \begin_layout Verse
14998
14999 \family typewriter
15000 void nmi_isr (void) critical interrupt
15001 \newline
15002
15003 \newline
15004 \InsetSpace ~
15005 \InsetSpace ~
15006 \InsetSpace ~
15007 \InsetSpace ~
15008 ...
15009  
15010 \newline
15011 }
15012 \end_layout
15013
15014 \begin_layout Standard
15015 However if you need to create a non-interruptable interrupt service routine
15016  you would also require the 
15017 \emph on
15018 critical
15019 \emph default
15020  keyword.
15021  To distinguish between this and an nmi_isr you must provide an interrupt
15022  number.
15023 \begin_inset VSpace bigskip
15024 \end_inset
15025
15026
15027 \end_layout
15028
15029 \begin_layout Section
15030 Enabling and Disabling Interrupts
15031 \end_layout
15032
15033 \begin_layout Subsection
15034 Critical Functions and Critical Statements
15035 \end_layout
15036
15037 \begin_layout Standard
15038 A special keyword may be associated with a block or a function declaring
15039  it as 
15040 \emph on
15041 critical
15042 \emph default
15043 .
15044  SDCC will generate code to disable all interrupts
15045 \begin_inset LatexCommand \index{interrupt}
15046
15047 \end_inset
15048
15049  upon entry to a critical function and restore the interrupt enable to the
15050  previous state before returning.
15051  Nesting critical functions will need one additional byte on the stack
15052 \begin_inset LatexCommand \index{stack}
15053
15054 \end_inset
15055
15056  for each call.
15057 \end_layout
15058
15059 \begin_layout Verse
15060
15061 \family typewriter
15062 int foo () __critical
15063 \begin_inset LatexCommand \index{critical}
15064
15065 \end_inset
15066
15067
15068 \begin_inset LatexCommand \index{\_\_critical}
15069
15070 \end_inset
15071
15072  
15073 \newline
15074
15075 \newline
15076 \InsetSpace ~
15077 \InsetSpace ~
15078 \InsetSpace ~
15079 \InsetSpace ~
15080 ...
15081  
15082 \newline
15083 \InsetSpace ~
15084 \InsetSpace ~
15085 \InsetSpace ~
15086 \InsetSpace ~
15087 ...
15088  
15089 \newline
15090 }
15091 \end_layout
15092
15093 \begin_layout Standard
15094 The critical attribute maybe used with other attributes like 
15095 \emph on
15096 reentrant.
15097 \emph default
15098
15099 \newline
15100 The keyword 
15101 \emph on
15102 critical
15103 \emph default
15104  may also be used to disable interrupts more locally:
15105 \end_layout
15106
15107 \begin_layout Verse
15108
15109 \family typewriter
15110 __critical{ i++; }
15111 \end_layout
15112
15113 \begin_layout Standard
15114 More than one statement could have been included in the block.
15115 \end_layout
15116
15117 \begin_layout Subsection
15118 Enabling and Disabling Interrupts directly
15119 \end_layout
15120
15121 \begin_layout Standard
15122 Interrupts
15123 \begin_inset LatexCommand \index{interrupt}
15124
15125 \end_inset
15126
15127  can also be disabled and enabled directly (8051):
15128 \end_layout
15129
15130 \begin_layout Verse
15131
15132 \family typewriter
15133 EA = 0;\InsetSpace ~
15134 \InsetSpace ~
15135 \InsetSpace ~
15136 \InsetSpace ~
15137 \InsetSpace ~
15138 \InsetSpace ~
15139 \InsetSpace ~
15140 \InsetSpace ~
15141 \InsetSpace ~
15142 \InsetSpace ~
15143 \InsetSpace ~
15144 \InsetSpace ~
15145 or:\InsetSpace ~
15146 \InsetSpace ~
15147 \InsetSpace ~
15148 \InsetSpace ~
15149 \InsetSpace ~
15150 \InsetSpace ~
15151 \InsetSpace ~
15152 \InsetSpace ~
15153 \InsetSpace ~
15154 \InsetSpace ~
15155 \InsetSpace ~
15156 EA_SAVE = EA;
15157 \end_layout
15158
15159 \begin_layout Verse
15160
15161 \family typewriter
15162 ...\InsetSpace ~
15163 \InsetSpace ~
15164 \InsetSpace ~
15165 \InsetSpace ~
15166 \InsetSpace ~
15167 \InsetSpace ~
15168 \InsetSpace ~
15169 \InsetSpace ~
15170 \InsetSpace ~
15171 \InsetSpace ~
15172 \InsetSpace ~
15173 \InsetSpace ~
15174 \InsetSpace ~
15175 \InsetSpace ~
15176 \InsetSpace ~
15177 \InsetSpace ~
15178 \InsetSpace ~
15179 \InsetSpace ~
15180 \InsetSpace ~
15181 \InsetSpace ~
15182 \InsetSpace ~
15183 \InsetSpace ~
15184 \InsetSpace ~
15185 \InsetSpace ~
15186 \InsetSpace ~
15187 \InsetSpace ~
15188 \InsetSpace ~
15189 \InsetSpace ~
15190 \InsetSpace ~
15191 \InsetSpace ~
15192 EA = 0;
15193 \end_layout
15194
15195 \begin_layout Verse
15196
15197 \family typewriter
15198 EA = 1;\InsetSpace ~
15199 \InsetSpace ~
15200 \InsetSpace ~
15201 \InsetSpace ~
15202 \InsetSpace ~
15203 \InsetSpace ~
15204 \InsetSpace ~
15205 \InsetSpace ~
15206 \InsetSpace ~
15207 \InsetSpace ~
15208 \InsetSpace ~
15209 \InsetSpace ~
15210 \InsetSpace ~
15211 \InsetSpace ~
15212 \InsetSpace ~
15213 \InsetSpace ~
15214 \InsetSpace ~
15215 \InsetSpace ~
15216 \InsetSpace ~
15217 \InsetSpace ~
15218 \InsetSpace ~
15219 \InsetSpace ~
15220 \InsetSpace ~
15221 \InsetSpace ~
15222 \InsetSpace ~
15223 \InsetSpace ~
15224 ...
15225 \end_layout
15226
15227 \begin_layout Verse
15228
15229 \family typewriter
15230 \InsetSpace ~
15231 \InsetSpace ~
15232 \InsetSpace ~
15233 \InsetSpace ~
15234 \InsetSpace ~
15235 \InsetSpace ~
15236 \InsetSpace ~
15237 \InsetSpace ~
15238 \InsetSpace ~
15239 \InsetSpace ~
15240 \InsetSpace ~
15241 \InsetSpace ~
15242 \InsetSpace ~
15243 \InsetSpace ~
15244 \InsetSpace ~
15245 \InsetSpace ~
15246 \InsetSpace ~
15247 \InsetSpace ~
15248 \InsetSpace ~
15249 \InsetSpace ~
15250 \InsetSpace ~
15251 \InsetSpace ~
15252 \InsetSpace ~
15253 \InsetSpace ~
15254 \InsetSpace ~
15255 \InsetSpace ~
15256 \InsetSpace ~
15257 \InsetSpace ~
15258 \InsetSpace ~
15259 \InsetSpace ~
15260 \InsetSpace ~
15261 \InsetSpace ~
15262 \InsetSpace ~
15263 EA = EA_SAVE;
15264 \end_layout
15265
15266 \begin_layout Standard
15267 On other architectures which have seperate opcodes for enabling and disabling
15268  interrupts you might want to make use of defines with inline assembly
15269 \begin_inset LatexCommand \index{Assembler routines}
15270
15271 \end_inset
15272
15273  (HC08
15274 \begin_inset LatexCommand \index{HC08!interrupt}
15275
15276 \end_inset
15277
15278 ):
15279 \end_layout
15280
15281 \begin_layout Verse
15282
15283 \family typewriter
15284 #define CLI _asm
15285 \begin_inset LatexCommand \index{\_asm}
15286
15287 \end_inset
15288
15289 \InsetSpace ~
15290 \InsetSpace ~
15291 cli\InsetSpace ~
15292 \InsetSpace ~
15293 _endasm
15294 \begin_inset LatexCommand \index{\_endasm}
15295
15296 \end_inset
15297
15298
15299 \end_layout
15300
15301 \begin_layout Verse
15302
15303 \family typewriter
15304 #define SEI _asm\InsetSpace ~
15305 \InsetSpace ~
15306 sei\InsetSpace ~
15307 \InsetSpace ~
15308 _endasm; 
15309 \end_layout
15310
15311 \begin_layout Verse
15312
15313 \family typewriter
15314 ...
15315 \end_layout
15316
15317 \begin_layout Standard
15318 Note: it is sometimes sufficient to disable only a specific interrupt source
15319  like f.e.
15320  a timer or serial interrupt by manipulating an 
15321 \emph on
15322 interrupt mask
15323 \begin_inset LatexCommand \index{interrupt mask}
15324
15325 \end_inset
15326
15327
15328 \emph default
15329  register.
15330  
15331 \end_layout
15332
15333 \begin_layout Standard
15334 Usually the time during which interrupts are disabled should be kept as
15335  short as possible.
15336  This minimizes both 
15337 \emph on
15338 interrupt latency
15339 \emph default
15340
15341 \begin_inset LatexCommand \index{interrupt latency}
15342
15343 \end_inset
15344
15345  (the time between the occurrence of the interrupt and the execution of
15346  the first code in the interrupt routine) and 
15347 \emph on
15348 interrupt jitter
15349 \emph default
15350
15351 \begin_inset LatexCommand \index{interrupt jitter}
15352
15353 \end_inset
15354
15355  (the difference between the shortest and the longest interrupt latency).
15356  These really are something different, f.e.
15357  a serial interrupt has to be served before its buffer overruns so it cares
15358  for the maximum interrupt latency, whereas it does not care about jitter.
15359  On a loudspeaker driven via a digital to analog converter which is fed
15360  by an interrupt a latency of a few milliseconds might be tolerable, whereas
15361  a much smaller jitter will be very audible.
15362 \end_layout
15363
15364 \begin_layout Standard
15365 You can reenable interrupts within an interrupt routine and on some architecture
15366 s you can make use of two (or more) levels of 
15367 \emph on
15368 interrupt priorities
15369 \emph default
15370
15371 \begin_inset LatexCommand \index{interrupt priority}
15372
15373 \end_inset
15374
15375 .
15376  On some architectures which don't support interrupt priorities these can
15377  be implemented by manipulating the interrupt mask and reenabling interrupts
15378  within the interrupt routine.
15379  Check there is sufficient space on the stack
15380 \begin_inset LatexCommand \index{stack}
15381
15382 \end_inset
15383
15384  and don't add complexity unless you have to.
15385  
15386 \end_layout
15387
15388 \begin_layout Subsection
15389 Semaphore
15390 \begin_inset LatexCommand \index{semaphore}
15391
15392 \end_inset
15393
15394  locking (mcs51/ds390)
15395 \end_layout
15396
15397 \begin_layout Standard
15398 Some architectures (mcs51/ds390) have an atomic
15399 \begin_inset LatexCommand \index{atomic}
15400
15401 \end_inset
15402
15403  bit test and
15404 \emph on
15405  
15406 \emph default
15407 clear
15408 \emph on
15409  
15410 \emph default
15411 instruction.
15412  These type of instructions are typically used in preemptive multitasking
15413  systems, where a routine f.e.
15414  claims the use of a data structure ('acquires a lock
15415 \begin_inset LatexCommand \index{lock}
15416
15417 \end_inset
15418
15419  on it'), makes some modifications and then releases the lock when the data
15420  structure is consistent again.
15421  The instruction may also be used if interrupt and non-interrupt code have
15422  to compete for a resource.
15423  With the atomic bit test and clear instruction interrupts
15424 \begin_inset LatexCommand \index{interrupt}
15425
15426 \end_inset
15427
15428  don't have to be disabled for the locking operation.
15429  
15430 \end_layout
15431
15432 \begin_layout Standard
15433 SDCC generates this instruction if the source follows this pattern:
15434 \end_layout
15435
15436 \begin_layout Verse
15437
15438 \family typewriter
15439 volatile
15440 \begin_inset LatexCommand \index{volatile}
15441
15442 \end_inset
15443
15444  bit resource_is_free; 
15445 \newline
15446
15447 \newline
15448 if (resource_is_free) 
15449 \newline
15450 \InsetSpace ~
15451 \InsetSpace ~
15452
15453 \newline
15454 \InsetSpace ~
15455 \InsetSpace ~
15456 \InsetSpace ~
15457 \InsetSpace ~
15458 resource_is_free=0; 
15459 \newline
15460 \InsetSpace ~
15461 \InsetSpace ~
15462 \InsetSpace ~
15463 \InsetSpace ~
15464 ...
15465  
15466 \newline
15467 \InsetSpace ~
15468 \InsetSpace ~
15469 \InsetSpace ~
15470 \InsetSpace ~
15471 resource_is_free=1;
15472 \newline
15473 \InsetSpace ~
15474 \InsetSpace ~
15475
15476 \end_layout
15477
15478 \begin_layout Standard
15479 Note, mcs51 and ds390 support only an atomic
15480 \begin_inset LatexCommand \index{atomic}
15481
15482 \end_inset
15483
15484  bit test and 
15485 \emph on
15486 clear
15487 \emph default
15488  instruction (as opposed to atomic bit test and 
15489 \emph on
15490 set).
15491 \end_layout
15492
15493 \begin_layout Section
15494 Functions using private register banks
15495 \begin_inset LatexCommand \label{sub:Functions-using-private-banks}
15496
15497 \end_inset
15498
15499  (mcs51/ds390)
15500 \end_layout
15501
15502 \begin_layout Standard
15503 Some architectures have support for quickly changing register sets.
15504  SDCC supports this feature with the 
15505 \emph on
15506 using
15507 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
15508
15509 \end_inset
15510
15511
15512 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
15513
15514 \end_inset
15515
15516
15517 \emph default
15518  attribute (which tells the compiler to use a register bank
15519 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
15520
15521 \end_inset
15522
15523  other than the default bank zero).
15524  It should only be applied to 
15525 \emph on
15526 interrupt
15527 \begin_inset LatexCommand \index{interrupt}
15528
15529 \end_inset
15530
15531
15532 \emph default
15533  functions (see footnote below).
15534  This will in most circumstances make the generated ISR code more efficient
15535  since it will not have to save registers on the stack.
15536 \end_layout
15537
15538 \begin_layout Standard
15539 The 
15540 \emph on
15541 using
15542 \emph default
15543  attribute will have no effect on the generated code for a 
15544 \emph on
15545 non-interrupt
15546 \emph default
15547  function (but may occasionally be useful anyway
15548 \begin_inset Foot
15549 status open
15550
15551 \begin_layout Standard
15552 possible exception: if a function is called ONLY from 'interrupt' functions
15553  using a particular bank, it can be declared with the same 'using' attribute
15554  as the calling 'interrupt' functions.
15555  For instance, if you have several ISRs using bank one, and all of them
15556  call memcpy(), it might make sense to create a specialized version of memcpy()
15557  'using 1', since this would prevent the ISR from having to save bank zero
15558  to the stack on entry and switch to bank zero before calling the function
15559 \end_layout
15560
15561 \end_inset
15562
15563 ).
15564 \newline
15565
15566 \emph on
15567 (pending: Note, nowadays the 
15568 \emph default
15569 using
15570 \emph on
15571  attribute has an effect on
15572 \emph default
15573  
15574 \emph on
15575 the generated code for a 
15576 \emph default
15577 non-interrupt
15578 \emph on
15579  function
15580 \emph default
15581 .
15582 \emph on
15583 )
15584 \end_layout
15585
15586 \begin_layout Standard
15587 An 
15588 \emph on
15589 interrupt
15590 \emph default
15591  function using a non-zero bank will assume that it can trash that register
15592  bank, and will not save it.
15593  Since high-priority interrupts
15594 \begin_inset LatexCommand \index{interrupts}
15595
15596 \end_inset
15597
15598
15599 \begin_inset LatexCommand \index{interrupt priority}
15600
15601 \end_inset
15602
15603  can interrupt low-priority ones on the 8051 and friends, this means that
15604  if a high-priority ISR 
15605 \emph on
15606 using
15607 \emph default
15608  a particular bank occurs while processing a low-priority ISR 
15609 \emph on
15610 using
15611 \emph default
15612  the same bank, terrible and bad things can happen.
15613  To prevent this, no single register bank should be 
15614 \emph on
15615 used
15616 \emph default
15617  by both a high priority and a low priority ISR.
15618  This is probably most easily done by having all high priority ISRs use
15619  one bank and all low priority ISRs use another.
15620  If you have an ISR which can change priority at runtime, you're on your
15621  own: I suggest using the default bank zero and taking the small performance
15622  hit.
15623 \end_layout
15624
15625 \begin_layout Standard
15626 It is most efficient if your ISR calls no other functions.
15627  If your ISR must call other functions, it is most efficient if those functions
15628  use the same bank as the ISR (see note 1 below); the next best is if the
15629  called functions use bank zero.
15630  It is very inefficient to call a function using a different, non-zero bank
15631  from an ISR.
15632  
15633 \begin_inset VSpace bigskip
15634 \end_inset
15635
15636
15637 \end_layout
15638
15639 \begin_layout Section
15640 Startup Code
15641 \begin_inset LatexCommand \label{sub:Startup-Code}
15642
15643 \end_inset
15644
15645
15646 \begin_inset LatexCommand \index{Startup code}
15647
15648 \end_inset
15649
15650
15651 \end_layout
15652
15653 \begin_layout Subsection
15654 MCS51/DS390 Startup Code
15655 \end_layout
15656
15657 \begin_layout Standard
15658 The compiler triggers the linker to link certain initialization modules
15659  from the runtime library
15660 \begin_inset LatexCommand \index{Runtime library}
15661
15662 \end_inset
15663
15664  called crt<something>.
15665  Only the necessary ones are linked, for instance crtxstack.asm (GSINIT1,
15666  GSINIT5) is not linked unless the -
15667 \series bold
15668
15669 \begin_inset ERT
15670 status open
15671
15672 \begin_layout Standard
15673
15674
15675 \backslash
15676 /
15677 \end_layout
15678
15679 \end_inset
15680
15681
15682 \series default
15683 -xstack option is used.
15684  These modules are highly entangled by the use of special segments/areas,
15685  but a common layout is shown below:
15686 \end_layout
15687
15688 \begin_layout Verse
15689
15690 \family typewriter
15691 \series bold
15692 \size footnotesize
15693 (main.asm)
15694 \end_layout
15695
15696 \begin_layout Verse
15697
15698 \family typewriter
15699 \size footnotesize
15700 \InsetSpace ~
15701 \InsetSpace ~
15702 \InsetSpace ~
15703 \InsetSpace ~
15704 \InsetSpace ~
15705 \InsetSpace ~
15706 \InsetSpace ~
15707 \InsetSpace ~
15708 .area HOME (CODE)
15709 \newline
15710 __interrupt_vect:
15711 \newline
15712 \InsetSpace ~
15713 \InsetSpace ~
15714 \InsetSpace ~
15715 \InsetSpace ~
15716 \InsetSpace ~
15717 \InsetSpace ~
15718 \InsetSpace ~
15719 \InsetSpace ~
15720 ljmp __sdcc_gsinit_startup
15721 \end_layout
15722
15723 \begin_layout Verse
15724
15725 \family typewriter
15726 \series bold
15727 \size footnotesize
15728 (crtstart.asm)
15729 \end_layout
15730
15731 \begin_layout Verse
15732
15733 \family typewriter
15734 \size footnotesize
15735 \InsetSpace ~
15736 \InsetSpace ~
15737 \InsetSpace ~
15738 \InsetSpace ~
15739 \InsetSpace ~
15740 \InsetSpace ~
15741 \InsetSpace ~
15742 \InsetSpace ~
15743 .area GSINIT0 (CODE)
15744 \newline
15745 __sdcc_gsinit_startup::
15746 \newline
15747 \InsetSpace ~
15748 \InsetSpace ~
15749 \InsetSpace ~
15750 \InsetSpace ~
15751 \InsetSpace ~
15752 \InsetSpace ~
15753 \InsetSpace ~
15754 \InsetSpace ~
15755 mov sp,#__start__stack - 1
15756 \end_layout
15757
15758 \begin_layout Verse
15759
15760 \family typewriter
15761 \series bold
15762 \size footnotesize
15763 (crtxstack.asm)
15764 \end_layout
15765
15766 \begin_layout Verse
15767
15768 \family typewriter
15769 \size footnotesize
15770 \InsetSpace ~
15771 \InsetSpace ~
15772 \InsetSpace ~
15773 \InsetSpace ~
15774 \InsetSpace ~
15775 \InsetSpace ~
15776 \InsetSpace ~
15777 \InsetSpace ~
15778 .area GSINIT1 (CODE)
15779 \newline
15780 __sdcc_init_xstack::
15781 \newline
15782 ; Need to initialize in GSINIT1 in
15783  case the user's __sdcc_external_startup uses the xstack.
15784 \newline
15785 \InsetSpace ~
15786 \InsetSpace ~
15787 \InsetSpace ~
15788 \InsetSpace ~
15789 \InsetSpace ~
15790 \InsetSpace ~
15791 \InsetSpace ~
15792 \InsetSpace ~
15793 mov __XPAGE,#(__start__x
15794 stack >> 8)
15795 \newline
15796 \InsetSpace ~
15797 \InsetSpace ~
15798 \InsetSpace ~
15799 \InsetSpace ~
15800 \InsetSpace ~
15801 \InsetSpace ~
15802 \InsetSpace ~
15803 \InsetSpace ~
15804 mov _spx,#__start__xstack
15805 \end_layout
15806
15807 \begin_layout Verse
15808
15809 \family typewriter
15810 \series bold
15811 \size footnotesize
15812 (crtstart.asm)
15813 \end_layout
15814
15815 \begin_layout Verse
15816
15817 \family typewriter
15818 \size footnotesize
15819 \InsetSpace ~
15820 \InsetSpace ~
15821 \InsetSpace ~
15822 \InsetSpace ~
15823 \InsetSpace ~
15824 \InsetSpace ~
15825 \InsetSpace ~
15826 \InsetSpace ~
15827 .area GSINIT2 (CODE)
15828 \newline
15829 \InsetSpace ~
15830 \InsetSpace ~
15831 \InsetSpace ~
15832 \InsetSpace ~
15833 \InsetSpace ~
15834 \InsetSpace ~
15835 \InsetSpace ~
15836 \InsetSpace ~
15837 lcall __sdcc_external_startup
15838 \newline
15839 \InsetSpace ~
15840 \InsetSpace ~
15841 \InsetSpace ~
15842 \InsetSpace ~
15843 \InsetSpace ~
15844 \InsetSpace ~
15845 \InsetSpace ~
15846 \InsetSpace ~
15847 mov a,dpl
15848 \newline
15849 \InsetSpace ~
15850 \InsetSpace ~
15851 \InsetSpace ~
15852 \InsetSpace ~
15853 \InsetSpace ~
15854 \InsetSpace ~
15855 \InsetSpace ~
15856 \InsetSpace ~
15857 jz __sdcc_init_data
15858 \newline
15859 \InsetSpace ~
15860 \InsetSpace ~
15861 \InsetSpace ~
15862 \InsetSpace ~
15863 \InsetSpace ~
15864 \InsetSpace ~
15865 \InsetSpace ~
15866 \InsetSpace ~
15867 ljmp
15868  __sdcc_program_startup
15869 \newline
15870 __sdcc_init_data:
15871 \end_layout
15872
15873 \begin_layout Verse
15874
15875 \family typewriter
15876 \series bold
15877 \size footnotesize
15878 (crtxinit.asm)
15879 \end_layout
15880
15881 \begin_layout Verse
15882
15883 \family typewriter
15884 \size footnotesize
15885 \InsetSpace ~
15886 \InsetSpace ~
15887 \InsetSpace ~
15888 \InsetSpace ~
15889 \InsetSpace ~
15890 \InsetSpace ~
15891 \InsetSpace ~
15892 \InsetSpace ~
15893 .area GSINIT3 (CODE)
15894 \newline
15895 __mcs51_genXINIT::
15896 \newline
15897 \InsetSpace ~
15898 \InsetSpace ~
15899 \InsetSpace ~
15900 \InsetSpace ~
15901 \InsetSpace ~
15902 \InsetSpace ~
15903 \InsetSpace ~
15904 \InsetSpace ~
15905 mov r1,#l_XINIT
15906 \newline
15907 \InsetSpace ~
15908 \InsetSpace ~
15909 \InsetSpace ~
15910 \InsetSpace ~
15911 \InsetSpace ~
15912 \InsetSpace ~
15913 \InsetSpace ~
15914 \InsetSpace ~
15915 mov a,r1
15916 \newline
15917 \InsetSpace ~
15918 \InsetSpace ~
15919 \InsetSpace ~
15920 \InsetSpace ~
15921 \InsetSpace ~
15922 \InsetSpace ~
15923 \InsetSpace ~
15924 \InsetSpace ~
15925 orl a,#(l_XINIT
15926  >> 8)
15927 \newline
15928 \InsetSpace ~
15929 \InsetSpace ~
15930 \InsetSpace ~
15931 \InsetSpace ~
15932 \InsetSpace ~
15933 \InsetSpace ~
15934 \InsetSpace ~
15935 \InsetSpace ~
15936 jz 00003$
15937 \newline
15938 \InsetSpace ~
15939 \InsetSpace ~
15940 \InsetSpace ~
15941 \InsetSpace ~
15942 \InsetSpace ~
15943 \InsetSpace ~
15944 \InsetSpace ~
15945 \InsetSpace ~
15946 mov r2,#((l_XINIT+255) >> 8)
15947 \newline
15948 \InsetSpace ~
15949 \InsetSpace ~
15950 \InsetSpace ~
15951 \InsetSpace ~
15952 \InsetSpace ~
15953 \InsetSpace ~
15954 \InsetSpace ~
15955 \InsetSpace ~
15956 mov dptr,#s_XINIT
15957 \newline
15958 \InsetSpace ~
15959 \InsetSpace ~
15960 \InsetSpace ~
15961 \InsetSpace ~
15962 \InsetSpace ~
15963 \InsetSpace ~
15964 \InsetSpace ~
15965 \InsetSpace ~
15966 mov r0,#s_XISEG
15967 \newline
15968 \InsetSpace ~
15969 \InsetSpace ~
15970 \InsetSpace ~
15971 \InsetSpace ~
15972 \InsetSpace ~
15973 \InsetSpace ~
15974 \InsetSpace ~
15975 \InsetSpace ~
15976 mov
15977  __XPAGE,#(s_XISEG >> 8)
15978 \newline
15979 00001$:\InsetSpace ~
15980 clr a
15981 \newline
15982 \InsetSpace ~
15983 \InsetSpace ~
15984 \InsetSpace ~
15985 \InsetSpace ~
15986 \InsetSpace ~
15987 \InsetSpace ~
15988 \InsetSpace ~
15989 \InsetSpace ~
15990 movc a,@a+dptr
15991 \newline
15992 \InsetSpace ~
15993 \InsetSpace ~
15994 \InsetSpace ~
15995 \InsetSpace ~
15996 \InsetSpace ~
15997 \InsetSpace ~
15998 \InsetSpace ~
15999 \InsetSpace ~
16000 movx @r0,a
16001 \newline
16002 \InsetSpace ~
16003 \InsetSpace ~
16004 \InsetSpace ~
16005 \InsetSpace ~
16006 \InsetSpace ~
16007 \InsetSpace ~
16008 \InsetSpace ~
16009 \InsetSpace ~
16010 inc dptr
16011 \newline
16012 \InsetSpace ~
16013 \InsetSpace ~
16014 \InsetSpace ~
16015 \InsetSpace ~
16016 \InsetSpace ~
16017 \InsetSpace ~
16018 \InsetSpace ~
16019 \InsetSpace ~
16020 inc
16021  r0
16022 \newline
16023 \InsetSpace ~
16024 \InsetSpace ~
16025 \InsetSpace ~
16026 \InsetSpace ~
16027 \InsetSpace ~
16028 \InsetSpace ~
16029 \InsetSpace ~
16030 \InsetSpace ~
16031 cjne r0,#0,00002$
16032 \newline
16033 \InsetSpace ~
16034 \InsetSpace ~
16035 \InsetSpace ~
16036 \InsetSpace ~
16037 \InsetSpace ~
16038 \InsetSpace ~
16039 \InsetSpace ~
16040 \InsetSpace ~
16041 inc __XPAGE
16042 \newline
16043 00002$:\InsetSpace ~
16044 djnz r1,00001$
16045 \newline
16046 \InsetSpace ~
16047 \InsetSpace ~
16048 \InsetSpace ~
16049 \InsetSpace ~
16050 \InsetSpace ~
16051 \InsetSpace ~
16052 \InsetSpace ~
16053 \InsetSpace ~
16054 djnz r2,00001$
16055 \newline
16056 \InsetSpace ~
16057 \InsetSpace ~
16058 \InsetSpace ~
16059 \InsetSpace ~
16060 \InsetSpace ~
16061 \InsetSpace ~
16062 \InsetSpace ~
16063 \InsetSpace ~
16064 mov __XPAGE,#0
16065 xFF
16066 \newline
16067 00003$:
16068 \end_layout
16069
16070 \begin_layout Verse
16071
16072 \family typewriter
16073 \series bold
16074 \size footnotesize
16075 (crtclear.asm)
16076 \end_layout
16077
16078 \begin_layout Verse
16079
16080 \family typewriter
16081 \size footnotesize
16082 \InsetSpace ~
16083 \InsetSpace ~
16084 \InsetSpace ~
16085 \InsetSpace ~
16086 \InsetSpace ~
16087 \InsetSpace ~
16088 \InsetSpace ~
16089 \InsetSpace ~
16090 .area GSINIT4 (CODE)
16091 \newline
16092 __mcs51_genRAMCLEAR::
16093 \newline
16094 \InsetSpace ~
16095 \InsetSpace ~
16096 \InsetSpace ~
16097 \InsetSpace ~
16098 \InsetSpace ~
16099 \InsetSpace ~
16100 \InsetSpace ~
16101 \InsetSpace ~
16102 clr a
16103 \newline
16104 \InsetSpace ~
16105 \InsetSpace ~
16106 \InsetSpace ~
16107 \InsetSpace ~
16108 \InsetSpace ~
16109 \InsetSpace ~
16110 \InsetSpace ~
16111 \InsetSpace ~
16112 mov r0,#(l_IRAM-1)
16113 \newline
16114 00004$:\InsetSpace ~
16115 mov
16116  @r0,a
16117 \newline
16118 \InsetSpace ~
16119 \InsetSpace ~
16120 \InsetSpace ~
16121 \InsetSpace ~
16122 \InsetSpace ~
16123 \InsetSpace ~
16124 \InsetSpace ~
16125 \InsetSpace ~
16126 djnz r0,00004$
16127 \newline
16128 ; _mcs51_genRAMCLEAR() end
16129 \end_layout
16130
16131 \begin_layout Verse
16132
16133 \family typewriter
16134 \series bold
16135 \size footnotesize
16136 (crtxclear.asm)
16137 \end_layout
16138
16139 \begin_layout Verse
16140
16141 \family typewriter
16142 \size footnotesize
16143 \InsetSpace ~
16144 \InsetSpace ~
16145 \InsetSpace ~
16146 \InsetSpace ~
16147 \InsetSpace ~
16148 \InsetSpace ~
16149 \InsetSpace ~
16150 \InsetSpace ~
16151 .area GSINIT4 (CODE)
16152 \newline
16153 __mcs51_genXRAMCLEAR::
16154 \newline
16155 \InsetSpace ~
16156 \InsetSpace ~
16157 \InsetSpace ~
16158 \InsetSpace ~
16159 \InsetSpace ~
16160 \InsetSpace ~
16161 \InsetSpace ~
16162 \InsetSpace ~
16163 mov r0,#l_PSEG
16164 \newline
16165 \InsetSpace ~
16166 \InsetSpace ~
16167 \InsetSpace ~
16168 \InsetSpace ~
16169 \InsetSpace ~
16170 \InsetSpace ~
16171 \InsetSpace ~
16172 \InsetSpace ~
16173 mov a,r0
16174 \newline
16175 \InsetSpace ~
16176 \InsetSpace ~
16177 \InsetSpace ~
16178 \InsetSpace ~
16179 \InsetSpace ~
16180 \InsetSpace ~
16181 \InsetSpace ~
16182 \InsetSpace ~
16183 orl a,#(l_PSEG
16184  >> 8)
16185 \newline
16186 \InsetSpace ~
16187 \InsetSpace ~
16188 \InsetSpace ~
16189 \InsetSpace ~
16190 \InsetSpace ~
16191 \InsetSpace ~
16192 \InsetSpace ~
16193 \InsetSpace ~
16194 jz 00006$
16195 \newline
16196 \InsetSpace ~
16197 \InsetSpace ~
16198 \InsetSpace ~
16199 \InsetSpace ~
16200 \InsetSpace ~
16201 \InsetSpace ~
16202 \InsetSpace ~
16203 \InsetSpace ~
16204 mov r1,#s_PSEG
16205 \newline
16206 \InsetSpace ~
16207 \InsetSpace ~
16208 \InsetSpace ~
16209 \InsetSpace ~
16210 \InsetSpace ~
16211 \InsetSpace ~
16212 \InsetSpace ~
16213 \InsetSpace ~
16214 mov __XPAGE,#(s_PSEG >> 8)
16215 \newline
16216 \InsetSpace ~
16217 \InsetSpace ~
16218 \InsetSpace ~
16219 \InsetSpace ~
16220 \InsetSpace ~
16221 \InsetSpace ~
16222 \InsetSpace ~
16223 \InsetSpace ~
16224 clr a
16225 \newline
16226 00005$:\InsetSpace ~
16227 movx
16228  @r1,a
16229 \newline
16230 \InsetSpace ~
16231 \InsetSpace ~
16232 \InsetSpace ~
16233 \InsetSpace ~
16234 \InsetSpace ~
16235 \InsetSpace ~
16236 \InsetSpace ~
16237 \InsetSpace ~
16238 inc r1
16239 \newline
16240 \InsetSpace ~
16241 \InsetSpace ~
16242 \InsetSpace ~
16243 \InsetSpace ~
16244 \InsetSpace ~
16245 \InsetSpace ~
16246 \InsetSpace ~
16247 \InsetSpace ~
16248 djnz r0,00005$
16249 \newline
16250 00006$:
16251 \newline
16252 \InsetSpace ~
16253 \InsetSpace ~
16254 \InsetSpace ~
16255 \InsetSpace ~
16256 \InsetSpace ~
16257 \InsetSpace ~
16258 \InsetSpace ~
16259 \InsetSpace ~
16260 mov r0,#l_XSEG
16261 \newline
16262 \InsetSpace ~
16263 \InsetSpace ~
16264 \InsetSpace ~
16265 \InsetSpace ~
16266 \InsetSpace ~
16267 \InsetSpace ~
16268 \InsetSpace ~
16269 \InsetSpace ~
16270 mov a,r0
16271 \newline
16272 \InsetSpace ~
16273 \InsetSpace ~
16274 \InsetSpace ~
16275 \InsetSpace ~
16276 \InsetSpace ~
16277 \InsetSpace ~
16278 \InsetSpace ~
16279 \InsetSpace ~
16280 orl a,#(l_XSEG >>
16281  8)
16282 \newline
16283 \InsetSpace ~
16284 \InsetSpace ~
16285 \InsetSpace ~
16286 \InsetSpace ~
16287 \InsetSpace ~
16288 \InsetSpace ~
16289 \InsetSpace ~
16290 \InsetSpace ~
16291 jz 00008$
16292 \newline
16293 \InsetSpace ~
16294 \InsetSpace ~
16295 \InsetSpace ~
16296 \InsetSpace ~
16297 \InsetSpace ~
16298 \InsetSpace ~
16299 \InsetSpace ~
16300 \InsetSpace ~
16301 mov r1,#((l_XSEG + 255) >> 8)
16302 \newline
16303 \InsetSpace ~
16304 \InsetSpace ~
16305 \InsetSpace ~
16306 \InsetSpace ~
16307 \InsetSpace ~
16308 \InsetSpace ~
16309 \InsetSpace ~
16310 \InsetSpace ~
16311 mov dptr,#s_XSEG
16312 \newline
16313 \InsetSpace ~
16314 \InsetSpace ~
16315 \InsetSpace ~
16316 \InsetSpace ~
16317 \InsetSpace ~
16318 \InsetSpace ~
16319 \InsetSpace ~
16320 \InsetSpace ~
16321 clr a
16322 \newline
16323 00007$:\InsetSpace ~
16324 movx
16325  @dptr,a
16326 \newline
16327 \InsetSpace ~
16328 \InsetSpace ~
16329 \InsetSpace ~
16330 \InsetSpace ~
16331 \InsetSpace ~
16332 \InsetSpace ~
16333 \InsetSpace ~
16334 \InsetSpace ~
16335 inc dptr
16336 \newline
16337 \InsetSpace ~
16338 \InsetSpace ~
16339 \InsetSpace ~
16340 \InsetSpace ~
16341 \InsetSpace ~
16342 \InsetSpace ~
16343 \InsetSpace ~
16344 \InsetSpace ~
16345 djnz r0,00007$
16346 \newline
16347 \InsetSpace ~
16348 \InsetSpace ~
16349 \InsetSpace ~
16350 \InsetSpace ~
16351 \InsetSpace ~
16352 \InsetSpace ~
16353 \InsetSpace ~
16354 \InsetSpace ~
16355 djnz r1,00007$
16356 \newline
16357 00008$:
16358 \end_layout
16359
16360 \begin_layout Verse
16361
16362 \family typewriter
16363 \series bold
16364 \size footnotesize
16365 (crtxstack.asm)
16366 \end_layout
16367
16368 \begin_layout Verse
16369
16370 \family typewriter
16371 \size footnotesize
16372 \InsetSpace ~
16373 \InsetSpace ~
16374 \InsetSpace ~
16375 \InsetSpace ~
16376 \InsetSpace ~
16377 \InsetSpace ~
16378 \InsetSpace ~
16379 \InsetSpace ~
16380 .area GSINIT5 (CODE)
16381 \newline
16382 ; Need to initialize in GSINIT5 because __mcs51_genXINIT
16383  modifies __XPAGE
16384 \newline
16385 ; and __mcs51_genRAMCLEAR modifies _spx.
16386 \newline
16387 \InsetSpace ~
16388 \InsetSpace ~
16389 \InsetSpace ~
16390 \InsetSpace ~
16391 \InsetSpace ~
16392 \InsetSpace ~
16393 \InsetSpace ~
16394 \InsetSpace ~
16395 mov __XPAGE,#(__start__x
16396 stack >> 8)
16397 \newline
16398 \InsetSpace ~
16399 \InsetSpace ~
16400 \InsetSpace ~
16401 \InsetSpace ~
16402 \InsetSpace ~
16403 \InsetSpace ~
16404 \InsetSpace ~
16405 \InsetSpace ~
16406 mov _spx,#__start__xstack
16407 \end_layout
16408
16409 \begin_layout Verse
16410
16411 \family typewriter
16412 \series bold
16413 \size footnotesize
16414 (application modules)
16415 \end_layout
16416
16417 \begin_layout Verse
16418
16419 \family typewriter
16420 \size footnotesize
16421 \InsetSpace ~
16422 \InsetSpace ~
16423 \InsetSpace ~
16424 \InsetSpace ~
16425 \InsetSpace ~
16426 \InsetSpace ~
16427 \InsetSpace ~
16428 \InsetSpace ~
16429 .area GSINIT (CODE)
16430 \end_layout
16431
16432 \begin_layout Verse
16433
16434 \family typewriter
16435 \series bold
16436 \size footnotesize
16437 (main.asm)
16438 \end_layout
16439
16440 \begin_layout Verse
16441
16442 \family typewriter
16443 \size footnotesize
16444 \InsetSpace ~
16445 \InsetSpace ~
16446 \InsetSpace ~
16447 \InsetSpace ~
16448 \InsetSpace ~
16449 \InsetSpace ~
16450 \InsetSpace ~
16451 \InsetSpace ~
16452 .area GSFINAL (CODE)
16453 \newline
16454 \InsetSpace ~
16455 \InsetSpace ~
16456 \InsetSpace ~
16457 \InsetSpace ~
16458 \InsetSpace ~
16459 \InsetSpace ~
16460 \InsetSpace ~
16461 \InsetSpace ~
16462 ljmp __sdcc_program_startup
16463 \newline
16464 ;---------------------------------
16465 -----------------------
16466 \newline
16467 ; Home
16468 \newline
16469 ;--------------------------------------------------
16470 ------
16471 \newline
16472 \InsetSpace ~
16473 \InsetSpace ~
16474 \InsetSpace ~
16475 \InsetSpace ~
16476 \InsetSpace ~
16477 \InsetSpace ~
16478 \InsetSpace ~
16479 \InsetSpace ~
16480 .area HOME (CODE)
16481 \newline
16482 \InsetSpace ~
16483 \InsetSpace ~
16484 \InsetSpace ~
16485 \InsetSpace ~
16486 \InsetSpace ~
16487 \InsetSpace ~
16488 \InsetSpace ~
16489 \InsetSpace ~
16490 .area CSEG (CODE)
16491 \newline
16492 __sdcc_program_startup:
16493 \newline
16494 \InsetSpace ~
16495 \InsetSpace ~
16496 \InsetSpace ~
16497 \InsetSpace ~
16498 \InsetSpace ~
16499 \InsetSpace ~
16500 \InsetSpace ~
16501 \InsetSpace ~
16502 lcall _main
16503 \newline
16504 ;
16505  return from main will lock up
16506 \newline
16507 \InsetSpace ~
16508 \InsetSpace ~
16509 \InsetSpace ~
16510 \InsetSpace ~
16511 \InsetSpace ~
16512 \InsetSpace ~
16513 \InsetSpace ~
16514 \InsetSpace ~
16515 sjmp .
16516 \end_layout
16517
16518 \begin_layout Standard
16519 One of these modules (crtstart.asm) contains a call to the C routine 
16520 \emph on
16521 _sdcc_external_startup()
16522 \begin_inset LatexCommand \index{\_sdcc\_external\_startup()}
16523
16524 \end_inset
16525
16526
16527 \series bold
16528 \emph default
16529  
16530 \series default
16531 at the start of the CODE area.
16532  This routine is also in the runtime library
16533 \begin_inset LatexCommand \index{Runtime library}
16534
16535 \end_inset
16536
16537  and returns 0 by default.
16538  If this routine returns a non-zero value, the static & global variable
16539  initialization will be skipped and the function main will be invoked.
16540  Otherwise static & global variables will be initialized before the function
16541  main is invoked.
16542  You could add an 
16543 \emph on
16544 _sdcc_external_startup()
16545 \emph default
16546  routine to your program to override the default if you need to setup hardware
16547  or perform some other critical operation prior to static & global variable
16548  initialization
16549 \begin_inset LatexCommand \index{Variable initialization}
16550
16551 \end_inset
16552
16553 .
16554  On some mcs51 variants xdata
16555 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
16556
16557 \end_inset
16558
16559  memory has to be explicitly enabled before it can be accessed or if the
16560  watchdog
16561 \begin_inset LatexCommand \index{watchdog}
16562
16563 \end_inset
16564
16565  needs to be disabled, this is the place to do it.
16566  The startup code clears all internal data memory, 256 bytes by default,
16567  but from 0 to n-1 if 
16568 \emph on
16569 -
16570 \begin_inset ERT
16571 status collapsed
16572
16573 \begin_layout Standard
16574
16575
16576 \backslash
16577 /
16578 \end_layout
16579
16580 \end_inset
16581
16582 -iram-size
16583 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
16584
16585 \end_inset
16586
16587 n
16588 \emph default
16589  is used.
16590  (recommended for Chipcon CC1010).
16591 \end_layout
16592
16593 \begin_layout Standard
16594 See also the compiler options 
16595 \emph on
16596 -
16597 \begin_inset ERT
16598 status collapsed
16599
16600 \begin_layout Standard
16601
16602
16603 \backslash
16604 /
16605 \end_layout
16606
16607 \end_inset
16608
16609 -no-xinit
16610 \emph default
16611 -
16612 \emph on
16613 opt
16614 \emph default
16615
16616 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
16617
16618 \end_inset
16619
16620
16621 \emph on
16622 -
16623 \begin_inset ERT
16624 status collapsed
16625
16626 \begin_layout Standard
16627
16628
16629 \backslash
16630 /
16631 \end_layout
16632
16633 \end_inset
16634
16635 -main-return
16636 \emph default
16637
16638 \begin_inset LatexCommand \index{-\/-main-return}
16639
16640 \end_inset
16641
16642  and section 
16643 \begin_inset LatexCommand \ref{sub:MCS51-variants}
16644
16645 \end_inset
16646
16647  about MCS51-variants.
16648 \newline
16649
16650 \end_layout
16651
16652 \begin_layout Standard
16653 While these initialization modules are meant as generic startup code there
16654  might be the need for customization.
16655  Let's assume the return value of 
16656 \emph on
16657 _sdcc_external_startup()
16658 \emph default
16659  in 
16660 \emph on
16661 crtstart.asm
16662 \emph default
16663  should not be checked (or 
16664 \emph on
16665 _sdcc_external_startup()
16666 \emph default
16667  should not be called at all).
16668  The recommended way would be to copy 
16669 \emph on
16670 crtstart.asm
16671 \emph default
16672  (f.e.
16673  from 
16674 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/device/lib/mcs51/crtstart.asm}
16675
16676 \end_inset
16677
16678 ) into the source directory, adapt it there, then assemble it with 
16679 \emph on
16680 asx8051 -plosgff
16681 \begin_inset Foot
16682 status open
16683
16684 \begin_layout Standard
16685 \begin_inset Quotes sld
16686 \end_inset
16687
16688 -plosgff
16689 \begin_inset Quotes srd
16690 \end_inset
16691
16692  are the assembler options used in 
16693 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/lib/mcs51/Makefile.in?view=markup }
16694
16695 \end_inset
16696
16697
16698 \end_layout
16699
16700 \end_inset
16701
16702  crtstart.asm
16703 \emph default
16704  and when linking your project explicitely specify 
16705 \emph on
16706 crtstart.rel
16707 \emph default
16708 .
16709  As a bonus a listing of the relocated object file 
16710 \emph on
16711 crtstart.rst
16712 \emph default
16713  is generated.
16714 \end_layout
16715
16716 \begin_layout Standard
16717 \begin_inset VSpace bigskip
16718 \end_inset
16719
16720
16721 \end_layout
16722
16723 \begin_layout Subsection
16724 HC08 Startup Code
16725 \end_layout
16726
16727 \begin_layout Standard
16728 The HC08
16729 \begin_inset LatexCommand \index{HC08}
16730
16731 \end_inset
16732
16733  startup code follows the same scheme as the MCS51 startup code.
16734 \begin_inset VSpace bigskip
16735 \end_inset
16736
16737
16738 \end_layout
16739
16740 \begin_layout Subsection
16741 Z80 Startup Code
16742 \end_layout
16743
16744 \begin_layout Standard
16745 On the Z80
16746 \begin_inset LatexCommand \index{Z80}
16747
16748 \end_inset
16749
16750  the startup code is inserted by linking with crt0.o which is generated from
16751  sdcc/device/lib/z80/crt0.s.
16752  If you need a different startup code you can use the compiler option 
16753 \emph on
16754 -
16755 \series bold
16756 \emph default
16757
16758 \begin_inset ERT
16759 status collapsed
16760
16761 \begin_layout Standard
16762
16763
16764 \backslash
16765 /
16766 \end_layout
16767
16768 \end_inset
16769
16770
16771 \series default
16772 \emph on
16773 -no-std-crt0
16774 \emph default
16775
16776 \begin_inset LatexCommand \index{-\/-no-std-crt0}
16777
16778 \end_inset
16779
16780  and provide your own crt0.o.
16781  
16782 \begin_inset VSpace bigskip
16783 \end_inset
16784
16785
16786 \end_layout
16787
16788 \begin_layout Section
16789 Inline Assembler Code
16790 \begin_inset LatexCommand \index{Assembler routines}
16791
16792 \end_inset
16793
16794
16795 \end_layout
16796
16797 \begin_layout Subsection
16798 A Step by Step Introduction
16799 \begin_inset LatexCommand \label{sub:A-Step-by Assembler Introduction}
16800
16801 \end_inset
16802
16803
16804 \end_layout
16805
16806 \begin_layout Standard
16807 Starting from a small snippet of c-code this example shows for the MCS51
16808  how to use inline assembly, access variables, a function parameter and
16809  an array in xdata memory.
16810  The example uses an MCS51 here but is easily adapted for other architectures.
16811  This is a buffer routine which should be optimized:
16812 \end_layout
16813
16814 \begin_layout Verse
16815
16816 \family typewriter
16817 \size footnotesize
16818 unsigned char __far
16819 \begin_inset LatexCommand \index{far (storage class)}
16820
16821 \end_inset
16822
16823
16824 \begin_inset LatexCommand \index{\_\_far (storage class)}
16825
16826 \end_inset
16827
16828  __at
16829 \begin_inset LatexCommand \index{at}
16830
16831 \end_inset
16832
16833
16834 \begin_inset LatexCommand \index{\_\_at}
16835
16836 \end_inset
16837
16838 (0x7f00) buf[0x100];
16839 \begin_inset LatexCommand \index{Aligned array}
16840
16841 \end_inset
16842
16843
16844 \newline
16845 unsigned char head, tail;\InsetSpace ~
16846 \InsetSpace ~
16847 \InsetSpace ~
16848 \InsetSpace ~
16849 \InsetSpace ~
16850 \InsetSpace ~
16851 \InsetSpace ~
16852 \InsetSpace ~
16853 \InsetSpace ~
16854 \InsetSpace ~
16855 \InsetSpace ~
16856 \InsetSpace ~
16857 \InsetSpace ~
16858 \InsetSpace ~
16859 \InsetSpace ~
16860 \InsetSpace ~
16861 \InsetSpace ~
16862 /* if interrupts
16863 \begin_inset LatexCommand \index{interrupt}
16864
16865 \end_inset
16866
16867  are involved see
16868 \newline
16869 \InsetSpace ~
16870 \InsetSpace ~
16871 \InsetSpace ~
16872 \InsetSpace ~
16873 \InsetSpace ~
16874 \InsetSpace ~
16875 \InsetSpace ~
16876 \InsetSpace ~
16877 \InsetSpace ~
16878 \InsetSpace ~
16879 \InsetSpace ~
16880 \InsetSpace ~
16881 \InsetSpace ~
16882 \InsetSpace ~
16883 \InsetSpace ~
16884 \InsetSpace ~
16885 \InsetSpace ~
16886 \InsetSpace ~
16887 \InsetSpace ~
16888 \InsetSpace ~
16889 \InsetSpace ~
16890 \InsetSpace ~
16891 \InsetSpace ~
16892 \InsetSpace ~
16893 \InsetSpace ~
16894 \InsetSpace ~
16895 \InsetSpace ~
16896 \InsetSpace ~
16897 \InsetSpace ~
16898 \InsetSpace ~
16899 \InsetSpace ~
16900 \InsetSpace ~
16901 \InsetSpace ~
16902 \InsetSpace ~
16903 \InsetSpace ~
16904 \InsetSpace ~
16905 \InsetSpace ~
16906 \InsetSpace ~
16907 \InsetSpace ~
16908 \InsetSpace ~
16909 \InsetSpace ~
16910 \InsetSpace ~
16911 \InsetSpace ~
16912 \InsetSpace ~
16913 \InsetSpace ~
16914 section 
16915 \begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
16916
16917 \end_inset
16918
16919  about
16920 \series bold
16921  volatile
16922 \series default
16923  */
16924 \newline
16925
16926 \newline
16927 void to_buffer( unsigned char c ) 
16928 \newline
16929 {
16930 \newline
16931 \InsetSpace ~
16932 \InsetSpace ~
16933 \InsetSpace ~
16934 \InsetSpace ~
16935 if( head != (unsigned char)(tail-1)
16936  )\InsetSpace ~
16937 /* cast 
16938 \series bold
16939 needed
16940 \series default
16941  to avoid promotion
16942 \begin_inset LatexCommand \index{promotion to signed int}
16943
16944 \end_inset
16945
16946
16947 \begin_inset LatexCommand \index{type promotion}
16948
16949 \end_inset
16950
16951  to integer */
16952 \begin_inset Marginal
16953 status collapsed
16954
16955 \begin_layout Standard
16956
16957 \series bold
16958 \InsetSpace ~
16959 !
16960 \end_layout
16961
16962 \end_inset
16963
16964
16965 \newline
16966 \InsetSpace ~
16967 \InsetSpace ~
16968 \InsetSpace ~
16969 \InsetSpace ~
16970 \InsetSpace ~
16971 \InsetSpace ~
16972 \InsetSpace ~
16973 \InsetSpace ~
16974 buf[ head++ ] = c;\InsetSpace ~
16975 \InsetSpace ~
16976 \InsetSpace ~
16977 \InsetSpace ~
16978 \InsetSpace ~
16979 \InsetSpace ~
16980 \InsetSpace ~
16981 \InsetSpace ~
16982 \InsetSpace ~
16983 \InsetSpace ~
16984 \InsetSpace ~
16985 \InsetSpace ~
16986 \InsetSpace ~
16987 \InsetSpace ~
16988 \InsetSpace ~
16989 \InsetSpace ~
16990 /* access to a 256 byte aligned array */
16991 \newline
16992
16993 \end_layout
16994
16995 \begin_layout Standard
16996 If the code snippet (assume it is saved in buffer.c) is compiled with SDCC
16997  then a corresponding buffer.asm file is generated.
16998  We define a new function 
16999 \family typewriter
17000 to_buffer_asm()
17001 \family default
17002  in file buffer.c in which we cut and paste the generated code, removing
17003  unwanted comments and some ':'.
17004  Then add 
17005 \begin_inset Quotes sld
17006 \end_inset
17007
17008
17009 \series bold
17010 _asm
17011 \series default
17012
17013 \begin_inset Quotes srd
17014 \end_inset
17015
17016  and 
17017 \begin_inset Quotes sld
17018 \end_inset
17019
17020
17021 \series bold
17022 _endasm;
17023 \series default
17024
17025 \begin_inset Quotes srd
17026 \end_inset
17027
17028
17029 \begin_inset Foot
17030 status open
17031
17032 \begin_layout Standard
17033 Note, that the single underscore form (_asm and _endasm) are not C99-compatible,
17034  and for C-99 compatibility, the double-underscore form (__asm and __endasm)
17035  has to be used.
17036  The latter is also used in the library functions.
17037 \end_layout
17038
17039 \end_inset
17040
17041  to the beginning and the end of the function body:
17042 \end_layout
17043
17044 \begin_layout Verse
17045
17046 \family typewriter
17047 \size footnotesize
17048 /* With a cut and paste from the .asm file, we have something to start with.
17049 \newline
17050 \InsetSpace ~
17051 \InsetSpace ~
17052 \InsetSpace ~
17053 The
17054  function is not yet OK! (registers aren't saved) */ 
17055 \newline
17056 void to_buffer_asm(
17057  unsigned char c ) 
17058 \newline
17059
17060 \newline
17061 \InsetSpace ~
17062 \InsetSpace ~
17063 \InsetSpace ~
17064 \InsetSpace ~
17065 _asm
17066 \begin_inset LatexCommand \index{\_asm}
17067
17068 \end_inset
17069
17070
17071 \begin_inset LatexCommand \index{\_\_asm}
17072
17073 \end_inset
17074
17075
17076 \newline
17077 \InsetSpace ~
17078 \InsetSpace ~
17079 \InsetSpace ~
17080 \InsetSpace ~
17081 mov\InsetSpace ~
17082 \InsetSpace ~
17083 r2,dpl 
17084 \newline
17085 ;buffer.c if( head != (unsigned char)(tail-1) ) \InsetSpace ~
17086 /* cast 
17087 \series bold
17088 needed
17089 \series default
17090  to avoid promotion
17091 \begin_inset LatexCommand \index{promotion to signed int}
17092
17093 \end_inset
17094
17095
17096 \begin_inset LatexCommand \index{type promotion}
17097
17098 \end_inset
17099
17100  to integer */
17101 \newline
17102 \InsetSpace ~
17103 \InsetSpace ~
17104 \InsetSpace ~
17105 \InsetSpace ~
17106 mov\InsetSpace ~
17107 \InsetSpace ~
17108 a,_tail 
17109 \newline
17110 \InsetSpace ~
17111 \InsetSpace ~
17112 \InsetSpace ~
17113 \InsetSpace ~
17114 dec\InsetSpace ~
17115 \InsetSpace ~
17116
17117 \newline
17118 \InsetSpace ~
17119 \InsetSpace ~
17120 \InsetSpace ~
17121 \InsetSpace ~
17122 mov\InsetSpace ~
17123 \InsetSpace ~
17124 r3,a 
17125 \newline
17126 \InsetSpace ~
17127 \InsetSpace ~
17128 \InsetSpace ~
17129 \InsetSpace ~
17130 mov\InsetSpace ~
17131 \InsetSpace ~
17132 a,_head 
17133 \newline
17134 \InsetSpace ~
17135 \InsetSpace ~
17136 \InsetSpace ~
17137 \InsetSpace ~
17138 cjne a,ar3,00106$ 
17139 \newline
17140 \InsetSpace ~
17141 \InsetSpace ~
17142 \InsetSpace ~
17143 \InsetSpace ~
17144 ret
17145 \newline
17146 00106$:
17147  
17148 \newline
17149 ;buffer.c buf[ head++ ] = c; /* access to a 256 byte aligned array */
17150 \begin_inset LatexCommand \index{Aligned array}
17151
17152 \end_inset
17153
17154
17155 \newline
17156 \InsetSpace ~
17157 \InsetSpace ~
17158 \InsetSpace ~
17159 \InsetSpace ~
17160 mov\InsetSpace ~
17161 \InsetSpace ~
17162 r3,_head 
17163 \newline
17164 \InsetSpace ~
17165 \InsetSpace ~
17166 \InsetSpace ~
17167 \InsetSpace ~
17168 inc\InsetSpace ~
17169 \InsetSpace ~
17170 _head 
17171 \newline
17172 \InsetSpace ~
17173 \InsetSpace ~
17174 \InsetSpace ~
17175 \InsetSpace ~
17176 mov\InsetSpace ~
17177 \InsetSpace ~
17178 dpl,r3 
17179 \newline
17180 \InsetSpace ~
17181 \InsetSpace ~
17182 \InsetSpace ~
17183 \InsetSpace ~
17184 mov\InsetSpace ~
17185 \InsetSpace ~
17186 dph,#(_buf >> 8) 
17187 \newline
17188 \InsetSpace ~
17189 \InsetSpace ~
17190 \InsetSpace ~
17191 \InsetSpace ~
17192 mov\InsetSpace ~
17193 \InsetSpace ~
17194 a,r2 
17195 \newline
17196 \InsetSpace ~
17197 \InsetSpace ~
17198 \InsetSpace ~
17199 \InsetSpace ~
17200 movx @dptr,a
17201  
17202 \newline
17203 00103$: 
17204 \newline
17205 \InsetSpace ~
17206 \InsetSpace ~
17207 \InsetSpace ~
17208 \InsetSpace ~
17209 ret
17210 \newline
17211 \InsetSpace ~
17212 \InsetSpace ~
17213 \InsetSpace ~
17214 \InsetSpace ~
17215 _endasm
17216 \begin_inset LatexCommand \index{\_endasm}
17217
17218 \end_inset
17219
17220
17221 \begin_inset LatexCommand \index{\_\_endasm}
17222
17223 \end_inset
17224
17225 ;
17226 \newline
17227
17228 \end_layout
17229
17230 \begin_layout Standard
17231 The new file buffer.c should compile with only one warning about the unreferenced
17232  function argument 'c'.
17233  Now we hand-optimize the assembly code and insert an #define USE_ASSEMBLY
17234  (1) and finally have:
17235 \end_layout
17236
17237 \begin_layout Verse
17238
17239 \family typewriter
17240 \size footnotesize
17241 unsigned char __far __at(0x7f00) buf[0x100];
17242 \newline
17243 unsigned char head, tail;
17244 \newline
17245 #define
17246  USE_ASSEMBLY (1)
17247 \newline
17248
17249 \newline
17250 #if !USE_ASSEMBLY
17251 \newline
17252
17253 \newline
17254 void to_buffer( unsigned char c )
17255 \newline
17256 {
17257 \newline
17258 \InsetSpace ~
17259 \InsetSpace ~
17260 \InsetSpace ~
17261 \InsetSpace ~
17262 if(
17263  head != (unsigned char)(tail-1) )
17264 \newline
17265 \InsetSpace ~
17266 \InsetSpace ~
17267 \InsetSpace ~
17268 \InsetSpace ~
17269 \InsetSpace ~
17270 \InsetSpace ~
17271 \InsetSpace ~
17272 \InsetSpace ~
17273 buf[ head++ ] = c;
17274 \newline
17275 }
17276 \newline
17277
17278 \newline
17279 #else
17280 \newline
17281
17282 \newline
17283 void to_buffer(
17284  unsigned char c )
17285 \newline
17286 {
17287 \newline
17288 \InsetSpace ~
17289 \InsetSpace ~
17290 \InsetSpace ~
17291 \InsetSpace ~
17292 c; // to avoid warning: unreferenced function argument
17293 \newline
17294 \InsetSpace ~
17295 \InsetSpace ~
17296 \InsetSpace ~
17297 \InsetSpace ~
17298 _asm
17299 \begin_inset LatexCommand \index{\_asm}
17300
17301 \end_inset
17302
17303
17304 \begin_inset LatexCommand \index{\_\_asm}
17305
17306 \end_inset
17307
17308
17309 \newline
17310 \InsetSpace ~
17311 \InsetSpace ~
17312 \InsetSpace ~
17313 \InsetSpace ~
17314 \InsetSpace ~
17315 \InsetSpace ~
17316 \InsetSpace ~
17317 \InsetSpace ~
17318 ; save used registers here.
17319  
17320 \newline
17321 \InsetSpace ~
17322 \InsetSpace ~
17323 \InsetSpace ~
17324 \InsetSpace ~
17325 \InsetSpace ~
17326 \InsetSpace ~
17327 \InsetSpace ~
17328 \InsetSpace ~
17329 ; If we were still using r2,r3 we would have to push them here.
17330  
17331 \newline
17332 ; if( head != (unsigned char)(tail-1) )
17333 \newline
17334 \InsetSpace ~
17335 \InsetSpace ~
17336 \InsetSpace ~
17337 \InsetSpace ~
17338 \InsetSpace ~
17339 \InsetSpace ~
17340 \InsetSpace ~
17341 \InsetSpace ~
17342 mov\InsetSpace ~
17343  a,_tail
17344 \newline
17345 \InsetSpace ~
17346 \InsetSpace ~
17347 \InsetSpace ~
17348 \InsetSpace ~
17349 \InsetSpace ~
17350 \InsetSpace ~
17351 \InsetSpace ~
17352 \InsetSpace ~
17353 dec\InsetSpace ~
17354  a
17355 \newline
17356 \InsetSpace ~
17357 \InsetSpace ~
17358 \InsetSpace ~
17359 \InsetSpace ~
17360 \InsetSpace ~
17361 \InsetSpace ~
17362 \InsetSpace ~
17363 \InsetSpace ~
17364 xrl\InsetSpace ~
17365  a,_head
17366 \newline
17367 \InsetSpace ~
17368 \InsetSpace ~
17369 \InsetSpace ~
17370 \InsetSpace ~
17371 \InsetSpace ~
17372 \InsetSpace ~
17373 \InsetSpace ~
17374 \InsetSpace ~
17375 ; we
17376  could do an ANL a,#0x0f here to use a smaller buffer (see below)
17377 \newline
17378 \InsetSpace ~
17379 \InsetSpace ~
17380 \InsetSpace ~
17381 \InsetSpace ~
17382 \InsetSpace ~
17383 \InsetSpace ~
17384 \InsetSpace ~
17385 \InsetSpace ~
17386 jz\InsetSpace ~
17387 \InsetSpace ~
17388  t_b_end$
17389 \newline
17390 \InsetSpace ~
17391 \InsetSpace ~
17392 \InsetSpace ~
17393 \InsetSpace ~
17394 \InsetSpace ~
17395 \InsetSpace ~
17396 \InsetSpace ~
17397 \InsetSpace ~
17398 ;
17399 \newline
17400 ;
17401  buf[ head++ ] = c;
17402 \newline
17403 \InsetSpace ~
17404 \InsetSpace ~
17405 \InsetSpace ~
17406 \InsetSpace ~
17407 \InsetSpace ~
17408 \InsetSpace ~
17409 \InsetSpace ~
17410 \InsetSpace ~
17411 mov\InsetSpace ~
17412  a,dpl \InsetSpace ~
17413 \InsetSpace ~
17414 \InsetSpace ~
17415 \InsetSpace ~
17416 \InsetSpace ~
17417 \InsetSpace ~
17418 \InsetSpace ~
17419 ; dpl holds lower byte of function argument
17420 \newline
17421 \InsetSpace ~
17422 \InsetSpace ~
17423 \InsetSpace ~
17424 \InsetSpace ~
17425 \InsetSpace ~
17426 \InsetSpace ~
17427 \InsetSpace ~
17428 \InsetSpace ~
17429 mov\InsetSpace ~
17430
17431  dpl,_head \InsetSpace ~
17432 \InsetSpace ~
17433 \InsetSpace ~
17434 ; buf is 0x100 byte aligned so head can be used directly
17435 \newline
17436 \InsetSpace ~
17437 \InsetSpace ~
17438 \InsetSpace ~
17439 \InsetSpace ~
17440 \InsetSpace ~
17441 \InsetSpace ~
17442 \InsetSpace ~
17443 \InsetSpace ~
17444 mov\InsetSpace ~
17445  dph,#(_bu
17446 f>>8)
17447 \newline
17448 \InsetSpace ~
17449 \InsetSpace ~
17450 \InsetSpace ~
17451 \InsetSpace ~
17452 \InsetSpace ~
17453 \InsetSpace ~
17454 \InsetSpace ~
17455 \InsetSpace ~
17456 movx @dptr,a
17457 \newline
17458 \InsetSpace ~
17459 \InsetSpace ~
17460 \InsetSpace ~
17461 \InsetSpace ~
17462 \InsetSpace ~
17463 \InsetSpace ~
17464 \InsetSpace ~
17465 \InsetSpace ~
17466 inc \InsetSpace ~
17467 _head
17468 \newline
17469 \InsetSpace ~
17470 \InsetSpace ~
17471 \InsetSpace ~
17472 \InsetSpace ~
17473 \InsetSpace ~
17474 \InsetSpace ~
17475 \InsetSpace ~
17476 \InsetSpace ~
17477 ; we could do an ANL _head,#0x0f here to use a
17478  smaller buffer (see above)
17479 \newline
17480 t_b_end$:
17481 \newline
17482 \InsetSpace ~
17483 \InsetSpace ~
17484 \InsetSpace ~
17485 \InsetSpace ~
17486 \InsetSpace ~
17487 \InsetSpace ~
17488 \InsetSpace ~
17489 \InsetSpace ~
17490 ; restore used registers here 
17491 \newline
17492 \InsetSpace ~
17493 \InsetSpace ~
17494 \InsetSpace ~
17495 \InsetSpace ~
17496 _endasm
17497 \begin_inset LatexCommand \index{\_endasm}
17498
17499 \end_inset
17500
17501
17502 \begin_inset LatexCommand \index{\_\_endasm}
17503
17504 \end_inset
17505
17506 ;
17507 \newline
17508 }
17509 \newline
17510 #endif
17511 \end_layout
17512
17513 \begin_layout Standard
17514 The inline assembler code can contain any valid code understood by the assembler
17515 , this includes any assembler directives and comment lines.
17516  The assembler does not like some characters like ':' or ''' in comments.
17517  You'll find an 100+ pages assembler manual in sdcc/as/doc/asxhtm.html
17518 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
17519
17520 \end_inset
17521
17522
17523 \begin_inset LatexCommand \index{Assembler documentation}
17524
17525 \end_inset
17526
17527  or online at 
17528 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
17529
17530 \end_inset
17531
17532 \InsetSpace ~
17533 .
17534 \end_layout
17535
17536 \begin_layout Standard
17537 The compiler does not do any validation of the code within the 
17538 \family typewriter
17539 _asm
17540 \begin_inset LatexCommand \index{\_asm}
17541
17542 \end_inset
17543
17544
17545 \begin_inset LatexCommand \index{\_\_asm}
17546
17547 \end_inset
17548
17549  ...
17550  _endasm
17551 \size footnotesize
17552
17553 \begin_inset LatexCommand \index{\_endasm}
17554
17555 \end_inset
17556
17557
17558 \begin_inset LatexCommand \index{\_\_endasm}
17559
17560 \end_inset
17561
17562
17563 \size default
17564 ;
17565 \family default
17566  keyword pair.
17567  Specifically it will not know which registers are used and thus register
17568  pushing/popping
17569 \begin_inset LatexCommand \index{push/pop}
17570
17571 \end_inset
17572
17573  has to be done manually.
17574  
17575 \end_layout
17576
17577 \begin_layout Standard
17578 It is recommended that each assembly instruction (including labels) be placed
17579  in a separate line (as the example shows).
17580  When the -
17581 \begin_inset ERT
17582 status collapsed
17583
17584 \begin_layout Standard
17585
17586
17587 \backslash
17588 /
17589 \end_layout
17590
17591 \end_inset
17592
17593 -
17594 \emph on
17595 peep-asm
17596 \begin_inset LatexCommand \index{-\/-peep-asm}
17597
17598 \end_inset
17599
17600
17601 \emph default
17602  command line option is used, the inline assembler code will be passed through
17603  the peephole optimizer
17604 \begin_inset LatexCommand \index{Peephole optimizer}
17605
17606 \end_inset
17607
17608 .
17609  There are only a few (if any) cases where this option makes sense, it might
17610  cause some unexpected changes in the inline assembler code.
17611  Please go through the peephole optimizer rules defined in file 
17612 \emph on
17613 SDCCpeeph.def
17614 \emph default
17615  before using this option.
17616 \end_layout
17617
17618 \begin_layout Subsection
17619 Naked Functions
17620 \begin_inset LatexCommand \label{sub:Naked-Functions}
17621
17622 \end_inset
17623
17624
17625 \begin_inset LatexCommand \index{Naked functions}
17626
17627 \end_inset
17628
17629
17630 \end_layout
17631
17632 \begin_layout Standard
17633 A special keyword may be associated with a function declaring it as 
17634 \emph on
17635 _naked
17636 \begin_inset LatexCommand \index{\_naked}
17637
17638 \end_inset
17639
17640
17641 \begin_inset LatexCommand \index{\_\_naked}
17642
17643 \end_inset
17644
17645 .
17646  
17647 \emph default
17648 The 
17649 \emph on
17650 _naked
17651 \emph default
17652  function modifier attribute prevents the compiler from generating prologue
17653 \begin_inset LatexCommand \index{function prologue}
17654
17655 \end_inset
17656
17657  and epilogue
17658 \begin_inset LatexCommand \index{function epilogue}
17659
17660 \end_inset
17661
17662  code for that function.
17663  This means that the user is entirely responsible for such things as saving
17664  any registers that may need to be preserved, selecting the proper register
17665  bank, generating the 
17666 \emph on
17667 return
17668 \emph default
17669  instruction at the end, etc.
17670  Practically, this means that the contents of the function must be written
17671  in inline assembler.
17672  This is particularly useful for interrupt functions, which can have a large
17673  (and often unnecessary) prologue/epilogue.
17674  For example, compare the code generated by these two functions:
17675 \end_layout
17676
17677 \begin_layout Verse
17678
17679 \family typewriter
17680 volatile
17681 \begin_inset LatexCommand \index{volatile}
17682
17683 \end_inset
17684
17685  data unsigned char counter;
17686 \newline
17687
17688 \newline
17689 void simpleInterrupt(void) __interrupt
17690 \begin_inset LatexCommand \index{interrupt}
17691
17692 \end_inset
17693
17694
17695 \begin_inset LatexCommand \index{\_\_interrupt}
17696
17697 \end_inset
17698
17699  (1)
17700 \newline
17701 {
17702 \newline
17703 \InsetSpace ~
17704 \InsetSpace ~
17705 \InsetSpace ~
17706 \InsetSpace ~
17707 counter++;
17708 \newline
17709 }
17710 \newline
17711
17712 \newline
17713 void nakedInterrupt(void) __interrupt (2) __naked
17714 \newline
17715 {
17716 \newline
17717 \InsetSpace ~
17718 \InsetSpace ~
17719 \InsetSpace ~
17720 \InsetSpace ~
17721 _asm
17722 \begin_inset LatexCommand \index{\_asm}
17723
17724 \end_inset
17725
17726
17727 \begin_inset LatexCommand \index{\_\_asm}
17728
17729 \end_inset
17730
17731
17732 \newline
17733 \InsetSpace ~
17734 \InsetSpace ~
17735 \InsetSpace ~
17736 \InsetSpace ~
17737 \InsetSpace ~
17738 \InsetSpace ~
17739 inc\InsetSpace ~
17740 \InsetSpace ~
17741 \InsetSpace ~
17742 \InsetSpace ~
17743 \InsetSpace ~
17744 _counter ; does not change flags, no need to save psw
17745 \newline
17746 \InsetSpace ~
17747 \InsetSpace ~
17748 \InsetSpace ~
17749 \InsetSpace ~
17750 \InsetSpace ~
17751 \InsetSpace ~
17752 reti\InsetSpace ~
17753 \InsetSpace ~
17754 \InsetSpace ~
17755 \InsetSpace ~
17756 ; MUST explicitly
17757  include ret or reti in _naked function.
17758 \newline
17759 \InsetSpace ~
17760 \InsetSpace ~
17761 \InsetSpace ~
17762 \InsetSpace ~
17763 _endasm
17764 \begin_inset LatexCommand \index{\_endasm}
17765
17766 \end_inset
17767
17768
17769 \begin_inset LatexCommand \index{\_\_endasm}
17770
17771 \end_inset
17772
17773 ;
17774 \newline
17775 }
17776 \end_layout
17777
17778 \begin_layout Standard
17779 For an 8051 target, the generated simpleInterrupt looks like:
17780 \end_layout
17781
17782 \begin_layout Verse
17783
17784 \family typewriter
17785 Note, this is an 
17786 \emph on
17787 outdated
17788 \emph default
17789  example, recent versions of SDCC generate
17790 \newline
17791 the 
17792 \emph on
17793 same
17794 \emph default
17795  code for simpleInterrupt() and nakedInterrupt()!
17796 \newline
17797
17798 \newline
17799 _simpleInterrupt:
17800 \newline
17801 \InsetSpace ~
17802 \InsetSpace ~
17803 \InsetSpace ~
17804 \InsetSpace ~
17805 push\InsetSpace ~
17806 \InsetSpace ~
17807 \InsetSpace ~
17808 \InsetSpace ~
17809 acc
17810 \newline
17811 \InsetSpace ~
17812 \InsetSpace ~
17813 \InsetSpace ~
17814 \InsetSpace ~
17815 push\InsetSpace ~
17816 \InsetSpace ~
17817 \InsetSpace ~
17818 \InsetSpace ~
17819 b
17820 \newline
17821 \InsetSpace ~
17822 \InsetSpace ~
17823 \InsetSpace ~
17824 \InsetSpace ~
17825 pu
17826 sh\InsetSpace ~
17827 \InsetSpace ~
17828 \InsetSpace ~
17829 \InsetSpace ~
17830 dpl
17831 \newline
17832 \InsetSpace ~
17833 \InsetSpace ~
17834 \InsetSpace ~
17835 \InsetSpace ~
17836 push\InsetSpace ~
17837 \InsetSpace ~
17838 \InsetSpace ~
17839 \InsetSpace ~
17840 dph
17841 \newline
17842 \InsetSpace ~
17843 \InsetSpace ~
17844 \InsetSpace ~
17845 \InsetSpace ~
17846 push\InsetSpace ~
17847 \InsetSpace ~
17848 \InsetSpace ~
17849 \InsetSpace ~
17850 psw
17851 \newline
17852 \InsetSpace ~
17853 \InsetSpace ~
17854 \InsetSpace ~
17855 \InsetSpace ~
17856 mov\InsetSpace ~
17857 \InsetSpace ~
17858 \InsetSpace ~
17859 \InsetSpace ~
17860 \InsetSpace ~
17861 psw,#0x00
17862 \newline
17863 \InsetSpace ~
17864 \InsetSpace ~
17865 \InsetSpace ~
17866 \InsetSpace ~
17867 inc\InsetSpace ~
17868 \InsetSpace ~
17869 \InsetSpace ~
17870 \InsetSpace ~
17871 \InsetSpace ~
17872 _counter
17873 \newline
17874 \InsetSpace ~
17875 \InsetSpace ~
17876 \InsetSpace ~
17877 \InsetSpace ~
17878 pop\InsetSpace ~
17879 \InsetSpace ~
17880 \InsetSpace ~
17881 \InsetSpace ~
17882 \InsetSpace ~
17883 psw
17884 \newline
17885 \InsetSpace ~
17886 \InsetSpace ~
17887 \InsetSpace ~
17888 \InsetSpace ~
17889 pop\InsetSpace ~
17890 \InsetSpace ~
17891 \InsetSpace ~
17892 \InsetSpace ~
17893 \InsetSpace ~
17894 dph
17895 \newline
17896 \InsetSpace ~
17897 \InsetSpace ~
17898 \InsetSpace ~
17899 \InsetSpace ~
17900 pop\InsetSpace ~
17901 \InsetSpace ~
17902 \InsetSpace ~
17903 \InsetSpace ~
17904 \InsetSpace ~
17905 dpl
17906 \newline
17907 \InsetSpace ~
17908 \InsetSpace ~
17909 \InsetSpace ~
17910 \InsetSpace ~
17911 pop\InsetSpace ~
17912 \InsetSpace ~
17913 \InsetSpace ~
17914 \InsetSpace ~
17915 \InsetSpace ~
17916 b
17917 \newline
17918 \InsetSpace ~
17919 \InsetSpace ~
17920 \InsetSpace ~
17921 \InsetSpace ~
17922 pop\InsetSpace ~
17923 \InsetSpace ~
17924 \InsetSpace ~
17925 \InsetSpace ~
17926 \InsetSpace ~
17927 acc
17928 \newline
17929 \InsetSpace ~
17930 \InsetSpace ~
17931 \InsetSpace ~
17932 \InsetSpace ~
17933 reti
17934 \end_layout
17935
17936 \begin_layout Standard
17937 whereas nakedInterrupt looks like:
17938 \end_layout
17939
17940 \begin_layout Verse
17941
17942 \family typewriter
17943 _nakedInterrupt:
17944 \newline
17945 \InsetSpace ~
17946 \InsetSpace ~
17947 \InsetSpace ~
17948 \InsetSpace ~
17949 inc\InsetSpace ~
17950 \InsetSpace ~
17951 \InsetSpace ~
17952 \InsetSpace ~
17953 _counter ; does not change flags, no need to save psw
17954 \newline
17955 \InsetSpace ~
17956 \InsetSpace ~
17957 \InsetSpace ~
17958 \InsetSpace ~
17959 reti\InsetSpace ~
17960 \InsetSpace ~
17961 \InsetSpace ~
17962 \InsetSpace ~
17963 \InsetSpace ~
17964 \InsetSpace ~
17965 \InsetSpace ~
17966 \InsetSpace ~
17967 \InsetSpace ~
17968 \InsetSpace ~
17969 \InsetSpace ~
17970 \InsetSpace ~
17971 ;
17972  MUST explicitly include ret or reti in _naked function
17973 \end_layout
17974
17975 \begin_layout Standard
17976 The related directive #pragma exclude
17977 \begin_inset LatexCommand \index{\#pragma exclude}
17978
17979 \end_inset
17980
17981  allows a more fine grained control over pushing & popping
17982 \begin_inset LatexCommand \index{push/pop}
17983
17984 \end_inset
17985
17986  the registers.
17987 \end_layout
17988
17989 \begin_layout Standard
17990 While there is nothing preventing you from writing C code inside a 
17991 \family typewriter
17992 _naked
17993 \family default
17994  function, there are many ways to shoot yourself in the foot doing this,
17995  and it is recommended that you stick to inline assembler.
17996 \end_layout
17997
17998 \begin_layout Subsection
17999 Use of Labels within Inline Assembler
18000 \end_layout
18001
18002 \begin_layout Standard
18003 SDCC allows the use of in-line assembler with a few restrictions regarding
18004  labels.
18005  All labels defined within inline assembler code have to be of the form
18006  
18007 \emph on
18008 nnnnn$
18009 \emph default
18010  where nnnnn is a number less than 100 (which implies a limit of utmost
18011  100 inline assembler labels 
18012 \emph on
18013 per function
18014 \emph default
18015 \noun on
18016 )
18017 \noun default
18018 .
18019 \begin_inset Foot
18020 status open
18021
18022 \begin_layout Standard
18023 This is a slightly more stringent rule than absolutely necessary, but stays
18024  always on the safe side.
18025  Labels in the form of nnnnn$ are local labels in the assembler, locality
18026  of which is confined within two labels of the standard form.
18027  The compiler uses the same form for labels within a function (but starting
18028  from nnnnn=00100); and places always a standard label at the beginning
18029  of a function, thus limiting the locality of labels within the scope of
18030  the function.
18031  So, if the inline assembler part would be embedded into C-code, an improperly
18032  placed non-local label in the assembler would break up the reference space
18033  for labels created by the compiler for the C-code, leading to an assembling
18034  error.
18035 \end_layout
18036
18037 \begin_layout Standard
18038 The numeric part of local labels does not need to have 5 digits (although
18039  this is the form of labels output by the compiler), any valid integer will
18040  do.
18041  Please refer to the assemblers documentation for further details.
18042 \end_layout
18043
18044 \end_inset
18045
18046  
18047 \end_layout
18048
18049 \begin_layout Verse
18050
18051 \family typewriter
18052 _asm
18053 \begin_inset LatexCommand \index{\_asm}
18054
18055 \end_inset
18056
18057
18058 \begin_inset LatexCommand \index{\_\_asm}
18059
18060 \end_inset
18061
18062  
18063 \newline
18064 \InsetSpace ~
18065 \InsetSpace ~
18066 \InsetSpace ~
18067 \InsetSpace ~
18068 mov\InsetSpace ~
18069 \InsetSpace ~
18070 \InsetSpace ~
18071 \InsetSpace ~
18072 \InsetSpace ~
18073 b,#10 
18074 \newline
18075 00001$: 
18076 \newline
18077 \InsetSpace ~
18078 \InsetSpace ~
18079 \InsetSpace ~
18080 \InsetSpace ~
18081 djnz\InsetSpace ~
18082 \InsetSpace ~
18083 \InsetSpace ~
18084 \InsetSpace ~
18085 b,00001$ 
18086 \newline
18087 _endasm
18088 \begin_inset LatexCommand \index{\_endasm}
18089
18090 \end_inset
18091
18092
18093 \begin_inset LatexCommand \index{\_\_endasm}
18094
18095 \end_inset
18096
18097  ;
18098 \end_layout
18099
18100 \begin_layout Standard
18101 Inline assembler code cannot reference any C-labels, however it can reference
18102  labels
18103 \begin_inset LatexCommand \index{Labels}
18104
18105 \end_inset
18106
18107  defined by the inline assembler, e.g.:
18108 \end_layout
18109
18110 \begin_layout Verse
18111
18112 \family typewriter
18113 foo() { 
18114 \newline
18115 \InsetSpace ~
18116 \InsetSpace ~
18117 \InsetSpace ~
18118 \InsetSpace ~
18119 /* some c code */ 
18120 \newline
18121 \InsetSpace ~
18122 \InsetSpace ~
18123 \InsetSpace ~
18124 \InsetSpace ~
18125 _asm 
18126 \newline
18127 \InsetSpace ~
18128 \InsetSpace ~
18129 \InsetSpace ~
18130 \InsetSpace ~
18131 \InsetSpace ~
18132 \InsetSpace ~
18133 ; some assembler code 
18134 \newline
18135 \InsetSpace ~
18136 \InsetSpace ~
18137 \InsetSpace ~
18138 \InsetSpace ~
18139 \InsetSpace ~
18140 \InsetSpace ~
18141 ljmp 0003$ 
18142 \newline
18143 \InsetSpace ~
18144 \InsetSpace ~
18145 \InsetSpace ~
18146 \InsetSpace ~
18147 _endasm;
18148  
18149 \newline
18150 \InsetSpace ~
18151 \InsetSpace ~
18152 \InsetSpace ~
18153 \InsetSpace ~
18154 /* some more c code */ 
18155 \newline
18156 clabel:\InsetSpace ~
18157 \InsetSpace ~
18158 /* inline assembler cannot reference this
18159  label */ 
18160 \begin_inset Foot
18161 status open
18162
18163 \begin_layout Standard
18164 Here, the C-label 
18165 \family typewriter
18166 clabel
18167 \family default
18168  is translated by the compiler into a local label, so the locality of labels
18169  within the function is not broken.
18170 \end_layout
18171
18172 \end_inset
18173
18174
18175 \newline
18176 \InsetSpace ~
18177 \InsetSpace ~
18178 \InsetSpace ~
18179 \InsetSpace ~
18180 _asm
18181 \newline
18182 \InsetSpace ~
18183 \InsetSpace ~
18184 \InsetSpace ~
18185 \InsetSpace ~
18186 0003$: ;label (can be referenced by inline assembler only) 
18187 \newline
18188 \InsetSpace ~
18189 \InsetSpace ~
18190 \InsetSpace ~
18191 \InsetSpace ~
18192 _endasm
18193 \begin_inset LatexCommand \index{\_endasm}
18194
18195 \end_inset
18196
18197
18198 \begin_inset LatexCommand \index{\_\_endasm}
18199
18200 \end_inset
18201
18202  ; 
18203 \newline
18204 \InsetSpace ~
18205 \InsetSpace ~
18206 \InsetSpace ~
18207 \InsetSpace ~
18208 /* some more c code */
18209 \newline
18210 }
18211 \end_layout
18212
18213 \begin_layout Standard
18214 In other words inline assembly code can access labels defined in inline
18215  assembly within the scope of the function.
18216  The same goes the other way, i.e.
18217  labels defines in inline assembly can not be accessed by C statements.
18218 \end_layout
18219
18220 \begin_layout Section
18221 Interfacing with Assembler Code
18222 \begin_inset LatexCommand \index{Assembler routines}
18223
18224 \end_inset
18225
18226
18227 \end_layout
18228
18229 \begin_layout Subsection
18230 Global Registers used for Parameter Passing
18231 \begin_inset LatexCommand \index{Parameter passing}
18232
18233 \end_inset
18234
18235
18236 \end_layout
18237
18238 \begin_layout Standard
18239 The compiler always uses the global registers 
18240 \emph on
18241 DPL, DPH
18242 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
18243
18244 \end_inset
18245
18246
18247 \begin_inset LatexCommand \index{DPTR}
18248
18249 \end_inset
18250
18251 , B
18252 \begin_inset LatexCommand \index{B (mcs51, ds390 register)}
18253
18254 \end_inset
18255
18256  
18257 \emph default
18258 and
18259 \emph on
18260  ACC
18261 \begin_inset LatexCommand \index{ACC (mcs51, ds390 register)}
18262
18263 \end_inset
18264
18265
18266 \emph default
18267  to pass the first (non-bit) parameter to a function, and also to pass the
18268  return value 
18269 \begin_inset LatexCommand \index{return value}
18270
18271 \end_inset
18272
18273 of function; according to the following scheme: one byte return value in
18274  
18275 \emph on
18276 DPL
18277 \emph default
18278 , two byte value in 
18279 \emph on
18280 DPL
18281 \emph default
18282  (LSB) and 
18283 \emph on
18284 DPH
18285 \emph default
18286  (MSB).
18287  three byte values (generic pointers) in 
18288 \emph on
18289 DPH
18290 \emph default
18291
18292 \emph on
18293 DPL
18294 \emph default
18295  and 
18296 \emph on
18297 B
18298 \emph default
18299 , and four byte values in 
18300 \emph on
18301 DPH
18302 \emph default
18303
18304 \emph on
18305 DPL
18306 \emph default
18307 ,
18308 \emph on
18309  B
18310 \emph default
18311  and 
18312 \emph on
18313 ACC
18314 \emph default
18315 .
18316  Generic pointers
18317 \begin_inset LatexCommand \index{generic pointer}
18318
18319 \end_inset
18320
18321  contain type of accessed memory in 
18322 \emph on
18323 B
18324 \emph default
18325
18326 \series bold
18327 0x00
18328 \series default
18329  -- xdata/far, 
18330 \series bold
18331 0x40
18332 \series default
18333  -- idata/near -- , 
18334 \series bold
18335 0x60
18336 \series default
18337  -- pdata, 
18338 \series bold
18339 0x80
18340 \series default
18341  -- code
18342 \begin_inset Note Note
18343 status collapsed
18344
18345 \begin_layout Standard
18346 This might not be the case of certain memory models (medium???)
18347 \end_layout
18348
18349 \end_inset
18350
18351 .
18352 \end_layout
18353
18354 \begin_layout Standard
18355 The second parameter onwards is either allocated on the stack (for reentrant
18356  routines or if -
18357 \begin_inset ERT
18358 status collapsed
18359
18360 \begin_layout Standard
18361
18362
18363 \backslash
18364 /
18365 \end_layout
18366
18367 \end_inset
18368
18369 -stack-auto is used) or in data/xdata memory (depending on the memory model).
18370 \end_layout
18371
18372 \begin_layout Standard
18373 Bit parameters are passed in a virtual register called 'bits' in bit-addressable
18374  space for reentrant functions or allocated directly in bit memory otherwise.
18375 \end_layout
18376
18377 \begin_layout Standard
18378 Functions (with two or more parameters or bit parameters) that are called
18379  through function pointers
18380 \begin_inset LatexCommand \index{function pointers}
18381
18382 \end_inset
18383
18384  must therefor be reentrant so the compiler knows how to pass the parameters.
18385 \end_layout
18386
18387 \begin_layout Subsection
18388 Registers usage
18389 \end_layout
18390
18391 \begin_layout Standard
18392 Unless the called function is declared as 
18393 \family typewriter
18394 _naked
18395 \family default
18396
18397 \begin_inset LatexCommand \index{naked}
18398
18399 \end_inset
18400
18401 , or the -
18402 \begin_inset ERT
18403 status collapsed
18404
18405 \begin_layout Standard
18406
18407
18408 \backslash
18409 /
18410 \end_layout
18411
18412 \end_inset
18413
18414 -callee-saves
18415 \begin_inset LatexCommand \index{-\/-callee-saves}
18416
18417 \end_inset
18418
18419 /-
18420 \begin_inset ERT
18421 status collapsed
18422
18423 \begin_layout Standard
18424
18425
18426 \backslash
18427 /
18428 \end_layout
18429
18430 \end_inset
18431
18432 -all-callee-saves command line option or the corresponding callee_saves
18433  pragma are used, the caller will save the registers (
18434 \emph on
18435 R0-R7
18436 \emph default
18437 ) around the call, so the called function can destroy they content freely.
18438 \end_layout
18439
18440 \begin_layout Standard
18441 If the called function is not declared as 
18442 \family typewriter
18443 _naked
18444 \family default
18445 , the caller will swap register banks around the call, if caller and callee
18446  use different register banks (having them defined by the 
18447 \family typewriter
18448 _using
18449 \family default
18450  modifier).
18451  
18452 \end_layout
18453
18454 \begin_layout Standard
18455 The called function can also use 
18456 \emph on
18457 DPL
18458 \emph default
18459
18460 \emph on
18461 DPH
18462 \emph default
18463
18464 \emph on
18465 B
18466 \emph default
18467  and 
18468 \emph on
18469 ACC
18470 \emph default
18471  observing that they are used for parameter/return value passing.
18472 \end_layout
18473
18474 \begin_layout Subsection
18475 Assembler Routine (non-reentrant)
18476 \end_layout
18477
18478 \begin_layout Standard
18479 In the following example
18480 \begin_inset LatexCommand \index{reentrant}
18481
18482 \end_inset
18483
18484
18485 \begin_inset LatexCommand \index{Assembler routines (non-reentrant)}
18486
18487 \end_inset
18488
18489  the function c_func calls an assembler routine asm_func, which takes two
18490  parameters
18491 \begin_inset LatexCommand \index{function parameter}
18492
18493 \end_inset
18494
18495 .
18496 \end_layout
18497
18498 \begin_layout Verse
18499
18500 \family typewriter
18501 extern int asm_func(unsigned char, unsigned char);
18502 \newline
18503
18504 \newline
18505 int c_func (unsigned char
18506  i, unsigned char j)
18507 \newline
18508 {
18509 \newline
18510 \InsetSpace ~
18511 \InsetSpace ~
18512 \InsetSpace ~
18513 \InsetSpace ~
18514 return asm_func(i,j);
18515 \newline
18516 }
18517 \newline
18518
18519 \newline
18520 int main()
18521 \newline
18522 {
18523 \newline
18524 \InsetSpace ~
18525 \InsetSpace ~
18526 \InsetSpace ~
18527 \InsetSpace ~
18528 return c_func(10,9);
18529 \newline
18530 }
18531 \end_layout
18532
18533 \begin_layout Standard
18534 The corresponding assembler function is:
18535 \end_layout
18536
18537 \begin_layout Verse
18538
18539 \family typewriter
18540 .globl _asm_func_PARM_2 
18541 \newline
18542 \InsetSpace ~
18543 \InsetSpace ~
18544 \InsetSpace ~
18545 \InsetSpace ~
18546 \InsetSpace ~
18547 \InsetSpace ~
18548 \InsetSpace ~
18549 \InsetSpace ~
18550 .globl _asm_func 
18551 \newline
18552 \InsetSpace ~
18553 \InsetSpace ~
18554 \InsetSpace ~
18555 \InsetSpace ~
18556 \InsetSpace ~
18557 \InsetSpace ~
18558 \InsetSpace ~
18559 \InsetSpace ~
18560 .area OSEG 
18561 \newline
18562 _asm_func_PARM_2:
18563 \newline
18564 \InsetSpace ~
18565 \InsetSpace ~
18566 \InsetSpace ~
18567 \InsetSpace ~
18568 \InsetSpace ~
18569 \InsetSpace ~
18570 \InsetSpace ~
18571 \InsetSpace ~
18572 .ds   
18573  1 
18574 \newline
18575 \InsetSpace ~
18576 \InsetSpace ~
18577 \InsetSpace ~
18578 \InsetSpace ~
18579 \InsetSpace ~
18580 \InsetSpace ~
18581 \InsetSpace ~
18582 \InsetSpace ~
18583 .area CSEG 
18584 \newline
18585 _asm_func: 
18586 \newline
18587 \InsetSpace ~
18588 \InsetSpace ~
18589 \InsetSpace ~
18590 \InsetSpace ~
18591 \InsetSpace ~
18592 \InsetSpace ~
18593 \InsetSpace ~
18594 \InsetSpace ~
18595 mov\InsetSpace ~
18596 \InsetSpace ~
18597 \InsetSpace ~
18598 \InsetSpace ~
18599 a,dpl 
18600 \newline
18601 \InsetSpace ~
18602 \InsetSpace ~
18603 \InsetSpace ~
18604 \InsetSpace ~
18605 \InsetSpace ~
18606 \InsetSpace ~
18607 \InsetSpace ~
18608 \InsetSpace ~
18609 add\InsetSpace ~
18610 \InsetSpace ~
18611 \InsetSpace ~
18612 \InsetSpace ~
18613 a,_asm_func_PARM_2 
18614 \newline
18615 \InsetSpace ~
18616 \InsetSpace ~
18617 \InsetSpace ~
18618 \InsetSpace ~
18619 \InsetSpace ~
18620 \InsetSpace ~
18621 \InsetSpace ~
18622 \InsetSpace ~
18623 mov\InsetSpace ~
18624 \InsetSpace ~
18625 \InsetSpace ~
18626 \InsetSpace ~
18627 dpl,a 
18628 \newline
18629 \InsetSpace ~
18630 \InsetSpace ~
18631 \InsetSpace ~
18632 \InsetSpace ~
18633 \InsetSpace ~
18634 \InsetSpace ~
18635 \InsetSpace ~
18636 \InsetSpace ~
18637 mov\InsetSpace ~
18638 \InsetSpace ~
18639 \InsetSpace ~
18640 \InsetSpace ~
18641 dph
18642 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
18643
18644 \end_inset
18645
18646 ,#0x00 
18647 \newline
18648 \InsetSpace ~
18649 \InsetSpace ~
18650 \InsetSpace ~
18651 \InsetSpace ~
18652 \InsetSpace ~
18653 \InsetSpace ~
18654 \InsetSpace ~
18655 \InsetSpace ~
18656 ret
18657 \end_layout
18658
18659 \begin_layout Standard
18660 The parameter naming convention is _<function_name>_PARM_<n>, where n is
18661  the parameter number starting from 1, and counting from the left.
18662  The first parameter is passed in 
18663 \emph on
18664 DPH
18665 \emph default
18666
18667 \emph on
18668 DPL
18669 \emph default
18670
18671 \emph on
18672 B
18673 \emph default
18674  and 
18675 \emph on
18676 ACC
18677 \emph default
18678  according to the description above.
18679  The variable name for the second parameter will be _<function_name>_PARM_2.
18680 \newline
18681
18682 \newline
18683 Assem
18684 ble the assembler routine with the following command:
18685 \newline
18686
18687 \newline
18688
18689 \family sans
18690 \series bold
18691 asx8051 -losg asmfunc.asm
18692 \newline
18693
18694 \newline
18695
18696 \family default
18697 \series default
18698 Then compile and link the assembler routine to the C source file with the
18699  following command:
18700 \newline
18701
18702 \newline
18703
18704 \family sans
18705 \series bold
18706 sdcc cfunc.c asmfunc.rel
18707 \end_layout
18708
18709 \begin_layout Subsection
18710 Assembler Routine (reentrant)
18711 \end_layout
18712
18713 \begin_layout Standard
18714 In this case
18715 \begin_inset LatexCommand \index{reentrant}
18716
18717 \end_inset
18718
18719
18720 \begin_inset LatexCommand \index{Assembler routines (reentrant)}
18721
18722 \end_inset
18723
18724  the second parameter
18725 \begin_inset LatexCommand \index{function parameter}
18726
18727 \end_inset
18728
18729  onwards will be passed on the stack, the parameters are pushed from right
18730  to left i.e.
18731  before the call the second leftmost parameter will be on the top of the
18732  stack (the leftmost parameter is passed in registers).
18733  Here is an example:
18734 \end_layout
18735
18736 \begin_layout Verse
18737
18738 \family typewriter
18739 extern int asm_func(unsigned char, unsigned char, unsigned char) reentrant;
18740 \newline
18741
18742 \newline
18743 int
18744  c_func (unsigned char i, unsigned char j, unsigned char k) reentrant 
18745 \newline
18746 {
18747  
18748 \newline
18749 \InsetSpace ~
18750 \InsetSpace ~
18751 \InsetSpace ~
18752 \InsetSpace ~
18753 return asm_func(i,j,k); 
18754 \newline
18755
18756 \newline
18757
18758 \newline
18759 int main() 
18760 \newline
18761
18762 \newline
18763 \InsetSpace ~
18764 \InsetSpace ~
18765 \InsetSpace ~
18766 \InsetSpace ~
18767 return c_func(10,9,8); 
18768 \newline
18769 }
18770 \end_layout
18771
18772 \begin_layout Standard
18773 The corresponding (unoptimized) assembler routine is:
18774 \end_layout
18775
18776 \begin_layout Verse
18777
18778 \family typewriter
18779 .globl _asm_func 
18780 \newline
18781 _asm_func: 
18782 \newline
18783 \InsetSpace ~
18784 \InsetSpace ~
18785 \InsetSpace ~
18786 \InsetSpace ~
18787 push\InsetSpace ~
18788 _bp 
18789 \newline
18790 \InsetSpace ~
18791 \InsetSpace ~
18792 \InsetSpace ~
18793 \InsetSpace ~
18794 mov\InsetSpace ~
18795 \InsetSpace ~
18796 _bp,sp\InsetSpace ~
18797 \InsetSpace ~
18798 \InsetSpace ~
18799 \InsetSpace ~
18800 \InsetSpace ~
18801 \InsetSpace ~
18802 ;stack contains: _bp, return
18803  address, second parameter, third parameter
18804 \newline
18805 \InsetSpace ~
18806 \InsetSpace ~
18807 \InsetSpace ~
18808 \InsetSpace ~
18809 mov\InsetSpace ~
18810 \InsetSpace ~
18811 r2,dpl
18812 \newline
18813 \InsetSpace ~
18814 \InsetSpace ~
18815 \InsetSpace ~
18816 \InsetSpace ~
18817 mov\InsetSpace ~
18818 \InsetSpace ~
18819 a,_bp
18820 \newline
18821 \InsetSpace ~
18822 \InsetSpace ~
18823 \InsetSpace ~
18824 \InsetSpace ~
18825 add\InsetSpace ~
18826 \InsetSpace ~
18827 a,#0xfd\InsetSpace ~
18828 \InsetSpace ~
18829 \InsetSpace ~
18830 \InsetSpace ~
18831 \InsetSpace ~
18832 ;calculate
18833  pointer to the second parameter
18834 \newline
18835 \InsetSpace ~
18836 \InsetSpace ~
18837 \InsetSpace ~
18838 \InsetSpace ~
18839 mov\InsetSpace ~
18840 \InsetSpace ~
18841 r0,a 
18842 \newline
18843 \InsetSpace ~
18844 \InsetSpace ~
18845 \InsetSpace ~
18846 \InsetSpace ~
18847 mov\InsetSpace ~
18848 \InsetSpace ~
18849 a,_bp 
18850 \newline
18851 \InsetSpace ~
18852 \InsetSpace ~
18853 \InsetSpace ~
18854 \InsetSpace ~
18855 add\InsetSpace ~
18856 \InsetSpace ~
18857 a,#0xfc\InsetSpace ~
18858 \InsetSpace ~
18859 \InsetSpace ~
18860 \InsetSpace ~
18861 \InsetSpace ~
18862 ;calculate pointer
18863  to the rightmost parameter
18864 \newline
18865 \InsetSpace ~
18866 \InsetSpace ~
18867 \InsetSpace ~
18868 \InsetSpace ~
18869 mov\InsetSpace ~
18870 \InsetSpace ~
18871 r1,a 
18872 \newline
18873 \InsetSpace ~
18874 \InsetSpace ~
18875 \InsetSpace ~
18876 \InsetSpace ~
18877 mov\InsetSpace ~
18878 \InsetSpace ~
18879 a,@r0
18880 \newline
18881 \InsetSpace ~
18882 \InsetSpace ~
18883 \InsetSpace ~
18884 \InsetSpace ~
18885 add\InsetSpace ~
18886 \InsetSpace ~
18887 a,@r1
18888 \newline
18889 \InsetSpace ~
18890 \InsetSpace ~
18891 \InsetSpace ~
18892 \InsetSpace ~
18893 add\InsetSpace ~
18894 \InsetSpace ~
18895 a,r2\InsetSpace ~
18896 \InsetSpace ~
18897 \InsetSpace ~
18898 \InsetSpace ~
18899 \InsetSpace ~
18900 \InsetSpace ~
18901 \InsetSpace ~
18902 \InsetSpace ~
18903 ;calculate the
18904  result (= sum of all three parameters)
18905 \newline
18906 \InsetSpace ~
18907 \InsetSpace ~
18908 \InsetSpace ~
18909 \InsetSpace ~
18910 mov\InsetSpace ~
18911 \InsetSpace ~
18912 dpl,a\InsetSpace ~
18913 \InsetSpace ~
18914 \InsetSpace ~
18915 \InsetSpace ~
18916 \InsetSpace ~
18917 \InsetSpace ~
18918 \InsetSpace ~
18919 ;return value goes into dptr
18920  (cast into int)
18921 \newline
18922 \InsetSpace ~
18923 \InsetSpace ~
18924 \InsetSpace ~
18925 \InsetSpace ~
18926 mov\InsetSpace ~
18927 \InsetSpace ~
18928 dph,#0x00 
18929 \newline
18930 \InsetSpace ~
18931 \InsetSpace ~
18932 \InsetSpace ~
18933 \InsetSpace ~
18934 mov\InsetSpace ~
18935 \InsetSpace ~
18936 sp,_bp 
18937 \newline
18938 \InsetSpace ~
18939 \InsetSpace ~
18940 \InsetSpace ~
18941 \InsetSpace ~
18942 pop\InsetSpace ~
18943 \InsetSpace ~
18944 _bp 
18945 \newline
18946 \InsetSpace ~
18947 \InsetSpace ~
18948 \InsetSpace ~
18949 \InsetSpace ~
18950 ret
18951 \end_layout
18952
18953 \begin_layout Standard
18954 The compiling and linking procedure remains the same, however note the extra
18955  entry & exit linkage required for the assembler code, _bp is the stack
18956  frame pointer and is used to compute the offset into the stack for parameters
18957  and local variables.
18958 \begin_inset VSpace bigskip
18959 \end_inset
18960
18961
18962 \end_layout
18963
18964 \begin_layout Section
18965 int (16 bit)
18966 \begin_inset LatexCommand \index{int (16 bit)}
18967
18968 \end_inset
18969
18970  and long (32 bit)
18971 \begin_inset LatexCommand \index{long (32 bit)}
18972
18973 \end_inset
18974
18975  Support
18976 \end_layout
18977
18978 \begin_layout Standard
18979 For signed & unsigned int (16 bit) and long (32 bit) variables, division,
18980  multiplication and modulus operations are implemented by support routines.
18981  These support routines are all developed in ANSI-C to facilitate porting
18982  to other MCUs, although some model specific assembler optimizations are
18983  used.
18984  The following files contain the described routines, all of them can be
18985  found in <installdir>/share/sdcc/lib.
18986 \newline
18987
18988 \end_layout
18989
18990 \begin_layout Standard
18991 \align center
18992 \begin_inset Tabular
18993 <lyxtabular version="3" rows="11" columns="2">
18994 <features>
18995 <column alignment="left" valignment="top" leftline="true" width="0">
18996 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
18997 <row topline="true" bottomline="true">
18998 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18999 \begin_inset Text
19000
19001 \begin_layout Standard
19002
19003 \series bold
19004 Function
19005 \end_layout
19006
19007 \end_inset
19008 </cell>
19009 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19010 \begin_inset Text
19011
19012 \begin_layout Standard
19013
19014 \series bold
19015 Description
19016 \end_layout
19017
19018 \end_inset
19019 </cell>
19020 </row>
19021 <row topline="true">
19022 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19023 \begin_inset Text
19024
19025 \begin_layout Standard
19026 _mulint.c 
19027 \end_layout
19028
19029 \end_inset
19030 </cell>
19031 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19032 \begin_inset Text
19033
19034 \begin_layout Standard
19035 16 bit multiplication
19036 \end_layout
19037
19038 \end_inset
19039 </cell>
19040 </row>
19041 <row topline="true">
19042 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19043 \begin_inset Text
19044
19045 \begin_layout Standard
19046 _divsint.c 
19047 \end_layout
19048
19049 \end_inset
19050 </cell>
19051 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19052 \begin_inset Text
19053
19054 \begin_layout Standard
19055  signed 16 bit division (calls _divuint)
19056 \end_layout
19057
19058 \end_inset
19059 </cell>
19060 </row>
19061 <row topline="true">
19062 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19063 \begin_inset Text
19064
19065 \begin_layout Standard
19066 _divuint.c 
19067 \end_layout
19068
19069 \end_inset
19070 </cell>
19071 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19072 \begin_inset Text
19073
19074 \begin_layout Standard
19075  unsigned 16 bit division
19076 \end_layout
19077
19078 \end_inset
19079 </cell>
19080 </row>
19081 <row topline="true">
19082 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19083 \begin_inset Text
19084
19085 \begin_layout Standard
19086 _modsint.c
19087 \end_layout
19088
19089 \end_inset
19090 </cell>
19091 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19092 \begin_inset Text
19093
19094 \begin_layout Standard
19095 signed 16 bit modulus (calls _moduint)
19096 \end_layout
19097
19098 \end_inset
19099 </cell>
19100 </row>
19101 <row topline="true">
19102 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19103 \begin_inset Text
19104
19105 \begin_layout Standard
19106 _moduint.c
19107 \end_layout
19108
19109 \end_inset
19110 </cell>
19111 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19112 \begin_inset Text
19113
19114 \begin_layout Standard
19115 unsigned 16 bit modulus
19116 \end_layout
19117
19118 \end_inset
19119 </cell>
19120 </row>
19121 <row topline="true">
19122 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19123 \begin_inset Text
19124
19125 \begin_layout Standard
19126 _mullong.c
19127 \end_layout
19128
19129 \end_inset
19130 </cell>
19131 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19132 \begin_inset Text
19133
19134 \begin_layout Standard
19135 32 bit multiplication
19136 \end_layout
19137
19138 \end_inset
19139 </cell>
19140 </row>
19141 <row topline="true">
19142 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19143 \begin_inset Text
19144
19145 \begin_layout Standard
19146 _divslong.c 
19147 \end_layout
19148
19149 \end_inset
19150 </cell>
19151 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19152 \begin_inset Text
19153
19154 \begin_layout Standard
19155  signed 32 division (calls _divulong)
19156 \end_layout
19157
19158 \end_inset
19159 </cell>
19160 </row>
19161 <row topline="true">
19162 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19163 \begin_inset Text
19164
19165 \begin_layout Standard
19166 _divulong.c 
19167 \end_layout
19168
19169 \end_inset
19170 </cell>
19171 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19172 \begin_inset Text
19173
19174 \begin_layout Standard
19175 unsigned 32 division
19176 \end_layout
19177
19178 \end_inset
19179 </cell>
19180 </row>
19181 <row topline="true">
19182 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19183 \begin_inset Text
19184
19185 \begin_layout Standard
19186 _modslong.c
19187 \end_layout
19188
19189 \end_inset
19190 </cell>
19191 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19192 \begin_inset Text
19193
19194 \begin_layout Standard
19195  signed 32 bit modulus (calls _modulong)
19196 \end_layout
19197
19198 \end_inset
19199 </cell>
19200 </row>
19201 <row topline="true" bottomline="true">
19202 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19203 \begin_inset Text
19204
19205 \begin_layout Standard
19206 _modulong.c
19207 \end_layout
19208
19209 \end_inset
19210 </cell>
19211 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19212 \begin_inset Text
19213
19214 \begin_layout Standard
19215 unsigned 32 bit modulus
19216 \end_layout
19217
19218 \end_inset
19219 </cell>
19220 </row>
19221 </lyxtabular>
19222
19223 \end_inset
19224
19225
19226 \newline
19227
19228 \end_layout
19229
19230 \begin_layout Standard
19231 Since they are compiled as 
19232 \emph on
19233 non-reentrant
19234 \emph default
19235
19236 \begin_inset LatexCommand \index{reentrant}
19237
19238 \end_inset
19239
19240 , interrupt
19241 \begin_inset LatexCommand \index{interrupt}
19242
19243 \end_inset
19244
19245  service routines should not do any of the above operations.
19246  If this is unavoidable then the above routines will need to be compiled
19247  with the 
19248 \emph on
19249 -
19250 \begin_inset ERT
19251 status collapsed
19252
19253 \begin_layout Standard
19254
19255
19256 \backslash
19257 /
19258 \end_layout
19259
19260 \end_inset
19261
19262 -stack-auto
19263 \begin_inset LatexCommand \index{-\/-stack-auto}
19264
19265 \end_inset
19266
19267
19268 \emph default
19269  option, after which the source program will have to be compiled with 
19270 \emph on
19271 -
19272 \begin_inset ERT
19273 status collapsed
19274
19275 \begin_layout Standard
19276
19277
19278 \backslash
19279 /
19280 \end_layout
19281
19282 \end_inset
19283
19284 -int-long-reent
19285 \begin_inset LatexCommand \index{-\/-int-long-reent}
19286
19287 \end_inset
19288
19289
19290 \emph default
19291  option.
19292  Notice that you don't have to call these routines directly.
19293  The compiler will use them automatically every time an integer operation
19294  is required.
19295 \end_layout
19296
19297 \begin_layout Section
19298 Floating Point Support
19299 \begin_inset LatexCommand \index{Floating point support}
19300
19301 \end_inset
19302
19303
19304 \end_layout
19305
19306 \begin_layout Standard
19307 SDCC supports IEEE (single precision 4 bytes) floating point numbers.
19308  The floating point support routines are derived from gcc's floatlib.c and
19309  consist of the following routines:
19310 \newline
19311
19312 \end_layout
19313
19314 \begin_layout Standard
19315 \align center
19316
19317 \size footnotesize
19318 \begin_inset Tabular
19319 <lyxtabular version="3" rows="17" columns="2">
19320 <features>
19321 <column alignment="left" valignment="top" leftline="true" width="0">
19322 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
19323 <row topline="true" bottomline="true">
19324 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19325 \begin_inset Text
19326
19327 \begin_layout Standard
19328
19329 \family roman
19330 \series medium
19331 \shape up
19332 \size normal
19333 \emph off
19334 \bar no
19335 \noun off
19336 \color none
19337 Function 
19338 \end_layout
19339
19340 \end_inset
19341 </cell>
19342 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19343 \begin_inset Text
19344
19345 \begin_layout Standard
19346 Description
19347 \end_layout
19348
19349 \end_inset
19350 </cell>
19351 </row>
19352 <row topline="true">
19353 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19354 \begin_inset Text
19355
19356 \begin_layout Standard
19357
19358 \family roman
19359 \series medium
19360 \shape up
19361 \size normal
19362 \emph off
19363 \bar no
19364 \noun off
19365 \color none
19366 _fsadd.c
19367 \end_layout
19368
19369 \end_inset
19370 </cell>
19371 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19372 \begin_inset Text
19373
19374 \begin_layout Standard
19375
19376 \family roman
19377 \series medium
19378 \shape up
19379 \size normal
19380 \emph off
19381 \bar no
19382 \noun off
19383 \color none
19384 add floating point numbers
19385 \end_layout
19386
19387 \end_inset
19388 </cell>
19389 </row>
19390 <row topline="true">
19391 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19392 \begin_inset Text
19393
19394 \begin_layout Standard
19395
19396 \family roman
19397 \series medium
19398 \shape up
19399 \size normal
19400 \emph off
19401 \bar no
19402 \noun off
19403 \color none
19404 _fssub.c 
19405 \end_layout
19406
19407 \end_inset
19408 </cell>
19409 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19410 \begin_inset Text
19411
19412 \begin_layout Standard
19413
19414 \family roman
19415 \series medium
19416 \shape up
19417 \size normal
19418 \emph off
19419 \bar no
19420 \noun off
19421 \color none
19422 subtract floating point numbers 
19423 \end_layout
19424
19425 \end_inset
19426 </cell>
19427 </row>
19428 <row topline="true">
19429 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19430 \begin_inset Text
19431
19432 \begin_layout Standard
19433
19434 \family roman
19435 \series medium
19436 \shape up
19437 \size normal
19438 \emph off
19439 \bar no
19440 \noun off
19441 \color none
19442 _fsdiv.c 
19443 \end_layout
19444
19445 \end_inset
19446 </cell>
19447 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19448 \begin_inset Text
19449
19450 \begin_layout Standard
19451
19452 \family roman
19453 \series medium
19454 \shape up
19455 \size normal
19456 \emph off
19457 \bar no
19458 \noun off
19459 \color none
19460 divide floating point numbers 
19461 \end_layout
19462
19463 \end_inset
19464 </cell>
19465 </row>
19466 <row topline="true">
19467 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19468 \begin_inset Text
19469
19470 \begin_layout Standard
19471
19472 \family roman
19473 \series medium
19474 \shape up
19475 \size normal
19476 \emph off
19477 \bar no
19478 \noun off
19479 \color none
19480 _fsmul.c 
19481 \end_layout
19482
19483 \end_inset
19484 </cell>
19485 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19486 \begin_inset Text
19487
19488 \begin_layout Standard
19489
19490 \family roman
19491 \series medium
19492 \shape up
19493 \size normal
19494 \emph off
19495 \bar no
19496 \noun off
19497 \color none
19498 multiply floating point numbers 
19499 \end_layout
19500
19501 \end_inset
19502 </cell>
19503 </row>
19504 <row topline="true">
19505 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19506 \begin_inset Text
19507
19508 \begin_layout Standard
19509
19510 \family roman
19511 \series medium
19512 \shape up
19513 \size normal
19514 \emph off
19515 \bar no
19516 \noun off
19517 \color none
19518 _fs2uchar.c
19519 \end_layout
19520
19521 \end_inset
19522 </cell>
19523 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19524 \begin_inset Text
19525
19526 \begin_layout Standard
19527
19528 \family roman
19529 \series medium
19530 \shape up
19531 \size normal
19532 \emph off
19533 \bar no
19534 \noun off
19535 \color none
19536 convert floating point to unsigned char
19537 \end_layout
19538
19539 \end_inset
19540 </cell>
19541 </row>
19542 <row topline="true">
19543 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19544 \begin_inset Text
19545
19546 \begin_layout Standard
19547
19548 \family roman
19549 \series medium
19550 \shape up
19551 \size normal
19552 \emph off
19553 \bar no
19554 \noun off
19555 \color none
19556 _fs2char.c
19557 \end_layout
19558
19559 \end_inset
19560 </cell>
19561 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19562 \begin_inset Text
19563
19564 \begin_layout Standard
19565
19566 \family roman
19567 \series medium
19568 \shape up
19569 \size normal
19570 \emph off
19571 \bar no
19572 \noun off
19573 \color none
19574 convert floating point to signed char
19575 \end_layout
19576
19577 \end_inset
19578 </cell>
19579 </row>
19580 <row topline="true">
19581 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19582 \begin_inset Text
19583
19584 \begin_layout Standard
19585
19586 \family roman
19587 \series medium
19588 \shape up
19589 \size normal
19590 \emph off
19591 \bar no
19592 \noun off
19593 \color none
19594 _fs2uint.c
19595 \end_layout
19596
19597 \end_inset
19598 </cell>
19599 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19600 \begin_inset Text
19601
19602 \begin_layout Standard
19603
19604 \family roman
19605 \series medium
19606 \shape up
19607 \size normal
19608 \emph off
19609 \bar no
19610 \noun off
19611 \color none
19612 convert floating point to unsigned int
19613 \end_layout
19614
19615 \end_inset
19616 </cell>
19617 </row>
19618 <row topline="true">
19619 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19620 \begin_inset Text
19621
19622 \begin_layout Standard
19623
19624 \family roman
19625 \series medium
19626 \shape up
19627 \size normal
19628 \emph off
19629 \bar no
19630 \noun off
19631 \color none
19632 _fs2int.c
19633 \end_layout
19634
19635 \end_inset
19636 </cell>
19637 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19638 \begin_inset Text
19639
19640 \begin_layout Standard
19641
19642 \family roman
19643 \series medium
19644 \shape up
19645 \size normal
19646 \emph off
19647 \bar no
19648 \noun off
19649 \color none
19650 convert floating point to signed int
19651 \end_layout
19652
19653 \end_inset
19654 </cell>
19655 </row>
19656 <row topline="true">
19657 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19658 \begin_inset Text
19659
19660 \begin_layout Standard
19661
19662 \family roman
19663 \series medium
19664 \shape up
19665 \size normal
19666 \emph off
19667 \bar no
19668 \noun off
19669 \color none
19670 _fs2ulong.
19671 \family default
19672 \series default
19673 \shape default
19674 \size default
19675 \emph default
19676 \bar default
19677 \noun default
19678 c
19679 \end_layout
19680
19681 \end_inset
19682 </cell>
19683 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19684 \begin_inset Text
19685
19686 \begin_layout Standard
19687
19688 \family roman
19689 \series medium
19690 \shape up
19691 \size normal
19692 \emph off
19693 \bar no
19694 \noun off
19695 \color none
19696 convert floating point to unsigned long
19697 \end_layout
19698
19699 \end_inset
19700 </cell>
19701 </row>
19702 <row topline="true">
19703 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19704 \begin_inset Text
19705
19706 \begin_layout Standard
19707
19708 \family roman
19709 \series medium
19710 \shape up
19711 \size normal
19712 \emph off
19713 \bar no
19714 \noun off
19715 \color none
19716 _fs2long.c
19717 \end_layout
19718
19719 \end_inset
19720 </cell>
19721 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19722 \begin_inset Text
19723
19724 \begin_layout Standard
19725
19726 \family roman
19727 \series medium
19728 \shape up
19729 \size normal
19730 \emph off
19731 \bar no
19732 \noun off
19733 \color none
19734 convert floating point to signed long
19735 \end_layout
19736
19737 \end_inset
19738 </cell>
19739 </row>
19740 <row topline="true">
19741 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19742 \begin_inset Text
19743
19744 \begin_layout Standard
19745
19746 \family roman
19747 \series medium
19748 \shape up
19749 \size normal
19750 \emph off
19751 \bar no
19752 \noun off
19753 \color none
19754 _uchar2fs.c
19755 \end_layout
19756
19757 \end_inset
19758 </cell>
19759 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19760 \begin_inset Text
19761
19762 \begin_layout Standard
19763
19764 \family roman
19765 \series medium
19766 \shape up
19767 \size normal
19768 \emph off
19769 \bar no
19770 \noun off
19771 \color none
19772 convert unsigned char to floating point
19773 \end_layout
19774
19775 \end_inset
19776 </cell>
19777 </row>
19778 <row topline="true">
19779 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19780 \begin_inset Text
19781
19782 \begin_layout Standard
19783
19784 \family roman
19785 \series medium
19786 \shape up
19787 \size normal
19788 \emph off
19789 \bar no
19790 \noun off
19791 \color none
19792 _char2fs.c
19793 \end_layout
19794
19795 \end_inset
19796 </cell>
19797 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19798 \begin_inset Text
19799
19800 \begin_layout Standard
19801
19802 \family roman
19803 \series medium
19804 \shape up
19805 \size normal
19806 \emph off
19807 \bar no
19808 \noun off
19809 \color none
19810 convert char to floating point number
19811 \end_layout
19812
19813 \end_inset
19814 </cell>
19815 </row>
19816 <row topline="true">
19817 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19818 \begin_inset Text
19819
19820 \begin_layout Standard
19821
19822 \family roman
19823 \series medium
19824 \shape up
19825 \size normal
19826 \emph off
19827 \bar no
19828 \noun off
19829 \color none
19830 _uint2fs.c
19831 \end_layout
19832
19833 \end_inset
19834 </cell>
19835 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19836 \begin_inset Text
19837
19838 \begin_layout Standard
19839
19840 \family roman
19841 \series medium
19842 \shape up
19843 \size normal
19844 \emph off
19845 \bar no
19846 \noun off
19847 \color none
19848 convert unsigned int to floating point
19849 \end_layout
19850
19851 \end_inset
19852 </cell>
19853 </row>
19854 <row topline="true">
19855 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19856 \begin_inset Text
19857
19858 \begin_layout Standard
19859
19860 \family roman
19861 \series medium
19862 \shape up
19863 \size normal
19864 \emph off
19865 \bar no
19866 \noun off
19867 \color none
19868 _int2fs.c
19869 \end_layout
19870
19871 \end_inset
19872 </cell>
19873 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19874 \begin_inset Text
19875
19876 \begin_layout Standard
19877
19878 \family roman
19879 \series medium
19880 \shape up
19881 \size normal
19882 \emph off
19883 \bar no
19884 \noun off
19885 \color none
19886 convert int to floating point numbers
19887 \end_layout
19888
19889 \end_inset
19890 </cell>
19891 </row>
19892 <row topline="true">
19893 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19894 \begin_inset Text
19895
19896 \begin_layout Standard
19897
19898 \family roman
19899 \series medium
19900 \shape up
19901 \size normal
19902 \emph off
19903 \bar no
19904 \noun off
19905 \color none
19906 _ulong2fs.c
19907 \end_layout
19908
19909 \end_inset
19910 </cell>
19911 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19912 \begin_inset Text
19913
19914 \begin_layout Standard
19915
19916 \family roman
19917 \series medium
19918 \shape up
19919 \size normal
19920 \emph off
19921 \bar no
19922 \noun off
19923 \color none
19924 convert unsigned long to floating point number
19925 \end_layout
19926
19927 \end_inset
19928 </cell>
19929 </row>
19930 <row topline="true" bottomline="true">
19931 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19932 \begin_inset Text
19933
19934 \begin_layout Standard
19935
19936 \family roman
19937 \series medium
19938 \shape up
19939 \size normal
19940 \emph off
19941 \bar no
19942 \noun off
19943 \color none
19944 _long2fs.c
19945 \end_layout
19946
19947 \end_inset
19948 </cell>
19949 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19950 \begin_inset Text
19951
19952 \begin_layout Standard
19953
19954 \family roman
19955 \series medium
19956 \shape up
19957 \size normal
19958 \emph off
19959 \bar no
19960 \noun off
19961 \color none
19962 convert long to floating point number
19963 \end_layout
19964
19965 \end_inset
19966 </cell>
19967 </row>
19968 </lyxtabular>
19969
19970 \end_inset
19971
19972
19973 \newline
19974
19975 \end_layout
19976
19977 \begin_layout Standard
19978 These support routines are developed in ANSI-C so there is room for space
19979  and speed improvement
19980 \begin_inset Foot
19981 status open
19982
19983 \begin_layout Standard
19984 These floating point routines (
19985 \emph on
19986 not
19987 \emph default
19988  sinf(), cosf(), ...) for the mcs51 are implemented in assembler.
19989  
19990 \end_layout
19991
19992 \end_inset
19993
19994 .
19995  Note if all these routines are used simultaneously the data space might
19996  overflow.
19997  For serious floating point usage the large model might be needed.
19998  Also notice that you don't have to call this routines directly.
19999  The compiler will use them automatically every time a floating point operation
20000  is required.
20001 \begin_inset VSpace bigskip
20002 \end_inset
20003
20004
20005 \end_layout
20006
20007 \begin_layout Section
20008 Library Routines
20009 \begin_inset LatexCommand \index{Libraries}
20010
20011 \end_inset
20012
20013
20014 \end_layout
20015
20016 \begin_layout Standard
20017
20018 \emph on
20019 <pending: this is messy and incomplete - a little more information is in
20020  sdcc/doc/libdoc.txt
20021 \emph default
20022  >
20023 \end_layout
20024
20025 \begin_layout Subsection
20026 Compiler support routines (_gptrget, _mulint etc.)
20027 \end_layout
20028
20029 \begin_layout Subsection
20030 Stdclib functions (puts, printf, strcat etc.)
20031 \end_layout
20032
20033 \begin_layout Subsubsection
20034 <stdio.h>
20035 \end_layout
20036
20037 \begin_layout Paragraph
20038 getchar(), putchar()
20039 \end_layout
20040
20041 \begin_layout Standard
20042 \begin_inset LatexCommand \index{<stdio.h>}
20043
20044 \end_inset
20045
20046 As usual on embedded systems you have to provide your own 
20047 \family typewriter
20048 getchar()
20049 \begin_inset LatexCommand \index{getchar()}
20050
20051 \end_inset
20052
20053  
20054 \family default
20055 and 
20056 \family typewriter
20057 putchar()
20058 \begin_inset LatexCommand \index{putchar()}
20059
20060 \end_inset
20061
20062
20063 \family default
20064  routines.
20065  SDCC does not know whether the system connects to a serial line with or
20066  without handshake, LCD, keyboard or other device.
20067  And whether a 
20068 \family typewriter
20069 lf
20070 \family default
20071  to 
20072 \family typewriter
20073 crlf
20074 \family default
20075  conversion within 
20076 \family typewriter
20077 putchar()
20078 \family default
20079  is intended.
20080  You'll find examples for serial routines f.e.
20081  in sdcc/device/lib.
20082  For the mcs51 this minimalistic polling 
20083 \family typewriter
20084 putchar()
20085 \family default
20086  routine might be a start:
20087 \end_layout
20088
20089 \begin_layout Verse
20090
20091 \family typewriter
20092 void putchar (char c) { 
20093 \newline
20094 \InsetSpace ~
20095 \InsetSpace ~
20096 \InsetSpace ~
20097 \InsetSpace ~
20098 while (!TI)\InsetSpace ~
20099 \InsetSpace ~
20100 \InsetSpace ~
20101  /* assumes UART is initialized */
20102 \newline
20103 \InsetSpace ~
20104 \InsetSpace ~
20105 \InsetSpace ~
20106 \InsetSpace ~
20107 \InsetSpace ~
20108 \InsetSpace ~
20109 \InsetSpace ~
20110 \InsetSpace ~
20111 ;
20112 \newline
20113 \InsetSpace ~
20114 \InsetSpace ~
20115 \InsetSpace ~
20116 \InsetSpace ~
20117 TI
20118  = 0;
20119 \newline
20120 \InsetSpace ~
20121 \InsetSpace ~
20122 \InsetSpace ~
20123 \InsetSpace ~
20124 SBUF = c;
20125 \newline
20126 }
20127 \end_layout
20128
20129 \begin_layout Paragraph
20130 printf()
20131 \end_layout
20132
20133 \begin_layout Standard
20134 The default
20135 \family typewriter
20136  printf()
20137 \begin_inset LatexCommand \index{printf()}
20138
20139 \end_inset
20140
20141
20142 \family default
20143  implementation in
20144 \family typewriter
20145  printf_large.c
20146 \family default
20147  does not support float (except on ds390).
20148  To enable this recompile it with the option 
20149 \emph on
20150 -
20151 \begin_inset ERT
20152 status collapsed
20153
20154 \begin_layout Standard
20155
20156
20157 \backslash
20158 /
20159 \end_layout
20160
20161 \end_inset
20162
20163 DUSE_FLOATS=1
20164 \begin_inset LatexCommand \index{USE\_FLOATS}
20165
20166 \end_inset
20167
20168
20169 \emph default
20170  on the command line.
20171  Use
20172 \emph on
20173  -
20174 \begin_inset ERT
20175 status collapsed
20176
20177 \begin_layout Standard
20178
20179
20180 \backslash
20181 /
20182 \end_layout
20183
20184 \end_inset
20185
20186 -model-large
20187 \begin_inset LatexCommand \index{-\/-model-large}
20188
20189 \end_inset
20190
20191
20192 \emph default
20193  for the mcs51 port, since this uses a lot of memory.
20194 \end_layout
20195
20196 \begin_layout Standard
20197 If you're short on code memory you might want to use 
20198 \family typewriter
20199 printf_small()
20200 \begin_inset LatexCommand \index{printf\_small()}
20201
20202 \end_inset
20203
20204
20205 \family default
20206  
20207 \emph on
20208 instead
20209 \emph default
20210  of
20211 \family typewriter
20212  printf().
20213
20214 \family default
20215  For the mcs51 there additionally are assembly versions 
20216 \family typewriter
20217 printf_tiny()
20218 \begin_inset LatexCommand \index{printf\_tiny() (mcs51)}
20219
20220 \end_inset
20221
20222
20223 \family default
20224  (subset of printf using less than 270 bytes) and 
20225 \family typewriter
20226 printf_fast()
20227 \begin_inset LatexCommand \index{printf\_fast() (mcs51)}
20228
20229 \end_inset
20230
20231  
20232 \family default
20233 and
20234 \family typewriter
20235  printf_fast_f()
20236 \begin_inset LatexCommand \index{printf\_fast\_f() (mcs51)}
20237
20238 \end_inset
20239
20240
20241 \family default
20242  (floating-point aware version of printf_fast) which should fit the requirements
20243  of many embedded systems (printf_fast() can be customized by unsetting
20244  #defines to 
20245 \emph on
20246 not
20247 \emph default
20248  support long variables and field widths).
20249  Be sure to use only one of these printf options within a project.
20250 \newline
20251
20252 \end_layout
20253
20254 \begin_layout Standard
20255 Feature matrix of different 
20256 \emph on
20257 printf
20258 \emph default
20259  options on mcs51.
20260 \end_layout
20261
20262 \begin_layout Standard
20263 \begin_inset Tabular
20264 <lyxtabular version="3" rows="14" columns="7">
20265 <features islongtable="true">
20266 <column alignment="left" valignment="middle" leftline="true" width="14col%">
20267 <column alignment="center" valignment="top" leftline="true" width="0">
20268 <column alignment="center" valignment="top" leftline="true" width="12col%">
20269 <column alignment="center" valignment="top" leftline="true" width="10col%">
20270 <column alignment="center" valignment="top" leftline="true" width="0">
20271 <column alignment="center" valignment="top" leftline="true" rightline="true" width="12col%">
20272 <column alignment="center" valignment="top" rightline="true" width="0">
20273 <row topline="true" bottomline="true" endhead="true">
20274 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20275 \begin_inset Text
20276
20277 \begin_layout Standard
20278
20279 \series bold
20280 \size large
20281 mcs51
20282 \end_layout
20283
20284 \end_inset
20285 </cell>
20286 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20287 \begin_inset Text
20288
20289 \begin_layout Standard
20290 printf
20291 \begin_inset LatexCommand \index{printf}
20292
20293 \end_inset
20294
20295
20296 \end_layout
20297
20298 \end_inset
20299 </cell>
20300 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20301 \begin_inset Text
20302
20303 \begin_layout Standard
20304 printf 
20305 \size scriptsize
20306 USE_FLOATS=1
20307 \end_layout
20308
20309 \end_inset
20310 </cell>
20311 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20312 \begin_inset Text
20313
20314 \begin_layout Standard
20315 printf_small
20316 \end_layout
20317
20318 \end_inset
20319 </cell>
20320 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20321 \begin_inset Text
20322
20323 \begin_layout Standard
20324 printf_fast
20325 \end_layout
20326
20327 \end_inset
20328 </cell>
20329 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20330 \begin_inset Text
20331
20332 \begin_layout Standard
20333 printf_fast_f
20334 \end_layout
20335
20336 \end_inset
20337 </cell>
20338 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20339 \begin_inset Text
20340
20341 \begin_layout Standard
20342 printf_tiny
20343 \end_layout
20344
20345 \end_inset
20346 </cell>
20347 </row>
20348 <row topline="true" endhead="true">
20349 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20350 \begin_inset Text
20351
20352 \begin_layout Standard
20353 filename
20354 \end_layout
20355
20356 \end_inset
20357 </cell>
20358 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20359 \begin_inset Text
20360
20361 \begin_layout Standard
20362
20363 \size scriptsize
20364 printf_large.c
20365 \end_layout
20366
20367 \end_inset
20368 </cell>
20369 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20370 \begin_inset Text
20371
20372 \begin_layout Standard
20373
20374 \size scriptsize
20375 printf_large.c
20376 \end_layout
20377
20378 \end_inset
20379 </cell>
20380 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20381 \begin_inset Text
20382
20383 \begin_layout Standard
20384
20385 \size scriptsize
20386 printfl.c
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
20396 \size scriptsize
20397 printf_fast.c
20398 \end_layout
20399
20400 \end_inset
20401 </cell>
20402 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20403 \begin_inset Text
20404
20405 \begin_layout Standard
20406
20407 \size scriptsize
20408 printf_fast_f.c
20409 \end_layout
20410
20411 \end_inset
20412 </cell>
20413 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20414 \begin_inset Text
20415
20416 \begin_layout Standard
20417
20418 \size scriptsize
20419 printf_tiny.c
20420 \end_layout
20421
20422 \end_inset
20423 </cell>
20424 </row>
20425 <row topline="true" endhead="true">
20426 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20427 \begin_inset Text
20428
20429 \begin_layout Standard
20430 \begin_inset Quotes sld
20431 \end_inset
20432
20433 Hello World
20434 \begin_inset Quotes srd
20435 \end_inset
20436
20437  size
20438 \end_layout
20439
20440 \begin_layout Standard
20441 small / large
20442 \end_layout
20443
20444 \end_inset
20445 </cell>
20446 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20447 \begin_inset Text
20448
20449 \begin_layout Standard
20450 1.7k / 2.4k
20451 \end_layout
20452
20453 \end_inset
20454 </cell>
20455 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20456 \begin_inset Text
20457
20458 \begin_layout Standard
20459 4.3k / 5.6k
20460 \end_layout
20461
20462 \end_inset
20463 </cell>
20464 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20465 \begin_inset Text
20466
20467 \begin_layout Standard
20468 1.2k / 1.8k
20469 \end_layout
20470
20471 \end_inset
20472 </cell>
20473 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20474 \begin_inset Text
20475
20476 \begin_layout Standard
20477 1.3k / 1.3k
20478 \end_layout
20479
20480 \end_inset
20481 </cell>
20482 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20483 \begin_inset Text
20484
20485 \begin_layout Standard
20486 1.9k / 1.9k
20487 \end_layout
20488
20489 \end_inset
20490 </cell>
20491 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20492 \begin_inset Text
20493
20494 \begin_layout Standard
20495 0.44k / 0.44k
20496 \end_layout
20497
20498 \end_inset
20499 </cell>
20500 </row>
20501 <row topline="true" endhead="true">
20502 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20503 \begin_inset Text
20504
20505 \begin_layout Standard
20506 code size
20507 \end_layout
20508
20509 \begin_layout Standard
20510 small / large
20511 \end_layout
20512
20513 \end_inset
20514 </cell>
20515 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20516 \begin_inset Text
20517
20518 \begin_layout Standard
20519 1.4k / 2.0k
20520 \end_layout
20521
20522 \end_inset
20523 </cell>
20524 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20525 \begin_inset Text
20526
20527 \begin_layout Standard
20528 2.8k / 3.7k
20529 \end_layout
20530
20531 \end_inset
20532 </cell>
20533 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20534 \begin_inset Text
20535
20536 \begin_layout Standard
20537 0.45k / 0.47k (+ _ltoa)
20538 \end_layout
20539
20540 \end_inset
20541 </cell>
20542 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20543 \begin_inset Text
20544
20545 \begin_layout Standard
20546 1.2k / 1.2k
20547 \end_layout
20548
20549 \end_inset
20550 </cell>
20551 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20552 \begin_inset Text
20553
20554 \begin_layout Standard
20555 1.6k / 1.6k
20556 \end_layout
20557
20558 \end_inset
20559 </cell>
20560 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20561 \begin_inset Text
20562
20563 \begin_layout Standard
20564 0.26k / 0.26k
20565 \end_layout
20566
20567 \end_inset
20568 </cell>
20569 </row>
20570 <row topline="true">
20571 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20572 \begin_inset Text
20573
20574 \begin_layout Standard
20575 formats
20576 \end_layout
20577
20578 \end_inset
20579 </cell>
20580 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20581 \begin_inset Text
20582
20583 \begin_layout Standard
20584 cdi
20585 \emph on
20586 o
20587 \emph default
20588 psux
20589 \end_layout
20590
20591 \end_inset
20592 </cell>
20593 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20594 \begin_inset Text
20595
20596 \begin_layout Standard
20597
20598 \family roman
20599 \series medium
20600 \shape up
20601 \size normal
20602 \emph off
20603 \bar no
20604 \noun off
20605 \color none
20606 cd
20607 \family default
20608 \series default
20609 \shape default
20610 \size default
20611 \emph default
20612 \bar default
20613 \noun default
20614 f
20615 \family roman
20616 \series medium
20617 \shape up
20618 \size normal
20619 \emph off
20620 \bar no
20621 \noun off
20622 i
20623 \family default
20624 \series default
20625 \shape default
20626 \size default
20627 \emph on
20628 \bar default
20629 \noun default
20630 o
20631 \family roman
20632 \series medium
20633 \shape up
20634 \size normal
20635 \emph off
20636 \bar no
20637 \noun off
20638 psux
20639 \end_layout
20640
20641 \end_inset
20642 </cell>
20643 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20644 \begin_inset Text
20645
20646 \begin_layout Standard
20647 c
20648 \family roman
20649 \series medium
20650 \shape up
20651 \size normal
20652 \emph off
20653 \bar no
20654 \noun off
20655 \color none
20656 d
20657 \family default
20658 \series default
20659 \shape default
20660 \size default
20661 \emph on
20662 \bar default
20663 \noun default
20664 o
20665 \family roman
20666 \series medium
20667 \shape up
20668 \size normal
20669 \emph off
20670 \bar no
20671 \noun off
20672 s
20673 \family default
20674 \series default
20675 \shape default
20676 \size default
20677 \emph default
20678 \bar default
20679 \noun default
20680 x
20681 \end_layout
20682
20683 \end_inset
20684 </cell>
20685 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20686 \begin_inset Text
20687
20688 \begin_layout Standard
20689 cdsux
20690 \end_layout
20691
20692 \end_inset
20693 </cell>
20694 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20695 \begin_inset Text
20696
20697 \begin_layout Standard
20698 cdfsux
20699 \end_layout
20700
20701 \end_inset
20702 </cell>
20703 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20704 \begin_inset Text
20705
20706 \begin_layout Standard
20707 cdsux
20708 \end_layout
20709
20710 \end_inset
20711 </cell>
20712 </row>
20713 <row topline="true">
20714 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20715 \begin_inset Text
20716
20717 \begin_layout Standard
20718 long (32 bit) support
20719 \end_layout
20720
20721 \end_inset
20722 </cell>
20723 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20724 \begin_inset Text
20725
20726 \begin_layout Standard
20727 x
20728 \end_layout
20729
20730 \end_inset
20731 </cell>
20732 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20733 \begin_inset Text
20734
20735 \begin_layout Standard
20736 x
20737 \end_layout
20738
20739 \end_inset
20740 </cell>
20741 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20742 \begin_inset Text
20743
20744 \begin_layout Standard
20745 x
20746 \end_layout
20747
20748 \end_inset
20749 </cell>
20750 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20751 \begin_inset Text
20752
20753 \begin_layout Standard
20754 x
20755 \end_layout
20756
20757 \end_inset
20758 </cell>
20759 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20760 \begin_inset Text
20761
20762 \begin_layout Standard
20763
20764 \family roman
20765 \series medium
20766 \shape up
20767 \size normal
20768 \emph off
20769 \bar no
20770 \noun off
20771 \color none
20772 x
20773 \end_layout
20774
20775 \end_inset
20776 </cell>
20777 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20778 \begin_inset Text
20779
20780 \begin_layout Standard
20781 -
20782 \end_layout
20783
20784 \end_inset
20785 </cell>
20786 </row>
20787 <row topline="true">
20788 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20789 \begin_inset Text
20790
20791 \begin_layout Standard
20792 byte arguments on stack
20793 \end_layout
20794
20795 \end_inset
20796 </cell>
20797 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20798 \begin_inset Text
20799
20800 \begin_layout Standard
20801 b
20802 \end_layout
20803
20804 \end_inset
20805 </cell>
20806 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20807 \begin_inset Text
20808
20809 \begin_layout Standard
20810 b
20811 \end_layout
20812
20813 \end_inset
20814 </cell>
20815 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20816 \begin_inset Text
20817
20818 \begin_layout Standard
20819 -
20820 \end_layout
20821
20822 \end_inset
20823 </cell>
20824 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20825 \begin_inset Text
20826
20827 \begin_layout Standard
20828 -
20829 \end_layout
20830
20831 \end_inset
20832 </cell>
20833 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20834 \begin_inset Text
20835
20836 \begin_layout Standard
20837 -
20838 \end_layout
20839
20840 \end_inset
20841 </cell>
20842 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20843 \begin_inset Text
20844
20845 \begin_layout Standard
20846 -
20847 \end_layout
20848
20849 \end_inset
20850 </cell>
20851 </row>
20852 <row topline="true">
20853 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20854 \begin_inset Text
20855
20856 \begin_layout Standard
20857 float format
20858 \begin_inset LatexCommand \index{Floating point support}
20859
20860 \end_inset
20861
20862
20863 \end_layout
20864
20865 \end_inset
20866 </cell>
20867 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20868 \begin_inset Text
20869
20870 \begin_layout Standard
20871 -
20872 \end_layout
20873
20874 \end_inset
20875 </cell>
20876 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20877 \begin_inset Text
20878
20879 \begin_layout Standard
20880 %f
20881 \end_layout
20882
20883 \end_inset
20884 </cell>
20885 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20886 \begin_inset Text
20887
20888 \begin_layout Standard
20889 -
20890 \end_layout
20891
20892 \end_inset
20893 </cell>
20894 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20895 \begin_inset Text
20896
20897 \begin_layout Standard
20898 -
20899 \end_layout
20900
20901 \end_inset
20902 </cell>
20903 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20904 \begin_inset Text
20905
20906 \begin_layout Standard
20907 %f
20908 \begin_inset Foot
20909 status collapsed
20910
20911 \begin_layout Standard
20912 Range limited to +/- 4294967040, precision limited to 8 digits past decimal
20913 \end_layout
20914
20915 \end_inset
20916
20917
20918 \end_layout
20919
20920 \end_inset
20921 </cell>
20922 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20923 \begin_inset Text
20924
20925 \begin_layout Standard
20926 -
20927 \end_layout
20928
20929 \end_inset
20930 </cell>
20931 </row>
20932 <row topline="true">
20933 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20934 \begin_inset Text
20935
20936 \begin_layout Standard
20937 float formats %e %g
20938 \end_layout
20939
20940 \end_inset
20941 </cell>
20942 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20943 \begin_inset Text
20944
20945 \begin_layout Standard
20946 -
20947 \end_layout
20948
20949 \end_inset
20950 </cell>
20951 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20952 \begin_inset Text
20953
20954 \begin_layout Standard
20955 -
20956 \end_layout
20957
20958 \end_inset
20959 </cell>
20960 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20961 \begin_inset Text
20962
20963 \begin_layout Standard
20964 -
20965 \end_layout
20966
20967 \end_inset
20968 </cell>
20969 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20970 \begin_inset Text
20971
20972 \begin_layout Standard
20973 -
20974 \end_layout
20975
20976 \end_inset
20977 </cell>
20978 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20979 \begin_inset Text
20980
20981 \begin_layout Standard
20982 -
20983 \end_layout
20984
20985 \end_inset
20986 </cell>
20987 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20988 \begin_inset Text
20989
20990 \begin_layout Standard
20991 -
20992 \end_layout
20993
20994 \end_inset
20995 </cell>
20996 </row>
20997 <row topline="true" bottomline="true">
20998 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20999 \begin_inset Text
21000
21001 \begin_layout Standard
21002 field width
21003 \end_layout
21004
21005 \end_inset
21006 </cell>
21007 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21008 \begin_inset Text
21009
21010 \begin_layout Standard
21011 x
21012 \end_layout
21013
21014 \end_inset
21015 </cell>
21016 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21017 \begin_inset Text
21018
21019 \begin_layout Standard
21020 x
21021 \end_layout
21022
21023 \end_inset
21024 </cell>
21025 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21026 \begin_inset Text
21027
21028 \begin_layout Standard
21029 -
21030 \end_layout
21031
21032 \end_inset
21033 </cell>
21034 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21035 \begin_inset Text
21036
21037 \begin_layout Standard
21038 x
21039 \end_layout
21040
21041 \end_inset
21042 </cell>
21043 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21044 \begin_inset Text
21045
21046 \begin_layout Standard
21047 x
21048 \end_layout
21049
21050 \end_inset
21051 </cell>
21052 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21053 \begin_inset Text
21054
21055 \begin_layout Standard
21056 -
21057 \end_layout
21058
21059 \end_inset
21060 </cell>
21061 </row>
21062 <row bottomline="true">
21063 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21064 \begin_inset Text
21065
21066 \begin_layout Standard
21067 string speed
21068 \begin_inset Foot
21069 status collapsed
21070
21071 \begin_layout Standard
21072 Execution time of printf("%s%c%s%c%c%c", "Hello", ' ', "World", '!', '
21073 \backslash
21074 r', '
21075 \backslash
21076 n'); standard 8051 @ 22.1184 MHz, empty putchar()
21077 \end_layout
21078
21079 \end_inset
21080
21081 ,
21082 \end_layout
21083
21084 \begin_layout Standard
21085 small / large
21086 \end_layout
21087
21088 \end_inset
21089 </cell>
21090 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21091 \begin_inset Text
21092
21093 \begin_layout Standard
21094 1.52 / 2.59 ms
21095 \end_layout
21096
21097 \end_inset
21098 </cell>
21099 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21100 \begin_inset Text
21101
21102 \begin_layout Standard
21103 1.53 / 2.62 ms
21104 \end_layout
21105
21106 \end_inset
21107 </cell>
21108 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21109 \begin_inset Text
21110
21111 \begin_layout Standard
21112 0.92 / 0.93 ms
21113 \end_layout
21114
21115 \end_inset
21116 </cell>
21117 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21118 \begin_inset Text
21119
21120 \begin_layout Standard
21121 0.45 / 0.45 ms
21122 \end_layout
21123
21124 \end_inset
21125 </cell>
21126 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21127 \begin_inset Text
21128
21129 \begin_layout Standard
21130 0.46 / 0.46 ms
21131 \end_layout
21132
21133 \end_inset
21134 </cell>
21135 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21136 \begin_inset Text
21137
21138 \begin_layout Standard
21139 0.45 / 0.45 ms
21140 \end_layout
21141
21142 \end_inset
21143 </cell>
21144 </row>
21145 <row bottomline="true">
21146 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21147 \begin_inset Text
21148
21149 \begin_layout Standard
21150 int speed
21151 \begin_inset Foot
21152 status collapsed
21153
21154 \begin_layout Standard
21155 Execution time of printf("%d", -12345); standard 8051 @ 22.1184 MHz, empty
21156  putchar()
21157 \end_layout
21158
21159 \end_inset
21160
21161 ,
21162 \end_layout
21163
21164 \begin_layout Standard
21165 small / large
21166 \end_layout
21167
21168 \end_inset
21169 </cell>
21170 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21171 \begin_inset Text
21172
21173 \begin_layout Standard
21174 3.01 / 3.61 ms
21175 \end_layout
21176
21177 \end_inset
21178 </cell>
21179 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21180 \begin_inset Text
21181
21182 \begin_layout Standard
21183 3.01 / 3.61 ms
21184 \end_layout
21185
21186 \end_inset
21187 </cell>
21188 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21189 \begin_inset Text
21190
21191 \begin_layout Standard
21192 3.51 / 18.13 ms
21193 \end_layout
21194
21195 \end_inset
21196 </cell>
21197 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21198 \begin_inset Text
21199
21200 \begin_layout Standard
21201 0.22 / 0.22 ms
21202 \end_layout
21203
21204 \end_inset
21205 </cell>
21206 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21207 \begin_inset Text
21208
21209 \begin_layout Standard
21210 0.23 / 0.23 ms
21211 \end_layout
21212
21213 \end_inset
21214 </cell>
21215 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21216 \begin_inset Text
21217
21218 \begin_layout Standard
21219 0.25 / 0.25 ms
21220 \begin_inset Foot
21221 status collapsed
21222
21223 \begin_layout Standard
21224 printf_tiny integer speed is data dependent, worst case is 0.33 ms
21225 \end_layout
21226
21227 \end_inset
21228
21229
21230 \end_layout
21231
21232 \end_inset
21233 </cell>
21234 </row>
21235 <row bottomline="true">
21236 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21237 \begin_inset Text
21238
21239 \begin_layout Standard
21240 long speed
21241 \begin_inset Foot
21242 status collapsed
21243
21244 \begin_layout Standard
21245 Execution time of printf("%ld", -123456789); standard 8051 @ 22.1184 MHz,
21246  empty putchar()
21247 \end_layout
21248
21249 \end_inset
21250
21251 ,
21252 \end_layout
21253
21254 \begin_layout Standard
21255 small / large
21256 \end_layout
21257
21258 \end_inset
21259 </cell>
21260 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21261 \begin_inset Text
21262
21263 \begin_layout Standard
21264 5.37 / 6.31 ms
21265 \end_layout
21266
21267 \end_inset
21268 </cell>
21269 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21270 \begin_inset Text
21271
21272 \begin_layout Standard
21273 5.37 / 6.31 ms
21274 \end_layout
21275
21276 \end_inset
21277 </cell>
21278 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21279 \begin_inset Text
21280
21281 \begin_layout Standard
21282 8.71 / 40.65 ms
21283 \end_layout
21284
21285 \end_inset
21286 </cell>
21287 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21288 \begin_inset Text
21289
21290 \begin_layout Standard
21291 0.40 / 0.40 ms
21292 \end_layout
21293
21294 \end_inset
21295 </cell>
21296 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21297 \begin_inset Text
21298
21299 \begin_layout Standard
21300 0.40 / 0.40 ms
21301 \end_layout
21302
21303 \end_inset
21304 </cell>
21305 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21306 \begin_inset Text
21307
21308 \begin_layout Standard
21309 -
21310 \end_layout
21311
21312 \end_inset
21313 </cell>
21314 </row>
21315 <row bottomline="true">
21316 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21317 \begin_inset Text
21318
21319 \begin_layout Standard
21320 float speed
21321 \begin_inset Foot
21322 status collapsed
21323
21324 \begin_layout Standard
21325 Execution time of printf("%.3f", -12345.678); standard 8051 @ 22.1184 MHz,
21326  empty putchar()
21327 \end_layout
21328
21329 \end_inset
21330
21331 ,
21332 \end_layout
21333
21334 \begin_layout Standard
21335 small / large
21336 \end_layout
21337
21338 \end_inset
21339 </cell>
21340 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21341 \begin_inset Text
21342
21343 \begin_layout Standard
21344 -
21345 \end_layout
21346
21347 \end_inset
21348 </cell>
21349 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21350 \begin_inset Text
21351
21352 \begin_layout Standard
21353 7.49 / 22.47 ms
21354 \end_layout
21355
21356 \end_inset
21357 </cell>
21358 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21359 \begin_inset Text
21360
21361 \begin_layout Standard
21362 -
21363 \end_layout
21364
21365 \end_inset
21366 </cell>
21367 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21368 \begin_inset Text
21369
21370 \begin_layout Standard
21371 -
21372 \end_layout
21373
21374 \end_inset
21375 </cell>
21376 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21377 \begin_inset Text
21378
21379 \begin_layout Standard
21380 1.04 / 1.04 ms
21381 \end_layout
21382
21383 \end_inset
21384 </cell>
21385 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21386 \begin_inset Text
21387
21388 \begin_layout Standard
21389 -
21390 \end_layout
21391
21392 \end_inset
21393 </cell>
21394 </row>
21395 </lyxtabular>
21396
21397 \end_inset
21398
21399
21400 \end_layout
21401
21402 \begin_layout Subsubsection
21403 <malloc.h>
21404 \begin_inset LatexCommand \index{malloc.h}
21405
21406 \end_inset
21407
21408
21409 \end_layout
21410
21411 \begin_layout Standard
21412 As of SDCC 2.6.2 you no longer need to call an initialization routine before
21413  using dynamic memory allocation
21414 \begin_inset LatexCommand \index{dynamic memory allocation (malloc)}
21415
21416 \end_inset
21417
21418  and a default heap
21419 \begin_inset LatexCommand \index{heap (malloc)}
21420
21421 \end_inset
21422
21423  space of 1024 bytes is provided for malloc to allocate memory from.
21424  If you need a different heap size you need to recompile _heap.c with the
21425  required size defined in HEAP_SIZE.
21426  It is recommended to make a copy of this file into your project directory
21427  and compile it there with:
21428 \end_layout
21429
21430 \begin_layout Verse
21431
21432 \family typewriter
21433 sdcc -c _heap.c -D HEAD_SIZE=2048
21434 \end_layout
21435
21436 \begin_layout Standard
21437 And then link it with:
21438 \end_layout
21439
21440 \begin_layout Verse
21441
21442 \family typewriter
21443 sdcc main.rel _heap.rel
21444 \end_layout
21445
21446 \begin_layout Subsection
21447 Math functions (sinf, powf, sqrtf etc.)
21448 \end_layout
21449
21450 \begin_layout Subsubsection
21451 <math.h>
21452 \end_layout
21453
21454 \begin_layout Standard
21455 See definitions in file <math.h>.
21456 \end_layout
21457
21458 \begin_layout Subsection
21459 Other libraries
21460 \end_layout
21461
21462 \begin_layout Standard
21463 Libraries
21464 \begin_inset LatexCommand \index{Libraries}
21465
21466 \end_inset
21467
21468  included in SDCC should have a license at least as liberal as the GNU Lesser
21469  General Public License
21470 \begin_inset LatexCommand \index{GNU Lesser General Public License, LGPL}
21471
21472 \end_inset
21473
21474  
21475 \emph on
21476 LGPL
21477 \emph default
21478 .
21479 \end_layout
21480
21481 \begin_layout Standard
21482 \begin_inset Note Note
21483 status collapsed
21484
21485 \begin_layout Standard
21486 license statements for the libraries are missing.
21487  sdcc/device/lib/ser_ir.c
21488 \end_layout
21489
21490 \begin_layout Standard
21491 or _decdptr f.e.
21492  come with a GPL (as opposed to LGPL) License - this will not be liberal
21493  enough for many embedded programmers.
21494 \end_layout
21495
21496 \end_inset
21497
21498
21499 \end_layout
21500
21501 \begin_layout Standard
21502 If you have ported some library or want to share experience about some code
21503  which f.e.
21504  falls into any of these categories Busses (I
21505 \begin_inset Formula $^{\textrm{2}}$
21506 \end_inset
21507
21508 C, CAN, Ethernet, Profibus, Modbus, USB, SPI, JTAG ...), Media (IDE, Memory
21509  cards, eeprom, flash...), En-/Decryption, Remote debugging, Realtime kernel,
21510  Keyboard, LCD, RTC, FPGA, PID then the sdcc-user mailing list 
21511 \begin_inset LatexCommand \url{http://sourceforge.net/mail/?group_id=599}
21512
21513 \end_inset
21514
21515 \InsetSpace ~
21516 would certainly like to hear about it.
21517 \end_layout
21518
21519 \begin_layout Standard
21520 Programmers coding for embedded systems are not especially famous for being
21521  enthusiastic, so don't expect a big hurray but as the mailing list is searchabl
21522 e these references are very valuable.
21523  Let's help to create a climate where information is shared.
21524 \begin_inset VSpace bigskip
21525 \end_inset
21526
21527
21528 \end_layout
21529
21530 \begin_layout Section
21531 Memory Models
21532 \end_layout
21533
21534 \begin_layout Subsection
21535 MCS51 Memory Models
21536 \begin_inset LatexCommand \index{Memory model}
21537
21538 \end_inset
21539
21540
21541 \begin_inset LatexCommand \index{MCS51 memory model}
21542
21543 \end_inset
21544
21545
21546 \end_layout
21547
21548 \begin_layout Subsubsection
21549 Small, Medium and Large
21550 \end_layout
21551
21552 \begin_layout Standard
21553 SDCC allows three memory models for MCS51 code, 
21554 \shape slanted
21555 small, medium
21556 \shape default
21557  and 
21558 \shape slanted
21559 large
21560 \shape default
21561 .
21562  Modules compiled with different memory models should 
21563 \emph on
21564 never
21565 \emph default
21566  be combined together or the results would be unpredictable.
21567  The library routines supplied with the compiler are compiled as small,
21568  medium and large.
21569  The compiled library modules are contained in separate directories as small,
21570  medium and large so that you can link to the appropriate set.
21571 \end_layout
21572
21573 \begin_layout Standard
21574 When the medium or large model is used all variables declared without a
21575  storage class will be allocated into the external ram, this includes all
21576  parameters and local variables (for non-reentrant
21577 \begin_inset LatexCommand \index{reentrant}
21578
21579 \end_inset
21580
21581  functions).
21582  When the small model is used variables without storage class are allocated
21583  in the internal ram.
21584 \end_layout
21585
21586 \begin_layout Standard
21587 Judicious usage of the processor specific storage classes
21588 \begin_inset LatexCommand \index{Storage class}
21589
21590 \end_inset
21591
21592  and the 'reentrant' function type will yield much more efficient code,
21593  than using the large model.
21594  Several optimizations are disabled when the program is compiled using the
21595  large model, it is therefore recommended that the small model be used unless
21596  absolutely required.
21597 \end_layout
21598
21599 \begin_layout Subsubsection
21600 External Stack
21601 \begin_inset LatexCommand \label{sub:External-Stack}
21602
21603 \end_inset
21604
21605
21606 \begin_inset LatexCommand \index{stack}
21607
21608 \end_inset
21609
21610
21611 \begin_inset LatexCommand \index{External stack (mcs51)}
21612
21613 \end_inset
21614
21615
21616 \end_layout
21617
21618 \begin_layout Standard
21619 The external stack (-
21620 \begin_inset ERT
21621 status collapsed
21622
21623 \begin_layout Standard
21624
21625
21626 \backslash
21627 /
21628 \end_layout
21629
21630 \end_inset
21631
21632 -xstack option
21633 \begin_inset LatexCommand \index{-\/-xstack}
21634
21635 \end_inset
21636
21637 ) is located in pdata
21638 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
21639
21640 \end_inset
21641
21642  memory (usually at the start of the external ram segment) and uses all
21643  unused space in pdata (max.
21644  256 bytes).
21645  When -
21646 \begin_inset ERT
21647 status collapsed
21648
21649 \begin_layout Standard
21650
21651
21652 \backslash
21653 /
21654 \end_layout
21655
21656 \end_inset
21657
21658 -xstack option is used to compile the program, the parameters and local
21659  variables
21660 \begin_inset LatexCommand \index{local variables}
21661
21662 \end_inset
21663
21664  of all reentrant functions are allocated in this area.
21665  This option is provided for programs with large stack space requirements.
21666  When used with the -
21667 \begin_inset ERT
21668 status collapsed
21669
21670 \begin_layout Standard
21671
21672
21673 \backslash
21674 /
21675 \end_layout
21676
21677 \end_inset
21678
21679 -stack-auto
21680 \begin_inset LatexCommand \index{-\/-stack-auto}
21681
21682 \end_inset
21683
21684  option, all parameters and local variables are allocated on the external
21685  stack (note: support libraries will need to be recompiled with the same
21686  options.
21687  There is a predefined target in the library makefile).
21688 \end_layout
21689
21690 \begin_layout Standard
21691 The compiler outputs the higher order address byte of the external ram segment
21692  into port P2
21693 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
21694
21695 \end_inset
21696
21697  (see also section 
21698 \begin_inset LatexCommand \ref{sub:MCS51-variants}
21699
21700 \end_inset
21701
21702 ), therefore when using the External Stack option, this port 
21703 \emph on
21704 may not
21705 \emph default
21706  be used by the application program.
21707 \end_layout
21708
21709 \begin_layout Subsection
21710 DS390 Memory Model
21711 \begin_inset LatexCommand \index{Memory model}
21712
21713 \end_inset
21714
21715
21716 \begin_inset LatexCommand \index{DS390 memory model}
21717
21718 \end_inset
21719
21720
21721 \end_layout
21722
21723 \begin_layout Standard
21724 The only model supported is Flat 24
21725 \begin_inset LatexCommand \index{Flat 24 (DS390 memory model)}
21726
21727 \end_inset
21728
21729 .
21730  This generates code for the 24 bit contiguous addressing mode of the Dallas
21731  DS80C390 part.
21732  In this mode, up to four meg of external RAM or code space can be directly
21733  addressed.
21734  See the data sheets at www.dalsemi.com for further information on this part.
21735 \newline
21736
21737 \newline
21738 Note
21739  that the compiler does not generate any code to place the processor into
21740  24 bitmode (although 
21741 \emph on
21742 tinibios
21743 \emph default
21744  in the ds390 libraries will do that for you).
21745  If you don't use 
21746 \emph on
21747 tinibios
21748 \emph default
21749
21750 \begin_inset LatexCommand \index{Tinibios (DS390)}
21751
21752 \end_inset
21753
21754 , the boot loader or similar code must ensure that the processor is in 24
21755  bit contiguous addressing mode before calling the SDCC startup code.
21756 \newline
21757
21758 \newline
21759 Like
21760  the 
21761 \emph on
21762 -
21763 \begin_inset ERT
21764 status collapsed
21765
21766 \begin_layout Standard
21767
21768
21769 \backslash
21770 /
21771 \end_layout
21772
21773 \end_inset
21774
21775 -model-large
21776 \emph default
21777  option, variables will by default be placed into the XDATA segment.
21778  
21779 \newline
21780
21781 \newline
21782 Segments may be placed anywhere in the 4 meg address space using the usual
21783  -
21784 \begin_inset ERT
21785 status collapsed
21786
21787 \begin_layout Standard
21788
21789
21790 \backslash
21791 /
21792 \end_layout
21793
21794 \end_inset
21795
21796 -*-loc options.
21797  Note that if any segments are located above 64K, the -r flag must be passed
21798  to the linker to generate the proper segment relocations, and the Intel
21799  HEX output format must be used.
21800  The -r flag can be passed to the linker by using the option 
21801 \emph on
21802 -Wl-r
21803 \emph default
21804  on the SDCC command line.
21805  However, currently the linker can not handle code segments > 64k.
21806 \end_layout
21807
21808 \begin_layout Section
21809 Pragmas
21810 \begin_inset LatexCommand \label{sec:Pragmas}
21811
21812 \end_inset
21813
21814
21815 \begin_inset LatexCommand \index{Pragmas}
21816
21817 \end_inset
21818
21819
21820 \end_layout
21821
21822 \begin_layout Standard
21823 Pragmas are used to turn on and/or off certain compiler options.
21824  Some of them are closely related to corresponding command-line options
21825  (see section 
21826 \begin_inset LatexCommand \vref{sec:Command-Line-Options}
21827
21828 \end_inset
21829
21830 ).
21831 \newline
21832 Pragmas should be placed before and/or after a function, placing pragmas
21833  inside a function body could have unpredictable results.
21834 \newline
21835
21836 \newline
21837 SDCC supports the
21838  following #pragma directives:
21839 \end_layout
21840
21841 \begin_layout Itemize
21842
21843 \series bold
21844 save
21845 \series default
21846
21847 \begin_inset LatexCommand \index{\#pragma save}
21848
21849 \end_inset
21850
21851  - this will save most current options to the save/restore stack.
21852  See #pragma\InsetSpace ~
21853 restore.
21854 \end_layout
21855
21856 \begin_layout Itemize
21857
21858 \series bold
21859 restore
21860 \series default
21861
21862 \begin_inset LatexCommand \index{\#pragma restore}
21863
21864 \end_inset
21865
21866  - will restore saved options from the last save.
21867  saves & restores can be nested.
21868  SDCC uses a save/restore stack: save pushes current options to the stack,
21869  restore pulls current options from the stack.
21870  See #pragma\InsetSpace ~
21871 save.
21872 \newline
21873
21874 \end_layout
21875
21876 \begin_layout Itemize
21877
21878 \series bold
21879 callee_saves
21880 \series default
21881
21882 \begin_inset LatexCommand \index{\#pragma callee\_saves}
21883
21884 \end_inset
21885
21886
21887 \begin_inset LatexCommand \index{function prologue}
21888
21889 \end_inset
21890
21891  function1[,function2[,function3...]] 
21892 \begin_inset LatexCommand \label{ite:callee_saves-function1[,function2[,function3...]]--}
21893
21894 \end_inset
21895
21896 - The compiler by default uses a caller saves convention for register saving
21897  across function calls, however this can cause unnecessary register pushing
21898  and popping
21899 \begin_inset LatexCommand \index{push/pop}
21900
21901 \end_inset
21902
21903  when calling small functions from larger functions.
21904  This option can be used to switch off the register saving convention for
21905  the function names specified.
21906  The compiler will not save registers when calling these functions, extra
21907  code need to be manually inserted at the entry and exit for these functions
21908  to save and restore the registers used by these functions, this can SUBSTANTIAL
21909 LY reduce code and improve run time performance of the generated code.
21910  In the future the compiler (with inter procedural analysis) may be able
21911  to determine the appropriate scheme to use for each function call.
21912  If -
21913 \begin_inset ERT
21914 status collapsed
21915
21916 \begin_layout Standard
21917
21918
21919 \backslash
21920 /
21921 \end_layout
21922
21923 \end_inset
21924
21925 -callee-saves command line option is used (see page 
21926 \begin_inset LatexCommand \vpageref{lyx:--callee-saves-function1[,function2][,function3]...}
21927
21928 \end_inset
21929
21930 ), the function names specified in #pragma\InsetSpace ~
21931 callee_saves
21932 \begin_inset LatexCommand \index{\#pragma callee\_saves}
21933
21934 \end_inset
21935
21936  is appended to the list of functions specified in the command line.
21937 \end_layout
21938
21939 \begin_layout Itemize
21940
21941 \series bold
21942 exclude
21943 \series default
21944
21945 \begin_inset LatexCommand \index{\#pragma exclude}
21946
21947 \end_inset
21948
21949  none | {acc[,b[,dpl[,dph]]] - The exclude pragma disables the generation
21950  of pairs of push/pop
21951 \begin_inset LatexCommand \index{push/pop}
21952
21953 \end_inset
21954
21955  instructions in 
21956 \emph on
21957 I
21958 \emph default
21959 nterrupt
21960 \begin_inset LatexCommand \index{interrupt}
21961
21962 \end_inset
21963
21964  
21965 \emph on
21966 S
21967 \emph default
21968 ervice 
21969 \emph on
21970 R
21971 \emph default
21972 outines.
21973  The directive should be placed immediately before the ISR function definition
21974  and it affects ALL ISR functions following it.
21975  To enable the normal register saving for ISR functions use #pragma\InsetSpace ~
21976 exclude\InsetSpace ~
21977 none
21978 \begin_inset LatexCommand \index{\#pragma exclude}
21979
21980 \end_inset
21981
21982 .
21983  See also the related keyword _naked
21984 \begin_inset LatexCommand \index{\_naked}
21985
21986 \end_inset
21987
21988
21989 \begin_inset LatexCommand \index{\_\_naked}
21990
21991 \end_inset
21992
21993 .
21994 \end_layout
21995
21996 \begin_layout Itemize
21997
21998 \series bold
21999 less_pedantic
22000 \series default
22001
22002 \begin_inset LatexCommand \index{pedantic}
22003
22004 \end_inset
22005
22006
22007 \begin_inset LatexCommand \index{\#pragma less\_pedantic}
22008
22009 \end_inset
22010
22011  
22012 \begin_inset LatexCommand \label{ite:less_pedantic}
22013
22014 \end_inset
22015
22016 - the compiler will not warn you anymore for obvious mistakes, you're on
22017  your own now ;-( .
22018  See also the command line option -
22019 \begin_inset ERT
22020 status collapsed
22021
22022 \begin_layout Standard
22023
22024
22025 \backslash
22026 /
22027 \end_layout
22028
22029 \end_inset
22030
22031 -less-pedantic 
22032 \begin_inset LatexCommand \vpageref{lyx:--less-pedantic}
22033
22034 \end_inset
22035
22036 .
22037  
22038 \newline
22039 More specifically, the following warnings will be disabled: 
22040 \shape italic
22041 comparison is always [true/false] due to limited range of data type
22042 \shape default
22043  (94); 
22044 \shape italic
22045 overflow in implicit constant conversion
22046 \shape default
22047  (158); [the (in)famous] 
22048 \shape italic
22049 conditional flow changed by optimizer: so said EVELYN the modified DOG
22050 \shape default
22051  (110); 
22052 \shape italic
22053 function '[function name]' must return value
22054 \shape default
22055  (59).
22056  
22057 \newline
22058 Furthermore, warnings of less importance (of PEDANTIC and INFO warning
22059  level) are disabled, too, namely: 
22060 \shape italic
22061 constant value '[
22062 \begin_inset Note Note
22063 status collapsed
22064
22065 \begin_layout Standard
22066 dunno what comes here - this warning appears to be unused altogether
22067 \end_layout
22068
22069 \end_inset
22070
22071 ]', out of range
22072 \shape default
22073  (81); 
22074 \shape italic
22075 [left/right] shifting more than size of object changed to zero
22076 \shape default
22077  (116); 
22078 \shape italic
22079 unreachable code
22080 \shape default
22081  (126); 
22082 \shape italic
22083 integer overflow in expression
22084 \shape default
22085  (165); 
22086 \shape italic
22087 unmatched #pragma save and #pragma restore
22088 \shape default
22089  (170); 
22090 \shape italic
22091 comparison of 'signed char' with 'unsigned char' requires promotion to int
22092 \shape default
22093  (185); 
22094 \shape italic
22095 ISO C90 does not support flexible array members
22096 \shape default
22097  (187); 
22098 \shape italic
22099 extended stack by [number] bytes for compiler temp(s) :in function '[function\InsetSpace ~
22100 nam
22101 e]':\InsetSpace ~
22102 [
22103 \begin_inset Note Note
22104 status collapsed
22105
22106 \begin_layout Standard
22107 appears to be always blank - what was supposed to be here?
22108 \end_layout
22109
22110 \end_inset
22111
22112 ]
22113 \shape default
22114  (114); 
22115 \shape italic
22116 function '[function name]', # edges [number] , # nodes [number] , cyclomatic
22117  complexity [number]
22118 \shape default
22119  (121).
22120 \end_layout
22121
22122 \begin_layout Itemize
22123
22124 \series bold
22125 disable_warning
22126 \series default
22127  <nnnn>
22128 \begin_inset LatexCommand \index{\#pragma disable\_warning}
22129
22130 \end_inset
22131
22132  - the compiler will not warn you anymore about warning number <nnnn>.
22133 \end_layout
22134
22135 \begin_layout Itemize
22136
22137 \series bold
22138 nogcse
22139 \series default
22140
22141 \begin_inset LatexCommand \index{\#pragma nogcse}
22142
22143 \end_inset
22144
22145  - will stop global common subexpression elimination.
22146 \end_layout
22147
22148 \begin_layout Itemize
22149
22150 \series bold
22151 noinduction
22152 \series default
22153
22154 \begin_inset LatexCommand \index{\#pragma noinduction}
22155
22156 \end_inset
22157
22158  - will stop loop induction optimizations.
22159 \end_layout
22160
22161 \begin_layout Itemize
22162
22163 \series bold
22164 noinvariant
22165 \series default
22166
22167 \begin_inset LatexCommand \index{\#pragma noinvariant}
22168
22169 \end_inset
22170
22171  - will not do loop invariant optimizations.
22172  For more details see Loop Invariants in section
22173 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
22174
22175 \end_inset
22176
22177 .
22178 \end_layout
22179
22180 \begin_layout Itemize
22181
22182 \series bold
22183 noiv
22184 \series default
22185
22186 \begin_inset LatexCommand \index{\#pragma noiv}
22187
22188 \end_inset
22189
22190  - Do not generate interrupt
22191 \begin_inset LatexCommand \index{interrupt}
22192
22193 \end_inset
22194
22195  vector table
22196 \begin_inset LatexCommand \index{interrupt vector table}
22197
22198 \end_inset
22199
22200  entries for all ISR functions defined after the pragma.
22201  This is useful in cases where the interrupt vector table must be defined
22202  manually, or when there is a secondary, manually defined interrupt vector
22203  table (e.g.
22204  for the autovector feature of the Cypress EZ-USB FX2).
22205  More elegantly this can be achieved by obmitting the optional interrupt
22206  number after the interrupt keyword, see section 
22207 \begin_inset LatexCommand \ref{sub:Interrupt-Service-Routines}
22208
22209 \end_inset
22210
22211 \InsetSpace ~
22212 about interrupts.
22213 \end_layout
22214
22215 \begin_layout Itemize
22216
22217 \series bold
22218 nojtbound
22219 \series default
22220
22221 \begin_inset LatexCommand \index{\#pragma nojtbound}
22222
22223 \end_inset
22224
22225  - will not generate code for boundary value checking, when switch statements
22226  are turned into jump-tables (dangerous).
22227  For more details see section 
22228 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
22229
22230 \end_inset
22231
22232 .
22233 \end_layout
22234
22235 \begin_layout Itemize
22236
22237 \series bold
22238 noloopreverse
22239 \series default
22240
22241 \begin_inset LatexCommand \index{\#pragma noloopreverse}
22242
22243 \end_inset
22244
22245  - Will not do loop reversal optimization
22246 \end_layout
22247
22248 \begin_layout Itemize
22249
22250 \series bold
22251 nooverlay
22252 \series default
22253
22254 \begin_inset LatexCommand \index{\#pragma nooverlay}
22255
22256 \end_inset
22257
22258  - the compiler will not overlay the parameters and local variables of a
22259  function.
22260 \end_layout
22261
22262 \begin_layout Itemize
22263
22264 \series bold
22265 stackauto
22266 \series default
22267
22268 \begin_inset LatexCommand \index{\#pragma stackauto}
22269
22270 \end_inset
22271
22272 - See option -
22273 \begin_inset ERT
22274 status collapsed
22275
22276 \begin_layout Standard
22277
22278
22279 \backslash
22280 /
22281 \end_layout
22282
22283 \end_inset
22284
22285 -stack-auto
22286 \begin_inset LatexCommand \index{-\/-stack-auto}
22287
22288 \end_inset
22289
22290  and section 
22291 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
22292
22293 \end_inset
22294
22295  Parameters and Local Variables.
22296 \end_layout
22297
22298 \begin_layout Itemize
22299
22300 \series bold
22301 opt_code_speed
22302 \series default
22303  
22304 \begin_inset LatexCommand \index{\#pragma opt\_code\_speed}
22305
22306 \end_inset
22307
22308 - The compiler will optimize code generation towards fast code, possibly
22309  at the expense of code size.
22310  Currently this has little effect.
22311 \end_layout
22312
22313 \begin_layout Itemize
22314
22315 \series bold
22316 opt_code_size
22317 \series default
22318  
22319 \begin_inset LatexCommand \index{\#pragma opt\_code\_size}
22320
22321 \end_inset
22322
22323 - The compiler will optimize code generation towards compact code, possibly
22324  at the expense of code speed.
22325  Currently this has little effect.
22326 \end_layout
22327
22328 \begin_layout Itemize
22329
22330 \series bold
22331 opt_code_balanced
22332 \series default
22333  
22334 \begin_inset LatexCommand \index{\#pragma opt\_code\_balanced}
22335
22336 \end_inset
22337
22338 - The compiler will attempt to generate code that is both compact and fast,
22339  as long as meeting one goal is not a detriment to the other (this is the
22340  default).
22341  
22342 \end_layout
22343
22344 \begin_layout Itemize
22345
22346 \series bold
22347 std_sdcc89
22348 \series default
22349  
22350 \begin_inset LatexCommand \index{\#pragma std\_sdcc89}
22351
22352 \end_inset
22353
22354 - Generally follow the C89 standard, but allow SDCC features that conflict
22355  with the standard (default).
22356 \end_layout
22357
22358 \begin_layout Itemize
22359
22360 \series bold
22361 std_c89
22362 \series default
22363  
22364 \begin_inset LatexCommand \index{\#pragma std\_c89}
22365
22366 \end_inset
22367
22368 - Follow the C89 standard and disable SDCC features that conflict with the
22369  standard.
22370 \end_layout
22371
22372 \begin_layout Itemize
22373
22374 \series bold
22375 std_sdcc99
22376 \series default
22377  
22378 \begin_inset LatexCommand \index{\#pragma std\_sdcc99}
22379
22380 \end_inset
22381
22382 - Generally follow the C99 standard, but allow SDCC features that conflict
22383  with the standard (incomplete support).
22384 \end_layout
22385
22386 \begin_layout Itemize
22387
22388 \series bold
22389 std_c99
22390 \series default
22391  
22392 \begin_inset LatexCommand \index{\#pragma std\_c99}
22393
22394 \end_inset
22395
22396 - Follow the C99 standard and disable SDCC features that conflict with the
22397  standard (incomplete support).
22398 \end_layout
22399
22400 \begin_layout Itemize
22401
22402 \series bold
22403 codeseg
22404 \series default
22405  <name>
22406 \begin_inset LatexCommand \index{\#pragma codeseg}
22407
22408 \end_inset
22409
22410 - Use this name (max.
22411  8 characters) for the code segment.
22412  See option -
22413 \begin_inset ERT
22414 status collapsed
22415
22416 \begin_layout Standard
22417
22418
22419 \backslash
22420 /
22421 \end_layout
22422
22423 \end_inset
22424
22425 -codeseg.
22426 \end_layout
22427
22428 \begin_layout Itemize
22429
22430 \series bold
22431 constseg
22432 \series default
22433  <name>
22434 \begin_inset LatexCommand \index{\#pragma constseg}
22435
22436 \end_inset
22437
22438 - Use this name (max.
22439  8 characters) for the const segment.
22440  See option -
22441 \begin_inset ERT
22442 status collapsed
22443
22444 \begin_layout Standard
22445
22446
22447 \backslash
22448 /
22449 \end_layout
22450
22451 \end_inset
22452
22453 -constseg.
22454 \end_layout
22455
22456 \begin_layout Standard
22457 The preprocessor SDCPP
22458 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
22459
22460 \end_inset
22461
22462  supports the following #pragma directives:
22463 \end_layout
22464
22465 \begin_layout Itemize
22466
22467 \series bold
22468 pedantic_parse_number
22469 \series default
22470
22471 \begin_inset LatexCommand \index{pedantic}
22472
22473 \end_inset
22474
22475
22476 \begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
22477
22478 \end_inset
22479
22480  (+ | -) 
22481 \begin_inset LatexCommand \label{ite:pedantic_parse_number}
22482
22483 \end_inset
22484
22485 - Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed
22486  properly and the macro LO_B(3) gets expanded.
22487  Default is off.
22488  See also the -
22489 \begin_inset ERT
22490 status collapsed
22491
22492 \begin_layout Standard
22493
22494
22495 \backslash
22496 /
22497 \end_layout
22498
22499 \end_inset
22500
22501 -pedantic-parse-number command line option 
22502 \begin_inset LatexCommand \vpageref{lyx:-pedantic-parse-number}
22503
22504 \end_inset
22505
22506 .
22507  
22508 \newline
22509 Below is an example on how to use this pragma.
22510
22511 \emph on
22512  Note: this functionality is not in conformance with standard!
22513 \end_layout
22514
22515 \begin_layout Verse
22516
22517 \family typewriter
22518 #pragma pedantic_parse_number +
22519 \begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
22520
22521 \end_inset
22522
22523
22524 \newline
22525
22526 \newline
22527 #define LO_B(x) ((x) & 0xff)
22528 \newline
22529
22530 \newline
22531 unsigned char foo(void)
22532 \newline
22533 {
22534 \newline
22535 \InsetSpace ~
22536 \InsetSpace ~
22537 \InsetSpace ~
22538 unsigned char c=0xfe-LO_B(3)
22539 ;
22540 \newline
22541
22542 \newline
22543 \InsetSpace ~
22544 \InsetSpace ~
22545 \InsetSpace ~
22546 return c;
22547 \newline
22548 }
22549 \newline
22550
22551 \end_layout
22552
22553 \begin_layout Itemize
22554
22555 \series bold
22556 preproc_asm
22557 \series default
22558
22559 \begin_inset LatexCommand \index{\#pragma preproc\_asm}
22560
22561 \end_inset
22562
22563  (+ | -) - switch _asm _endasm block preprocessing on / off.
22564  Default is on.
22565  You use this prama to define multilines of assembly code.
22566  This will prevent the preprocessor from changing the formating required
22567  by assembly code.
22568  Below is an example on how to use this pragma.
22569 \end_layout
22570
22571 \begin_layout Verse
22572
22573 \family typewriter
22574 #pragma preproc_asm -
22575 \begin_inset LatexCommand \index{\#pragma preproc\_asm}
22576
22577 \end_inset
22578
22579
22580 \newline
22581 #define MYDELAY _asm
22582 \newline
22583 \InsetSpace ~
22584 \InsetSpace ~
22585 \InsetSpace ~
22586 nop ;my assembly comment...
22587 \newline
22588 \InsetSpace ~
22589 \InsetSpace ~
22590 \InsetSpace ~
22591 nop
22592 \newline
22593 \InsetSpace ~
22594 \InsetSpace ~
22595 \InsetSpace ~
22596 nop
22597 \newline
22598 _endasm
22599 \newline
22600 #pragma preproc_asm
22601  +
22602 \newline
22603
22604 \newline
22605 void foo (void) 
22606 \newline
22607
22608 \newline
22609 \InsetSpace ~
22610 \InsetSpace ~
22611 \InsetSpace ~
22612  ...
22613  
22614 \newline
22615 \InsetSpace ~
22616 \InsetSpace ~
22617 \InsetSpace ~
22618  MYDELAY;
22619 \newline
22620 \InsetSpace ~
22621 \InsetSpace ~
22622 \InsetSpace ~
22623  ...
22624  
22625 \newline
22626
22627 \newline
22628
22629 \end_layout
22630
22631 \begin_layout Itemize
22632
22633 \series bold
22634 sdcc_hash
22635 \series default
22636
22637 \begin_inset LatexCommand \index{\#pragma sdcc\_hash}
22638
22639 \end_inset
22640
22641  (+ | -) - Allow "naked" hash in macro definition, for example:
22642 \newline
22643
22644 \family typewriter
22645 #define DIR_LO(x) #(x & 0xff)
22646 \family default
22647
22648 \newline
22649 Default is off.
22650  Below is an example on how to use this pragma.
22651 \end_layout
22652
22653 \begin_layout Verse
22654
22655 \family typewriter
22656 #pragma preproc_asm +
22657 \newline
22658 #pragma sdcc_hash +
22659 \begin_inset LatexCommand \index{\#pragma sdcc\_hash}
22660
22661 \end_inset
22662
22663
22664 \newline
22665
22666 \newline
22667 #define ROMCALL(x) 
22668 \backslash
22669
22670 \newline
22671 \InsetSpace ~
22672 \InsetSpace ~
22673 \InsetSpace ~
22674 mov R6_B3, #(x & 0xff) 
22675 \backslash
22676
22677 \newline
22678 \InsetSpace ~
22679 \InsetSpace ~
22680 \InsetSpace ~
22681 mov R7_B3, #((x >> 8) & 0xff) 
22682 \backslash
22683
22684 \newline
22685 \InsetSpace ~
22686 \InsetSpace ~
22687 \InsetSpace ~
22688 lcall __romcall
22689 \newline
22690
22691 \newline
22692 ...
22693 \newline
22694 _asm
22695 \newline
22696 ROMCALL(72)
22697 \newline
22698 _endasm;
22699 \newline
22700 ...
22701 \newline
22702
22703 \end_layout
22704
22705 \begin_layout Standard
22706 Some of the pragmas are intended to be used to turn-on or off certain optimizati
22707 ons which might cause the compiler to generate extra stack and/or data space
22708  to store compiler generated temporary variables.
22709  This usually happens in large functions.
22710  Pragma directives should be used as shown in the following example, they
22711  are used to control options and optimizations for a given function.
22712  
22713 \end_layout
22714
22715 \begin_layout Verse
22716
22717 \family typewriter
22718 #pragma save
22719 \begin_inset LatexCommand \index{\#pragma save}
22720
22721 \end_inset
22722
22723  \InsetSpace ~
22724 \InsetSpace ~
22725 \InsetSpace ~
22726 \InsetSpace ~
22727 \InsetSpace ~
22728 \InsetSpace ~
22729 \InsetSpace ~
22730 /* save the current settings */ 
22731 \newline
22732 #pragma nogcse
22733 \begin_inset LatexCommand \index{\#pragma nogcse}
22734
22735 \end_inset
22736
22737  \InsetSpace ~
22738 \InsetSpace ~
22739 \InsetSpace ~
22740 \InsetSpace ~
22741 \InsetSpace ~
22742 /* turnoff global subexpression elimination */ 
22743 \newline
22744 #pragma noinduction
22745 \begin_inset LatexCommand \index{\#pragma noinduction}
22746
22747 \end_inset
22748
22749  /* turn off induction optimizations */ 
22750 \newline
22751 int foo () 
22752 \newline
22753
22754 \newline
22755 \InsetSpace ~
22756  \InsetSpace ~
22757  ...
22758  
22759 \newline
22760 \InsetSpace ~
22761  \InsetSpace ~
22762  /* large code */ 
22763 \newline
22764 \InsetSpace ~
22765  \InsetSpace ~
22766  ...
22767  
22768 \newline
22769
22770 \newline
22771 #pragma restore
22772 \begin_inset LatexCommand \index{\#pragma restore}
22773
22774 \end_inset
22775
22776  /* turn the optimizations back on */
22777 \end_layout
22778
22779 \begin_layout Standard
22780 The compiler will generate a warning message when extra space is allocated.
22781  It is strongly recommended that the save and restore pragmas be used when
22782  changing options for a function.
22783 \newline
22784
22785 \newline
22786
22787 \newline
22788
22789 \end_layout
22790
22791 \begin_layout Section
22792 Defines Created by the Compiler
22793 \end_layout
22794
22795 \begin_layout Standard
22796 The compiler creates the following #defines
22797 \begin_inset LatexCommand \index{\#defines}
22798
22799 \end_inset
22800
22801
22802 \begin_inset LatexCommand \index{Defines created by the compiler}
22803
22804 \end_inset
22805
22806 :
22807 \newline
22808
22809 \end_layout
22810
22811 \begin_layout Standard
22812 \begin_inset Tabular
22813 <lyxtabular version="3" rows="15" columns="2">
22814 <features>
22815 <column alignment="left" valignment="top" leftline="true" width="3in">
22816 <column alignment="left" valignment="top" leftline="true" rightline="true" width="3in">
22817 <row topline="true" bottomline="true">
22818 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22819 \begin_inset Text
22820
22821 \begin_layout Standard
22822
22823 \series bold
22824 #define
22825 \end_layout
22826
22827 \end_inset
22828 </cell>
22829 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22830 \begin_inset Text
22831
22832 \begin_layout Standard
22833
22834 \series bold
22835 Description
22836 \end_layout
22837
22838 \end_inset
22839 </cell>
22840 </row>
22841 <row topline="true">
22842 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22843 \begin_inset Text
22844
22845 \begin_layout Standard
22846 SDCC
22847 \begin_inset LatexCommand \index{SDCC}
22848
22849 \end_inset
22850
22851  
22852 \end_layout
22853
22854 \end_inset
22855 </cell>
22856 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22857 \begin_inset Text
22858
22859 \begin_layout Standard
22860 Always defined.
22861  Since version 2.5.6 the version number as an int (ex.
22862  256)
22863 \end_layout
22864
22865 \end_inset
22866 </cell>
22867 </row>
22868 <row topline="true">
22869 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22870 \begin_inset Text
22871
22872 \begin_layout Standard
22873 SDCC_mcs51
22874 \begin_inset LatexCommand \index{SDCC\_mcs51}
22875
22876 \end_inset
22877
22878  or SDCC_ds390
22879 \begin_inset LatexCommand \index{SDCC\_ds390}
22880
22881 \end_inset
22882
22883  or SDCC_z80
22884 \begin_inset LatexCommand \index{SDCC\_z80}
22885
22886 \end_inset
22887
22888 , etc.
22889 \end_layout
22890
22891 \end_inset
22892 </cell>
22893 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22894 \begin_inset Text
22895
22896 \begin_layout Standard
22897 depending on the model used (e.g.: -mds390)
22898 \end_layout
22899
22900 \end_inset
22901 </cell>
22902 </row>
22903 <row topline="true">
22904 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22905 \begin_inset Text
22906
22907 \begin_layout Standard
22908 __mcs51
22909 \begin_inset LatexCommand \index{\_\_mcs51}
22910
22911 \end_inset
22912
22913 , __ds390
22914 \begin_inset LatexCommand \index{\_\_ds390}
22915
22916 \end_inset
22917
22918 , __hc08
22919 \begin_inset LatexCommand \index{\_\_hc08}
22920
22921 \end_inset
22922
22923 , __z80
22924 \begin_inset LatexCommand \index{\_\_z80}
22925
22926 \end_inset
22927
22928 , etc
22929 \end_layout
22930
22931 \end_inset
22932 </cell>
22933 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22934 \begin_inset Text
22935
22936 \begin_layout Standard
22937 depending on the model used (e.g.
22938  -mz80)
22939 \end_layout
22940
22941 \end_inset
22942 </cell>
22943 </row>
22944 <row topline="true">
22945 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22946 \begin_inset Text
22947
22948 \begin_layout Standard
22949 SDCC_STACK_AUTO
22950 \begin_inset LatexCommand \index{SDCC\_STACK\_AUTO}
22951
22952 \end_inset
22953
22954
22955 \end_layout
22956
22957 \end_inset
22958 </cell>
22959 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22960 \begin_inset Text
22961
22962 \begin_layout Standard
22963 when 
22964 \emph on
22965 -
22966 \begin_inset ERT
22967 status collapsed
22968
22969 \begin_layout Standard
22970
22971
22972 \backslash
22973 /
22974 \end_layout
22975
22976 \end_inset
22977
22978 -stack-auto
22979 \emph default
22980  option is used
22981 \end_layout
22982
22983 \end_inset
22984 </cell>
22985 </row>
22986 <row topline="true">
22987 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22988 \begin_inset Text
22989
22990 \begin_layout Standard
22991 SDCC_MODEL_SMALL
22992 \begin_inset LatexCommand \index{SDCC\_MODEL\_SMALL}
22993
22994 \end_inset
22995
22996
22997 \end_layout
22998
22999 \end_inset
23000 </cell>
23001 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23002 \begin_inset Text
23003
23004 \begin_layout Standard
23005 when 
23006 \emph on
23007 -
23008 \begin_inset ERT
23009 status collapsed
23010
23011 \begin_layout Standard
23012
23013
23014 \backslash
23015 /
23016 \end_layout
23017
23018 \end_inset
23019
23020 -model-small
23021 \emph default
23022  is used
23023 \end_layout
23024
23025 \end_inset
23026 </cell>
23027 </row>
23028 <row topline="true">
23029 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23030 \begin_inset Text
23031
23032 \begin_layout Standard
23033 SDCC_MODEL_MEDIUM
23034 \begin_inset LatexCommand \index{SDCC\_MODEL\_MEDIUM}
23035
23036 \end_inset
23037
23038
23039 \end_layout
23040
23041 \end_inset
23042 </cell>
23043 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23044 \begin_inset Text
23045
23046 \begin_layout Standard
23047 when 
23048 \emph on
23049 -
23050 \begin_inset ERT
23051 status collapsed
23052
23053 \begin_layout Standard
23054
23055
23056 \backslash
23057 /
23058 \end_layout
23059
23060 \end_inset
23061
23062 -model-medium
23063 \emph default
23064  is used
23065 \end_layout
23066
23067 \end_inset
23068 </cell>
23069 </row>
23070 <row topline="true">
23071 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23072 \begin_inset Text
23073
23074 \begin_layout Standard
23075 SDCC_MODEL_LARGE
23076 \begin_inset LatexCommand \index{SDCC\_MODEL\_LARGE}
23077
23078 \end_inset
23079
23080
23081 \end_layout
23082
23083 \end_inset
23084 </cell>
23085 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23086 \begin_inset Text
23087
23088 \begin_layout Standard
23089 when 
23090 \emph on
23091 -
23092 \begin_inset ERT
23093 status collapsed
23094
23095 \begin_layout Standard
23096
23097
23098 \backslash
23099 /
23100 \end_layout
23101
23102 \end_inset
23103
23104 -model-large
23105 \emph default
23106  is used
23107 \end_layout
23108
23109 \end_inset
23110 </cell>
23111 </row>
23112 <row topline="true">
23113 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23114 \begin_inset Text
23115
23116 \begin_layout Standard
23117 SDCC_USE_XSTACK
23118 \begin_inset LatexCommand \index{SDCC\_USE\_XSTACK}
23119
23120 \end_inset
23121
23122
23123 \end_layout
23124
23125 \end_inset
23126 </cell>
23127 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23128 \begin_inset Text
23129
23130 \begin_layout Standard
23131 when 
23132 \emph on
23133 -
23134 \begin_inset ERT
23135 status collapsed
23136
23137 \begin_layout Standard
23138
23139
23140 \backslash
23141 /
23142 \end_layout
23143
23144 \end_inset
23145
23146 -xstack
23147 \emph default
23148  option is used
23149 \end_layout
23150
23151 \end_inset
23152 </cell>
23153 </row>
23154 <row topline="true">
23155 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23156 \begin_inset Text
23157
23158 \begin_layout Standard
23159 SDCC_STACK_TENBIT
23160 \begin_inset LatexCommand \index{SDCC\_STACK\_TENBIT}
23161
23162 \end_inset
23163
23164  
23165 \end_layout
23166
23167 \end_inset
23168 </cell>
23169 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23170 \begin_inset Text
23171
23172 \begin_layout Standard
23173 when 
23174 \emph on
23175 -mds390
23176 \emph default
23177  is used
23178 \end_layout
23179
23180 \end_inset
23181 </cell>
23182 </row>
23183 <row topline="true">
23184 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23185 \begin_inset Text
23186
23187 \begin_layout Standard
23188 SDCC_MODEL_FLAT24
23189 \begin_inset LatexCommand \index{SDCC\_MODEL\_FLAT24}
23190
23191 \end_inset
23192
23193
23194 \end_layout
23195
23196 \end_inset
23197 </cell>
23198 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23199 \begin_inset Text
23200
23201 \begin_layout Standard
23202 when 
23203 \emph on
23204 -mds390
23205 \emph default
23206  is used
23207 \end_layout
23208
23209 \end_inset
23210 </cell>
23211 </row>
23212 <row topline="true">
23213 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23214 \begin_inset Text
23215
23216 \begin_layout Standard
23217 SDCC_REVISION
23218 \begin_inset LatexCommand \index{SDCC\_REVISION}
23219
23220 \end_inset
23221
23222
23223 \end_layout
23224
23225 \end_inset
23226 </cell>
23227 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23228 \begin_inset Text
23229
23230 \begin_layout Standard
23231 Always defined.
23232  SDCC svn revision number
23233 \end_layout
23234
23235 \end_inset
23236 </cell>
23237 </row>
23238 <row topline="true">
23239 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23240 \begin_inset Text
23241
23242 \begin_layout Standard
23243 SDCC_PARMS_IN_BANK1
23244 \begin_inset LatexCommand \index{SDCC\_PARMS\_IN\_BANK1}
23245
23246 \end_inset
23247
23248
23249 \end_layout
23250
23251 \end_inset
23252 </cell>
23253 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23254 \begin_inset Text
23255
23256 \begin_layout Standard
23257 when 
23258 \emph on
23259 -
23260 \begin_inset ERT
23261 status collapsed
23262
23263 \begin_layout Standard
23264
23265
23266 \backslash
23267 /
23268 \end_layout
23269
23270 \end_inset
23271
23272 -parms-in-bank1
23273 \emph default
23274  is used
23275 \end_layout
23276
23277 \end_inset
23278 </cell>
23279 </row>
23280 <row topline="true">
23281 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23282 \begin_inset Text
23283
23284 \begin_layout Standard
23285 SDCC_FLOAT_REENT
23286 \begin_inset LatexCommand \index{SDCC\_MODEL\_FLAT24}
23287
23288 \end_inset
23289
23290
23291 \end_layout
23292
23293 \end_inset
23294 </cell>
23295 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23296 \begin_inset Text
23297
23298 \begin_layout Standard
23299 when 
23300 \emph on
23301 -
23302 \begin_inset ERT
23303 status collapsed
23304
23305 \begin_layout Standard
23306
23307
23308 \backslash
23309 /
23310 \end_layout
23311
23312 \end_inset
23313
23314 -float-reent
23315 \emph default
23316  is used
23317 \end_layout
23318
23319 \end_inset
23320 </cell>
23321 </row>
23322 <row topline="true" bottomline="true">
23323 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23324 \begin_inset Text
23325
23326 \begin_layout Standard
23327 SDCC_INT_LONG_REENT
23328 \begin_inset LatexCommand \index{SDCC\_INT\_LONG\_REENT}
23329
23330 \end_inset
23331
23332
23333 \end_layout
23334
23335 \end_inset
23336 </cell>
23337 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23338 \begin_inset Text
23339
23340 \begin_layout Standard
23341 when 
23342 \emph on
23343 -
23344 \begin_inset ERT
23345 status collapsed
23346
23347 \begin_layout Standard
23348
23349
23350 \backslash
23351 /
23352 \end_layout
23353
23354 \end_inset
23355
23356 -int-long-reent
23357 \emph default
23358  is used
23359 \end_layout
23360
23361 \end_inset
23362 </cell>
23363 </row>
23364 </lyxtabular>
23365
23366 \end_inset
23367
23368
23369 \end_layout
23370
23371 \begin_layout Chapter
23372 Notes on supported Processors
23373 \end_layout
23374
23375 \begin_layout Section
23376 MCS51 variants
23377 \begin_inset LatexCommand \label{sub:MCS51-variants}
23378
23379 \end_inset
23380
23381
23382 \begin_inset LatexCommand \index{MCS51 variants}
23383
23384 \end_inset
23385
23386
23387 \end_layout
23388
23389 \begin_layout Standard
23390 MCS51 processors are available from many vendors and come in many different
23391  flavours.
23392  While they might differ considerably in respect to Special Function Registers
23393  the core MCS51 is usually not modified or is kept compatible.
23394  
23395 \end_layout
23396
23397 \begin_layout Subsection
23398 pdata access by SFR 
23399 \end_layout
23400
23401 \begin_layout Standard
23402 With the upcome of devices with internal xdata and flash memory devices
23403  using port P2
23404 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
23405
23406 \end_inset
23407
23408  as dedicated I/O port is becoming more popular.
23409  Switching the high byte for pdata
23410 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
23411
23412 \end_inset
23413
23414  access which was formerly done by port P2 is then achieved by a Special
23415  Function Register
23416 \begin_inset LatexCommand \index{sfr}
23417
23418 \end_inset
23419
23420 .
23421  In well-established MCS51 tradition the address of this 
23422 \emph on
23423 sfr
23424 \emph default
23425  is where the chip designers decided to put it.
23426  Needless to say that they didn't agree on a common name either.
23427  So that the startup code can correctly initialize xdata variables, you
23428  should define an sfr with the name _XPAGE
23429 \family typewriter
23430
23431 \begin_inset LatexCommand \index{\_XPAGE (mcs51)}
23432
23433 \end_inset
23434
23435
23436 \family default
23437  at the appropriate location if the default, port P2, is not used for this.
23438  Some examples are:
23439 \end_layout
23440
23441 \begin_layout Verse
23442
23443 \family typewriter
23444 __sfr __at (0x85) _XPAGE; /* Ramtron VRS51 family a.k.a.
23445  MPAGE */
23446 \end_layout
23447
23448 \begin_layout Verse
23449
23450 \family typewriter
23451 __sfr __at (0x92) _XPAGE; /* Cypress EZ-USB family, Texas Instruments (Chipcon)
23452  a.k.a.
23453  MPAGE */
23454 \end_layout
23455
23456 \begin_layout Verse
23457
23458 \family typewriter
23459 __sfr __at (0x91) _XPAGE; /* Infineon (Siemens) C500 family a.k.a.
23460  XPAGE */
23461 \end_layout
23462
23463 \begin_layout Verse
23464
23465 \family typewriter
23466 __sfr __at (0xaf) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
23467  EMI0CN */
23468 \end_layout
23469
23470 \begin_layout Verse
23471
23472 \family typewriter
23473 __sfr __at (0xaa) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
23474  EMI0CN */
23475 \end_layout
23476
23477 \begin_layout Standard
23478 For more exotic implementations further customizations may be needed.
23479  See section 
23480 \begin_inset LatexCommand \ref{sub:Startup-Code}
23481
23482 \end_inset
23483
23484  for other possibilities.
23485 \end_layout
23486
23487 \begin_layout Subsection
23488 Other Features available by SFR
23489 \end_layout
23490
23491 \begin_layout Standard
23492 Some MCS51 variants offer features like Double DPTR
23493 \begin_inset LatexCommand \index{DPTR}
23494
23495 \end_inset
23496
23497 , multiple DPTR, decrementing DPTR, 16x16 Multiply.
23498  These are currently not used for the MCS51 port.
23499  If you absolutely need them you can fall back to inline assembly or submit
23500  a patch to SDCC.
23501 \end_layout
23502
23503 \begin_layout Subsection
23504 Bankswitching
23505 \end_layout
23506
23507 \begin_layout Standard
23508 Bankswitching
23509 \begin_inset LatexCommand \index{Bankswitching}
23510
23511 \end_inset
23512
23513  (a.k.a.
23514  code banking
23515 \begin_inset LatexCommand \index{code banking}
23516
23517 \end_inset
23518
23519 ) is a technique to increase the code space above the 64k limit of the 8051.
23520 \end_layout
23521
23522 \begin_layout Subsubsection
23523 Hardware
23524 \end_layout
23525
23526 \begin_layout Standard
23527 \begin_inset Tabular
23528 <lyxtabular version="3" rows="3" columns="4">
23529 <features>
23530 <column alignment="center" valignment="top" width="0">
23531 <column alignment="center" valignment="top" leftline="true" width="0">
23532 <column alignment="center" valignment="top" leftline="true" width="0">
23533 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
23534 <row topline="true" bottomline="true">
23535 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
23536 \begin_inset Text
23537
23538 \begin_layout Standard
23539 8000-FFFF
23540 \end_layout
23541
23542 \end_inset
23543 </cell>
23544 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23545 \begin_inset Text
23546
23547 \begin_layout Standard
23548 bank1
23549 \end_layout
23550
23551 \end_inset
23552 </cell>
23553 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23554 \begin_inset Text
23555
23556 \begin_layout Standard
23557 bank2
23558 \end_layout
23559
23560 \end_inset
23561 </cell>
23562 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23563 \begin_inset Text
23564
23565 \begin_layout Standard
23566 bank3
23567 \end_layout
23568
23569 \end_inset
23570 </cell>
23571 </row>
23572 <row topline="true" bottomline="true">
23573 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
23574 \begin_inset Text
23575
23576 \begin_layout Standard
23577 0000-7FFF
23578 \end_layout
23579
23580 \end_inset
23581 </cell>
23582 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23583 \begin_inset Text
23584
23585 \begin_layout Standard
23586 common
23587 \end_layout
23588
23589 \end_inset
23590 </cell>
23591 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
23592 \begin_inset Text
23593
23594 \begin_layout Standard
23595
23596 \end_layout
23597
23598 \end_inset
23599 </cell>
23600 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23601 \begin_inset Text
23602
23603 \begin_layout Standard
23604
23605 \end_layout
23606
23607 \end_inset
23608 </cell>
23609 </row>
23610 <row>
23611 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
23612 \begin_inset Text
23613
23614 \begin_layout Standard
23615 SiLabs C8051F120 example
23616 \end_layout
23617
23618 \end_inset
23619 </cell>
23620 <cell multicolumn="2" alignment="center" valignment="top" usebox="none">
23621 \begin_inset Text
23622
23623 \begin_layout Standard
23624
23625 \end_layout
23626
23627 \end_inset
23628 </cell>
23629 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23630 \begin_inset Text
23631
23632 \begin_layout Standard
23633
23634 \end_layout
23635
23636 \end_inset
23637 </cell>
23638 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23639 \begin_inset Text
23640
23641 \begin_layout Standard
23642
23643 \end_layout
23644
23645 \end_inset
23646 </cell>
23647 </row>
23648 </lyxtabular>
23649
23650 \end_inset
23651
23652
23653 \newline
23654
23655 \newline
23656 Usually the hardware uses some sfr (an output port or an internal sfr) to
23657  select a bank and put it in the banked area of the memory map.
23658  The selected bank usually becomes active immediately upon assignment to
23659  this sfr and when running inside a bank it will switch out this code it
23660  is currently running.
23661  Therefor you cannot jump or call directly from one bank to another and
23662  need to use a so-called trampoline in the common area.
23663  For SDCC an example trampoline is in crtbank.asm and you may need to change
23664  it to your 8051 derivative or schematic.
23665  The presented code is written for the C8051F120.
23666 \newline
23667
23668 \newline
23669 When calling a banked function
23670  SDCC will put the LSB of the functions address in register R0, the MSB
23671  in R1 and the bank in R2 and then call this trampoline 
23672 \emph on
23673 __sdcc_banked_call
23674 \emph default
23675 .
23676  The current selected bank is saved on the stack, the new bank is selected
23677  and an indirect jump is made.
23678  When the banked function returns it jumps to 
23679 \emph on
23680 __sdcc_banked_ret
23681 \emph default
23682  which restores the previous bank and returns to the caller.
23683 \end_layout
23684
23685 \begin_layout Subsubsection
23686 Software
23687 \end_layout
23688
23689 \begin_layout Standard
23690 When writing banked software using SDCC you need to use some special keywords
23691  and options.
23692  You also need to take over a bit of work from the linker.
23693 \newline
23694
23695 \newline
23696 To create a function
23697  that can be called from another bank it requires the keyword 
23698 \emph on
23699 banked
23700 \emph default
23701
23702 \begin_inset LatexCommand \index{banked}
23703
23704 \end_inset
23705
23706 .
23707  The caller must see this in the prototype of the callee and the callee
23708  needs it for a proper return.
23709  Called functions within the same bank as the caller do not need the 
23710 \emph on
23711 banked
23712 \emph default
23713  keyword nor do functions in the common area.
23714  Beware: SDCC does not know or check if functions are in the same bank.
23715  This is your responsibility!
23716 \newline
23717
23718 \newline
23719 Normally all functions you write end up in
23720  the segment CSEG.
23721  If you want a function explicitly to reside in the common area put it in
23722  segment HOME.
23723  This applies for instance to interrupt service routines as they should
23724  not be banked.
23725 \end_layout
23726
23727 \begin_layout Standard
23728 Functions that need to be in a switched bank must be put in a named segment.
23729  The name can be mostly anything upto eight characters (e.g.
23730  BANK1).
23731  To do this you either use -
23732 \begin_inset ERT
23733 status collapsed
23734
23735 \begin_layout Standard
23736
23737
23738 \backslash
23739 /
23740 \end_layout
23741
23742 \end_inset
23743
23744 -codeseg BANK1 (See 
23745 \begin_inset LatexCommand \ref{lyx:-codeseg}
23746
23747 \end_inset
23748
23749 ) on the command line when compiling or #pragma codeseg BANK1 (See 
23750 \begin_inset LatexCommand \ref{sec:Pragmas}
23751
23752 \end_inset
23753
23754 ) at the top of the C source file.
23755  The segment name always applies to the whole source file and generated
23756  object so functions for different banks need to be defined in different
23757  source files.
23758 \newline
23759
23760 \newline
23761 When linking your objects you need to tell the linker where
23762  to put your segments.
23763  To do this you use the following command line option to SDCC: -Wl-b BANK1=0x180
23764 00 (See 
23765 \begin_inset LatexCommand \ref{lyx:-Wl option}
23766
23767 \end_inset
23768
23769 ).
23770  This sets the virtual start address of this segment.
23771  It sets the banknumber to 0x01 and maps the bank to 0x8000 and up.
23772  The linker will not check for overflows, again this is your responsibility.
23773 \end_layout
23774
23775 \begin_layout Standard
23776 \begin_inset VSpace bigskip
23777 \end_inset
23778
23779
23780 \end_layout
23781
23782 \begin_layout Section
23783 DS400 port
23784 \end_layout
23785
23786 \begin_layout Standard
23787 The DS80C400
23788 \begin_inset LatexCommand \index{DS80C400}
23789
23790 \end_inset
23791
23792
23793 \begin_inset LatexCommand \index{DS400}
23794
23795 \end_inset
23796
23797  microcontroller has a rich set of peripherals.
23798  In its built-in ROM library it includes functions to access some of the
23799  features, among them is a TCP stack with IP4 and IP6 support.
23800  Library headers (currently in beta status) and other files are provided
23801  at 
23802 \size footnotesize
23803
23804 \begin_inset LatexCommand \url{ftp://ftp.dalsemi.com/pub/tini/ds80c400/c_libraries/sdcc/index.html}
23805
23806 \end_inset
23807
23808 .
23809  
23810 \begin_inset VSpace bigskip
23811 \end_inset
23812
23813
23814 \end_layout
23815
23816 \begin_layout Section
23817 The Z80 and gbz80 port
23818 \end_layout
23819
23820 \begin_layout Standard
23821 SDCC can target both the Zilog Z80
23822 \begin_inset LatexCommand \index{Z80}
23823
23824 \end_inset
23825
23826  and the Nintendo Gameboy's Z80-like gbz80
23827 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
23828
23829 \end_inset
23830
23831 .
23832  The Z80 port is passed through the same 
23833 \emph on
23834 regressions tests
23835 \begin_inset LatexCommand \index{Regression test}
23836
23837 \end_inset
23838
23839
23840 \emph default
23841  (see section 
23842 \begin_inset LatexCommand \ref{sec:Quality-control}
23843
23844 \end_inset
23845
23846 ) as the MCS51 and DS390 ports, so floating point support, support for long
23847  variables and bitfield support is fine.
23848  See mailing lists and forums about interrupt routines.
23849 \end_layout
23850
23851 \begin_layout Standard
23852 As always, the code is the authoritative reference - see z80/ralloc.c and
23853  z80/gen.c.
23854  The stack
23855 \begin_inset LatexCommand \index{Z80!stack}
23856
23857 \end_inset
23858
23859  frame is similar to that generated by the IAR Z80 compiler.
23860  IX is used as the base pointer, HL and IY are used as a temporary registers,
23861  and BC and DE are available for holding variables.
23862  Return values
23863 \begin_inset LatexCommand \index{Z80!return value}
23864
23865 \end_inset
23866
23867  for the Z80 port are stored in L (one byte), HL (two bytes), or DEHL (four
23868  bytes).
23869  The gbz80 port use the same set of registers for the return values, but
23870  in a different order of significance: E (one byte), DE (two bytes), or
23871  HLDE (four bytes).
23872 \begin_inset VSpace bigskip
23873 \end_inset
23874
23875
23876 \end_layout
23877
23878 \begin_layout Section
23879 The HC08 port
23880 \end_layout
23881
23882 \begin_layout Standard
23883 The port to the Freescale/Motorola HC08
23884 \begin_inset LatexCommand \index{HC08}
23885
23886 \end_inset
23887
23888  family has been added in October 2003, and is still undergoing some basic
23889  development.
23890  The code generator is complete, but the register allocation is still quite
23891  unoptimized.
23892  Some of the SDCC's standard C library functions have embedded non-HC08
23893  inline assembly and so are not yet usable.
23894 \end_layout
23895
23896 \begin_layout Standard
23897 The HC08 port passes the regression test suite (see section 
23898 \begin_inset LatexCommand \ref{sec:Quality-control}
23899
23900 \end_inset
23901
23902 ).
23903 \begin_inset VSpace bigskip
23904 \end_inset
23905
23906
23907 \end_layout
23908
23909 \begin_layout Section
23910 The PIC14
23911 \begin_inset LatexCommand \index{PIC14}
23912
23913 \end_inset
23914
23915  port
23916 \end_layout
23917
23918 \begin_layout Standard
23919 The PIC14 port adds support for Microchip
23920 \begin_inset LatexCommand \index{Microchip}
23921
23922 \end_inset
23923
23924
23925 \begin_inset Formula $^{\text{TM}}$
23926 \end_inset
23927
23928  PIC
23929 \begin_inset LatexCommand \index{PIC14}
23930
23931 \end_inset
23932
23933
23934 \begin_inset Formula $^{\text{TM}}$
23935 \end_inset
23936
23937  MCUs with 14 bit wide instructions.
23938  This port is not yet mature and still lacks many features.
23939  However, it can work for simple code.
23940 \end_layout
23941
23942 \begin_layout Standard
23943 Currently supported devices include:
23944 \end_layout
23945
23946 \begin_layout Standard
23947 12F: 629, 635, 675, 683
23948 \end_layout
23949
23950 \begin_layout Standard
23951 16C: 432, 433
23952 \end_layout
23953
23954 \begin_layout Standard
23955 16C: 554, 557, 558
23956 \end_layout
23957
23958 \begin_layout Standard
23959 16C: 62, 620, 620a, 621, 621a, 622, 622a, 63a, 65b
23960 \end_layout
23961
23962 \begin_layout Standard
23963 16C: 71, 710, 711, 715, 717, 72, 73b, 745, 74b, 765, 770, 771, 773, 774,
23964  781, 782
23965 \end_layout
23966
23967 \begin_layout Standard
23968 16C: 925, 926
23969 \end_layout
23970
23971 \begin_layout Standard
23972 16CR: 620a, 73, 74, 76, 77
23973 \end_layout
23974
23975 \begin_layout Standard
23976 16F: 616, 627, 627a, 628, 628a, 630, 636, 639, 648, 648a, 676, 684, 685,
23977  687, 688, 689, 690
23978 \end_layout
23979
23980 \begin_layout Standard
23981 16F: 716, 72, 73, 737, 74, 747, 76, 767, 77, 777, 785
23982 \end_layout
23983
23984 \begin_layout Standard
23985 16F: 818, 819, 84, 84a, 87, 870, 871, 872, 873, 873a, 874, 874a, 876, 876a,
23986  877, 877a, 88, 886, 887
23987 \end_layout
23988
23989 \begin_layout Standard
23990 16F: 913, 914, 916, 917, 946
23991 \end_layout
23992
23993 \begin_layout Standard
23994 26HV: 626, 785
23995 \end_layout
23996
23997 \begin_layout Standard
23998 An up-to-date list of currently supported devices can be obtained via 
23999 \family typewriter
24000 sdcc -mpic14 -phelp foo.c
24001 \family default
24002  (foo.c must exist...).
24003 \end_layout
24004
24005 \begin_layout Subsection
24006 PIC Code Pages
24007 \begin_inset LatexCommand \index{code page (pic14)}
24008
24009 \end_inset
24010
24011  and Memory Banks
24012 \begin_inset LatexCommand \index{Memory bank (pic14)}
24013
24014 \end_inset
24015
24016
24017 \end_layout
24018
24019 \begin_layout Standard
24020 The linker organizes allocation for the code page and RAM banks.
24021  It does not have intimate knowledge of the code flow.
24022  It will put all the code section of a single .asm file into a single code
24023  page.
24024  In order to make use of multiple code pages, separate asm files must be
24025  used.
24026  The compiler assigns all 
24027 \emph on
24028 static
24029 \emph default
24030  functions of a single .c file into the same code page.
24031 \newline
24032
24033 \newline
24034 To get the best results,
24035  follow these guidelines:
24036 \end_layout
24037
24038 \begin_layout Enumerate
24039 Make local functions static, as non static functions require code page selection
24040  overhead.
24041 \newline
24042 Due to the way sdcc handles functions, place called functions prior
24043  to calling functions in the file wherever possible: Otherwise sdcc will
24044  insert unneccessary pagesel directives around the call, believing that
24045  the called function is externally defined.
24046 \end_layout
24047
24048 \begin_layout Enumerate
24049 For devices that have multiple code pages it is more efficient to use the
24050  same number of files as pages: Use up to 4 separate .c files for the 16F877,
24051  but only 2 files for the 16F874.
24052  This way the linker can put the code for each file into different code
24053  pages and there will be less page selection overhead.
24054 \end_layout
24055
24056 \begin_layout Enumerate
24057 And as for any 8 bit micro (especially for PIC14 as they have a very simple
24058  instruction set), use `unsigned char' wherever possible instead of `int'.
24059 \end_layout
24060
24061 \begin_layout Subsection
24062 Adding New Devices to the Port 
24063 \end_layout
24064
24065 \begin_layout Standard
24066 Adding support for a new 14
24067 \begin_inset ERT
24068 status open
24069
24070 \begin_layout Standard
24071
24072
24073 \backslash
24074 ,
24075 \end_layout
24076
24077 \end_inset
24078
24079 bit PIC MCU requires the following steps:
24080 \end_layout
24081
24082 \begin_layout Enumerate
24083 Create a new device description.
24084 \newline
24085 Each device is described in two files: pic16f*.h
24086  and pic16f*.c.
24087  These files primarily define SFRs, structs to access their bits, and symbolic
24088  configuration options.
24089  Both files can be generated from gputils' .inc files using the perl script
24090  
24091 \family typewriter
24092 support/scripts/inc2h.pl
24093 \family default
24094 .
24095  This file also contains further instructions on how to proceed.
24096 \end_layout
24097
24098 \begin_layout Enumerate
24099 Copy the .h file into SDCC's include path and either add the .c file to your
24100  project or copy it to 
24101 \family typewriter
24102 device/lib/pic/libdev
24103 \family default
24104 .
24105  Afterwards, rebuild and install the libraries.
24106 \end_layout
24107
24108 \begin_layout Enumerate
24109 Edit pic14devices.txt in SDCC's include path (
24110 \family typewriter
24111 device/include/pic/
24112 \family default
24113  in the source tree or 
24114 \family typewriter
24115 /usr/local/share/sdcc/include/pic
24116 \family default
24117  after installation).
24118 \newline
24119 You need to add a device specification here to make
24120  the memory layout (code banks, RAM, aliased memory regions, ...) known to
24121  the compiler.
24122  Probably you can copy and modify an existing entry.
24123  The file format is documented at the top of the file.
24124 \end_layout
24125
24126 \begin_layout Subsection
24127 Interrupt Code
24128 \end_layout
24129
24130 \begin_layout Standard
24131 For the interrupt function, use the keyword `__interrupt'
24132 \begin_inset LatexCommand \index{PIC14!interrupt}
24133
24134 \end_inset
24135
24136  with level number of 0 (PIC14 only has 1 interrupt so this number is only
24137  there to avoid a syntax error - it ought to be fixed).
24138  E.g.:
24139 \end_layout
24140
24141 \begin_layout Verse
24142
24143 \family typewriter
24144 void Intr(void) __interrupt 0
24145 \newline
24146 {
24147 \newline
24148 \InsetSpace ~
24149 \InsetSpace ~
24150 T0IF = 0; /* Clear timer interrupt */
24151 \newline
24152 }
24153 \end_layout
24154
24155 \begin_layout Subsection
24156 Linking and Assembling
24157 \end_layout
24158
24159 \begin_layout Standard
24160 For assembling you can use either GPUTILS'
24161 \begin_inset LatexCommand \index{gputils (pic tools)}
24162
24163 \end_inset
24164
24165  gpasm.exe or MPLAB's mpasmwin.exe.
24166  GPUTILS are available from 
24167 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
24168
24169 \end_inset
24170
24171 .
24172  For linking you can use either GPUTILS' gplink or MPLAB's mplink.exe.
24173  If you use MPLAB and an interrupt function then the linker script file
24174  vectors section will need to be enlarged to link with mplink.
24175 \newline
24176
24177 \newline
24178 Here is a 
24179 \family typewriter
24180 Makefile
24181 \family default
24182  using GPUTILS:
24183 \end_layout
24184
24185 \begin_layout Verse
24186
24187 \family typewriter
24188 .c.o:
24189 \newline
24190 \InsetSpace ~
24191 \InsetSpace ~
24192 \InsetSpace ~
24193 \InsetSpace ~
24194 \InsetSpace ~
24195 \InsetSpace ~
24196 \InsetSpace ~
24197 \InsetSpace ~
24198 sdcc -V -mpic14 -p16f877 -c $< 
24199 \newline
24200
24201 \newline
24202 $(PRJ).hex: $(OBJS) 
24203 \newline
24204 \InsetSpace ~
24205 \InsetSpace ~
24206 \InsetSpace ~
24207 \InsetSpace ~
24208 \InsetSpace ~
24209 \InsetSpace ~
24210 \InsetSpace ~
24211 \InsetSpace ~
24212 gplink -m -s $(PRJ).lkr
24213  -o $(PRJ).hex $(OBJS) libsdcc.lib
24214 \end_layout
24215
24216 \begin_layout Standard
24217 Here is a 
24218 \family typewriter
24219 Makefile
24220 \family default
24221  using MPLAB:
24222 \end_layout
24223
24224 \begin_layout Verse
24225
24226 \family typewriter
24227 .c.o: 
24228 \newline
24229 \InsetSpace ~
24230 \InsetSpace ~
24231 \InsetSpace ~
24232 \InsetSpace ~
24233 \InsetSpace ~
24234 \InsetSpace ~
24235 \InsetSpace ~
24236 \InsetSpace ~
24237 sdcc -S -V -mpic14 -p16f877 $< 
24238 \newline
24239 \InsetSpace ~
24240 \InsetSpace ~
24241 \InsetSpace ~
24242 \InsetSpace ~
24243 \InsetSpace ~
24244 \InsetSpace ~
24245 \InsetSpace ~
24246 \InsetSpace ~
24247 mpasmwin /q /o $*.asm
24248 \newline
24249
24250 \newline
24251 $(PRJ).hex: $(OBJS)
24252  
24253 \newline
24254 \InsetSpace ~
24255 \InsetSpace ~
24256 \InsetSpace ~
24257 \InsetSpace ~
24258 \InsetSpace ~
24259 \InsetSpace ~
24260 \InsetSpace ~
24261 \InsetSpace ~
24262 mplink /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS) libsdcc.lib
24263 \end_layout
24264
24265 \begin_layout Standard
24266 Please note that indentations within a
24267 \family typewriter
24268  Makefile
24269 \family default
24270  have to be done with a tabulator character.
24271 \end_layout
24272
24273 \begin_layout Subsection
24274 Command-Line Options
24275 \end_layout
24276
24277 \begin_layout Standard
24278 Besides the switches common to all SDCC backends, the PIC14 port accepts
24279  the following options (for an updated list see sdcc -
24280 \begin_inset ERT
24281 status collapsed
24282
24283 \begin_layout Standard
24284
24285
24286 \backslash
24287 /
24288 \end_layout
24289
24290 \end_inset
24291
24292 -help):
24293 \end_layout
24294
24295 \begin_layout Description
24296 -
24297 \begin_inset ERT
24298 status collapsed
24299
24300 \begin_layout Standard
24301
24302
24303 \backslash
24304 /
24305 \end_layout
24306
24307 \end_inset
24308
24309 -debug-xtra
24310 \begin_inset LatexCommand \index{PIC14!Options!-\/-debug-extra}
24311
24312 \end_inset
24313
24314  emit debug info in assembly output
24315 \end_layout
24316
24317 \begin_layout Description
24318 -
24319 \begin_inset ERT
24320 status collapsed
24321
24322 \begin_layout Standard
24323
24324
24325 \backslash
24326 /
24327 \end_layout
24328
24329 \end_inset
24330
24331 -no-pcode-opt
24332 \begin_inset LatexCommand \index{PIC14!Options!-\/-no-pcode-opt}
24333
24334 \end_inset
24335
24336  disable (slightly faulty) optimization on pCode
24337 \end_layout
24338
24339 \begin_layout Description
24340 -
24341 \begin_inset ERT
24342 status collapsed
24343
24344 \begin_layout Standard
24345
24346
24347 \backslash
24348 /
24349 \end_layout
24350
24351 \end_inset
24352
24353 -stack-loc
24354 \begin_inset LatexCommand \index{PIC14!Options!-\/-stack-loc}
24355
24356 \end_inset
24357
24358  sets the lowest address of the argument passing stack (defaults to a suitably
24359  large shared databank to reduce BANKSEL overhead)
24360 \end_layout
24361
24362 \begin_layout Description
24363 -
24364 \begin_inset ERT
24365 status collapsed
24366
24367 \begin_layout Standard
24368
24369
24370 \backslash
24371 /
24372 \end_layout
24373
24374 \end_inset
24375
24376 -stack-size
24377 \begin_inset LatexCommand \index{PIC14!Options!-\/-stack-size}
24378
24379 \end_inset
24380
24381  sets the size if the argument passing stack (default: 16, minimum: 4)
24382 \end_layout
24383
24384 \begin_layout Subsection
24385 Environment Variables
24386 \end_layout
24387
24388 \begin_layout Standard
24389 The PIC14 port recognizes the following environment variables:
24390 \end_layout
24391
24392 \begin_layout Description
24393 SDCC_PIC14_SPLIT_LOCALS If set and not empty, sdcc will allocate each temporary
24394  register (the ones called r0xNNNN) in a section of its own.
24395  By default (if this variable is unset), sdcc tries to cluster registers
24396  in sections in order to reduce the BANKSEL overhead when accessing them.
24397 \end_layout
24398
24399 \begin_layout Subsection
24400 The Library
24401 \end_layout
24402
24403 \begin_layout Standard
24404 The PIC14 library currently only contains support routines required by the
24405  compiler to implement multiplication, division, and floating point support.
24406  No libc-like replacement is available at the moment, though many of the
24407  common sdcc library sources (in 
24408 \family typewriter
24409 device/lib
24410 \family default
24411 ) should also compile with the PIC14 port.
24412 \end_layout
24413
24414 \begin_layout Subsubsection
24415 error: missing definition for symbol ``__gptrget1''
24416 \end_layout
24417
24418 \begin_layout Standard
24419 The PIC14 port uses library routines to provide more complex operations
24420  like multiplication, division/modulus and (generic) pointer dereferencing.
24421  In order to add these routines to your project, you must link with PIC14's
24422  
24423 \family typewriter
24424 libsdcc.lib
24425 \family default
24426 .
24427  For single source file projects this is done automatically, more complex
24428  projects must add 
24429 \family typewriter
24430 libsdcc.lib
24431 \family default
24432  to the linker's arguments.
24433  Make sure you also add an include path for the library (using the -I switch
24434  to the linker)!
24435 \end_layout
24436
24437 \begin_layout Subsubsection
24438 Processor mismatch in file ``XXX''.
24439 \end_layout
24440
24441 \begin_layout Standard
24442 This warning can usually be ignored due to the very good compatibility amongst
24443  14
24444 \begin_inset ERT
24445 status open
24446
24447 \begin_layout Standard
24448
24449
24450 \backslash
24451 ,
24452 \end_layout
24453
24454 \end_inset
24455
24456 bit PIC
24457 \begin_inset LatexCommand \index{PIC14}
24458
24459 \end_inset
24460
24461  devices.
24462 \end_layout
24463
24464 \begin_layout Standard
24465 You might also consider recompiling the library for your specific device
24466  by changing the ARCH=p16f877 (default target) entry in 
24467 \family typewriter
24468 device/lib/pic/Makefile.in
24469 \family default
24470  and 
24471 \family typewriter
24472 device/lib/pic/Makefile
24473 \family default
24474  to reflect your device.
24475  This might even improve performance for smaller devices as unneccesary
24476  BANKSELs might be removed.
24477 \end_layout
24478
24479 \begin_layout Subsection
24480 Known Bugs
24481 \end_layout
24482
24483 \begin_layout Subsubsection
24484 Function arguments
24485 \end_layout
24486
24487 \begin_layout Standard
24488 Functions with variable argument lists (like printf) are not yet supported.
24489  Similarly, taking the address of the first argument passed into a function
24490  does not work: It is currently passed in WREG and has no address...
24491 \end_layout
24492
24493 \begin_layout Subsubsection
24494 Regression tests fail
24495 \end_layout
24496
24497 \begin_layout Standard
24498 Though the small subset of regression tests in src/regression passes, SDCC
24499  regression test suite does not, indicating that there are still major bugs
24500  in the port.
24501  However, many smaller projects have successfully used SDCC in the past...
24502 \end_layout
24503
24504 \begin_layout Standard
24505
24506 \size footnotesize
24507
24508 \newpage
24509
24510 \end_layout
24511
24512 \begin_layout Section
24513 The PIC16
24514 \begin_inset LatexCommand \index{PIC16}
24515
24516 \end_inset
24517
24518  port
24519 \end_layout
24520
24521 \begin_layout Standard
24522 The PIC16 port adds support for Microchip
24523 \begin_inset LatexCommand \index{Microchip}
24524
24525 \end_inset
24526
24527
24528 \begin_inset Formula $^{\text{TM}}$
24529 \end_inset
24530
24531  PIC
24532 \begin_inset LatexCommand \index{PIC}
24533
24534 \end_inset
24535
24536
24537 \begin_inset Formula $^{\text{TM}}$
24538 \end_inset
24539
24540  MCUs with 16 bit wide instructions.
24541  Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx
24542 ; devices supported by the port include:
24543 \end_layout
24544
24545 \begin_layout Standard
24546 18F: 242, 248, 252, 258, 442, 448, 452, 458
24547 \end_layout
24548
24549 \begin_layout Standard
24550 18F: 1220, 1320
24551 \end_layout
24552
24553 \begin_layout Standard
24554 18F: 2220, 2221, 2320, 2321, 2331, 2420, 2423, 2431, 2455, 2480, 24j10
24555 \end_layout
24556
24557 \begin_layout Standard
24558 18F: 2520, 2523, 2525, 2550, 2580, 2585, 25j10, 2620, 2680, 2682, 2685
24559 \end_layout
24560
24561 \begin_layout Standard
24562 18F: 4220, 4221, 4320, 4321, 4331, 4420, 4423, 4431, 4455, 4480, 44j10
24563 \end_layout
24564
24565 \begin_layout Standard
24566 18F: 4520, 4523, 4525, 4550, 4580, 4585, 45j10, 4620, 4680, 4682, 4685
24567 \end_layout
24568
24569 \begin_layout Standard
24570 18F: 6520, 6585, 6620, 6680, 6720
24571 \end_layout
24572
24573 \begin_layout Standard
24574 18F: 8520, 8585, 8620, 8680, 8720
24575 \end_layout
24576
24577 \begin_layout Standard
24578 A list of supported devices is also available via '
24579 \family typewriter
24580 sdcc -mpic16 -plist
24581 \family default
24582 '.
24583 \end_layout
24584
24585 \begin_layout Subsection
24586 Global Options
24587 \end_layout
24588
24589 \begin_layout Standard
24590 PIC16 port supports the standard command line arguments as supposed, with
24591  the exception of certain cases that will be mentioned in the following
24592  list:
24593 \end_layout
24594
24595 \begin_layout Description
24596 -
24597 \begin_inset ERT
24598 status collapsed
24599
24600 \begin_layout Standard
24601
24602
24603 \backslash
24604 /
24605 \end_layout
24606
24607 \end_inset
24608
24609 -callee-saves
24610 \begin_inset LatexCommand \index{PIC16!Options!-\/-callee-saves}
24611
24612 \end_inset
24613
24614  See -
24615 \begin_inset ERT
24616 status collapsed
24617
24618 \begin_layout Standard
24619
24620
24621 \backslash
24622 /
24623 \end_layout
24624
24625 \end_inset
24626
24627 -all-callee-saves
24628 \end_layout
24629
24630 \begin_layout Description
24631 -
24632 \begin_inset ERT
24633 status collapsed
24634
24635 \begin_layout Standard
24636
24637
24638 \backslash
24639 /
24640 \end_layout
24641
24642 \end_inset
24643
24644 -fommit-frame-pointer
24645 \begin_inset LatexCommand \index{PIC16!Options!-\/-fommit-frame-pointer}
24646
24647 \end_inset
24648
24649  Frame pointer will be omitted when the function uses no local variables.
24650 \end_layout
24651
24652 \begin_layout Subsection
24653 Port Specific Options
24654 \begin_inset LatexCommand \index{Options PIC16}
24655
24656 \end_inset
24657
24658
24659 \end_layout
24660
24661 \begin_layout Standard
24662 The port specific options appear after the global options in the sdcc -
24663 \begin_inset ERT
24664 status collapsed
24665
24666 \begin_layout Standard
24667
24668
24669 \backslash
24670 /
24671 \end_layout
24672
24673 \end_inset
24674
24675 -help output.
24676 \end_layout
24677
24678 \begin_layout Subsubsection
24679 Code Generation Options
24680 \end_layout
24681
24682 \begin_layout Standard
24683 These options influence the generated assembler code.
24684 \end_layout
24685
24686 \begin_layout Description
24687 -
24688 \begin_inset ERT
24689 status collapsed
24690
24691 \begin_layout Standard
24692
24693
24694 \backslash
24695 /
24696 \end_layout
24697
24698 \end_inset
24699
24700 -pstack-model=[model] Used in conjuction with the command above.
24701  Defines the stack model to be used, valid stack models are:
24702 \end_layout
24703
24704 \begin_deeper
24705 \begin_layout List
24706 \labelwidthstring 00.00.0000
24707
24708 \emph on
24709 small
24710 \emph default
24711  Selects small stack model.
24712  8 bit stack and frame pointers.
24713  Supports 256 bytes stack size.
24714 \end_layout
24715
24716 \begin_layout List
24717 \labelwidthstring 00.00.0000
24718
24719 \emph on
24720 large
24721 \emph default
24722  Selects large stack model.
24723  16 bit stack and frame pointers.
24724  Supports 65536 bytes stack size.
24725 \end_layout
24726
24727 \end_deeper
24728 \begin_layout Description
24729 -
24730 \begin_inset ERT
24731 status collapsed
24732
24733 \begin_layout Standard
24734
24735
24736 \backslash
24737 /
24738 \end_layout
24739
24740 \end_inset
24741
24742 -pno-banksel Do not generate BANKSEL assembler directives.
24743 \end_layout
24744
24745 \begin_layout Description
24746 -
24747 \begin_inset ERT
24748 status collapsed
24749
24750 \begin_layout Standard
24751
24752
24753 \backslash
24754 /
24755 \end_layout
24756
24757 \end_inset
24758
24759 -extended Enable extended instruction set/literal offset addressing mode.
24760  Use with care!
24761 \end_layout
24762
24763 \begin_layout Subsubsection
24764 Optimization Options
24765 \end_layout
24766
24767 \begin_layout Description
24768 -
24769 \begin_inset ERT
24770 status collapsed
24771
24772 \begin_layout Standard
24773
24774
24775 \backslash
24776 /
24777 \end_layout
24778
24779 \end_inset
24780
24781 -obanksel=n Set optimization level for inserting BANKSELs.
24782 \newline
24783
24784 \end_layout
24785
24786 \begin_deeper
24787 \begin_layout List
24788 \labelwidthstring 00.00.0000
24789 0 no optimization
24790 \end_layout
24791
24792 \begin_layout List
24793 \labelwidthstring 00.00.0000
24794 1 checks previous used register and if it is the same then does not emit
24795  BANKSEL, accounts only for labels.
24796 \end_layout
24797
24798 \begin_layout List
24799 \labelwidthstring 00.00.0000
24800 2 tries to check the location of (even different) symbols and removes BANKSELs
24801  if they are in the same bank.
24802  
24803 \newline
24804
24805 \emph on
24806 Important: There might be problems if the linker script has data sections
24807  across bank borders!
24808 \end_layout
24809
24810 \end_deeper
24811 \begin_layout Description
24812 -
24813 \begin_inset ERT
24814 status collapsed
24815
24816 \begin_layout Standard
24817
24818
24819 \backslash
24820 /
24821 \end_layout
24822
24823 \end_inset
24824
24825 -denable-peeps Force the usage of peepholes.
24826  Use with care.
24827 \end_layout
24828
24829 \begin_layout Description
24830 -
24831 \begin_inset ERT
24832 status collapsed
24833
24834 \begin_layout Standard
24835
24836
24837 \backslash
24838 /
24839 \end_layout
24840
24841 \end_inset
24842
24843 -no-optimize-goto Do not use (conditional) BRA instead of GOTO.
24844 \end_layout
24845
24846 \begin_layout Description
24847 -
24848 \begin_inset ERT
24849 status collapsed
24850
24851 \begin_layout Standard
24852
24853
24854 \backslash
24855 /
24856 \end_layout
24857
24858 \end_inset
24859
24860 -optimize-cmp Try to optimize some compares.
24861 \end_layout
24862
24863 \begin_layout Description
24864 -
24865 \begin_inset ERT
24866 status collapsed
24867
24868 \begin_layout Standard
24869
24870
24871 \backslash
24872 /
24873 \end_layout
24874
24875 \end_inset
24876
24877 -optimize-df Analyze the dataflow of the generated code and improve it.
24878 \end_layout
24879
24880 \begin_layout Subsubsection
24881 Assembling Options
24882 \end_layout
24883
24884 \begin_layout Description
24885 -
24886 \begin_inset ERT
24887 status collapsed
24888
24889 \begin_layout Standard
24890
24891
24892 \backslash
24893 /
24894 \end_layout
24895
24896 \end_inset
24897
24898 -asm= Sets the full path and name of an external assembler to call.
24899 \end_layout
24900
24901 \begin_layout Description
24902 -
24903 \begin_inset ERT
24904 status collapsed
24905
24906 \begin_layout Standard
24907
24908
24909 \backslash
24910 /
24911 \end_layout
24912
24913 \end_inset
24914
24915 -mplab-comp MPLAB
24916 \begin_inset LatexCommand \index{PIC16!MPLAB}
24917
24918 \end_inset
24919
24920  compatibility option.
24921  Currently only suppresses special gpasm directives.
24922 \end_layout
24923
24924 \begin_layout Subsubsection
24925 Linking Options
24926 \end_layout
24927
24928 \begin_layout Description
24929 -
24930 \begin_inset ERT
24931 status collapsed
24932
24933 \begin_layout Standard
24934
24935
24936 \backslash
24937 /
24938 \end_layout
24939
24940 \end_inset
24941
24942 -link= Sets the full path and name of an external linker to call.
24943 \end_layout
24944
24945 \begin_layout Description
24946 -
24947 \begin_inset ERT
24948 status collapsed
24949
24950 \begin_layout Standard
24951
24952
24953 \backslash
24954 /
24955 \end_layout
24956
24957 \end_inset
24958
24959 -preplace-udata-with=[kword] Replaces the default udata keyword for allocating
24960  unitialized data variables with [kword].
24961  Valid keywords are: "udata_acs", "udata_shr", "udata_ovr".
24962 \end_layout
24963
24964 \begin_layout Description
24965 -
24966 \begin_inset ERT
24967 status collapsed
24968
24969 \begin_layout Standard
24970
24971
24972 \backslash
24973 /
24974 \end_layout
24975
24976 \end_inset
24977
24978 -ivt-loc=n Place the interrupt vector table at address 
24979 \emph on
24980 n
24981 \emph default
24982 .
24983  Useful for bootloaders.
24984 \end_layout
24985
24986 \begin_layout Description
24987 -
24988 \begin_inset ERT
24989 status collapsed
24990
24991 \begin_layout Standard
24992
24993
24994 \backslash
24995 /
24996 \end_layout
24997
24998 \end_inset
24999
25000 -nodefaultlibs Do not link default libraries when linking.
25001 \end_layout
25002
25003 \begin_layout Description
25004 -
25005 \begin_inset ERT
25006 status collapsed
25007
25008 \begin_layout Standard
25009
25010
25011 \backslash
25012 /
25013 \end_layout
25014
25015 \end_inset
25016
25017 -use-crt= Use a custom run-time module instead of the defaults.
25018 \end_layout
25019
25020 \begin_layout Description
25021 -
25022 \begin_inset ERT
25023 status collapsed
25024
25025 \begin_layout Standard
25026
25027
25028 \backslash
25029 /
25030 \end_layout
25031
25032 \end_inset
25033
25034 -no-crt Don't link the default run-time modules
25035 \end_layout
25036
25037 \begin_layout Subsubsection
25038 Debugging Options
25039 \end_layout
25040
25041 \begin_layout Standard
25042 Debugging options enable extra debugging information in the output files.
25043 \end_layout
25044
25045 \begin_layout Description
25046 -
25047 \begin_inset ERT
25048 status collapsed
25049
25050 \begin_layout Standard
25051
25052
25053 \backslash
25054 /
25055 \end_layout
25056
25057 \end_inset
25058
25059 -debug-xtra Similar to -
25060 \begin_inset ERT
25061 status collapsed
25062
25063 \begin_layout Standard
25064
25065
25066 \backslash
25067 /
25068 \end_layout
25069
25070 \end_inset
25071
25072 -debug
25073 \begin_inset LatexCommand \index{-\/-debug}
25074
25075 \end_inset
25076
25077 , but dumps more information.
25078 \end_layout
25079
25080 \begin_layout Description
25081 -
25082 \begin_inset ERT
25083 status collapsed
25084
25085 \begin_layout Standard
25086
25087
25088 \backslash
25089 /
25090 \end_layout
25091
25092 \end_inset
25093
25094 -debug-ralloc Force register allocator to dump <source>.d file with debugging
25095  information.
25096  <source> is the name of the file being compiled.
25097 \end_layout
25098
25099 \begin_layout Description
25100 -
25101 \begin_inset ERT
25102 status collapsed
25103
25104 \begin_layout Standard
25105
25106
25107 \backslash
25108 /
25109 \end_layout
25110
25111 \end_inset
25112
25113 -pcode-verbose Enable pcode debugging information in translation.
25114 \end_layout
25115
25116 \begin_layout Description
25117 -
25118 \begin_inset ERT
25119 status collapsed
25120
25121 \begin_layout Standard
25122
25123
25124 \backslash
25125 /
25126 \end_layout
25127
25128 \end_inset
25129
25130 -calltree Dump call tree in .calltree file.
25131 \end_layout
25132
25133 \begin_layout Description
25134 -
25135 \begin_inset ERT
25136 status collapsed
25137
25138 \begin_layout Standard
25139
25140
25141 \backslash
25142 /
25143 \end_layout
25144
25145 \end_inset
25146
25147 -gstack Trace push/pops for stack pointer overflow.
25148 \end_layout
25149
25150 \begin_layout Subsection
25151 Enviroment Variables
25152 \end_layout
25153
25154 \begin_layout Standard
25155 There is a number of enviromental variables that can be used when running
25156  SDCC to enable certain optimizations or force a specific program behaviour.
25157  these variables are primarily for debugging purposes so they can be enabled/dis
25158 abled at will.
25159 \end_layout
25160
25161 \begin_layout Standard
25162 Currently there is only two such variables available:
25163 \end_layout
25164
25165 \begin_layout Description
25166 OPTIMIZE_BITFIELD_POINTER_GET When this variable exists, reading of structure
25167  bitfields is optimized by directly loading FSR0 with the address of the
25168  bitfield structure.
25169  Normally SDCC will cast the bitfield structure to a bitfield pointer and
25170  then load FSR0.
25171  This step saves data ram and code space for functions that make heavy use
25172  of bitfields.
25173  (i.e., 80 bytes of code space are saved when compiling malloc.c with this
25174  option).
25175  
25176 \end_layout
25177
25178 \begin_layout Description
25179 NO_REG_OPT Do not perform pCode registers optimization.
25180  This should be used for debugging purposes.
25181  If bugs in the pcode optimizer are found, users can benefit from temporarily
25182  disabling the optimizer until the bug is fixed.
25183 \end_layout
25184
25185 \begin_layout Subsection
25186 Preprocessor Macros
25187 \end_layout
25188
25189 \begin_layout Standard
25190 PIC16
25191 \begin_inset LatexCommand \index{PIC16}
25192
25193 \end_inset
25194
25195  port defines the following preprocessor macros while translating a source.
25196 \end_layout
25197
25198 \begin_layout Standard
25199 \align center
25200 \begin_inset Tabular
25201 <lyxtabular version="3" rows="6" columns="2">
25202 <features>
25203 <column alignment="center" valignment="top" leftline="true" width="0">
25204 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25205 <row topline="true" bottomline="true">
25206 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25207 \begin_inset Text
25208
25209 \begin_layout Standard
25210 Macro
25211 \end_layout
25212
25213 \end_inset
25214 </cell>
25215 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25216 \begin_inset Text
25217
25218 \begin_layout Standard
25219 Description
25220 \end_layout
25221
25222 \end_inset
25223 </cell>
25224 </row>
25225 <row topline="true">
25226 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25227 \begin_inset Text
25228
25229 \begin_layout Standard
25230 SDCC_pic16
25231 \end_layout
25232
25233 \end_inset
25234 </cell>
25235 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25236 \begin_inset Text
25237
25238 \begin_layout Standard
25239 Port identification
25240 \end_layout
25241
25242 \end_inset
25243 </cell>
25244 </row>
25245 <row topline="true">
25246 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25247 \begin_inset Text
25248
25249 \begin_layout Standard
25250 _
25251 \begin_inset ERT
25252 status collapsed
25253
25254 \begin_layout Standard
25255
25256
25257 \backslash
25258 /
25259 \end_layout
25260
25261 \end_inset
25262
25263 _pic16
25264 \end_layout
25265
25266 \end_inset
25267 </cell>
25268 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25269 \begin_inset Text
25270
25271 \begin_layout Standard
25272 Port identification (same as above)
25273 \end_layout
25274
25275 \end_inset
25276 </cell>
25277 </row>
25278 <row topline="true">
25279 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25280 \begin_inset Text
25281
25282 \begin_layout Standard
25283 pic18fxxxx
25284 \end_layout
25285
25286 \end_inset
25287 </cell>
25288 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25289 \begin_inset Text
25290
25291 \begin_layout Standard
25292 MCU Identification.
25293  
25294 \emph on
25295 xxxx
25296 \emph default
25297  is the microcontrol identification number, i.e.
25298  452, 6620, etc
25299 \end_layout
25300
25301 \end_inset
25302 </cell>
25303 </row>
25304 <row topline="true">
25305 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25306 \begin_inset Text
25307
25308 \begin_layout Standard
25309 _
25310 \begin_inset ERT
25311 status collapsed
25312
25313 \begin_layout Standard
25314
25315
25316 \backslash
25317 /
25318 \end_layout
25319
25320 \end_inset
25321
25322 _18Fxxxx
25323 \end_layout
25324
25325 \end_inset
25326 </cell>
25327 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25328 \begin_inset Text
25329
25330 \begin_layout Standard
25331 MCU Identification (same as above)
25332 \end_layout
25333
25334 \end_inset
25335 </cell>
25336 </row>
25337 <row topline="true" bottomline="true">
25338 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25339 \begin_inset Text
25340
25341 \begin_layout Standard
25342 STACK_MODEL_nnn
25343 \end_layout
25344
25345 \end_inset
25346 </cell>
25347 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25348 \begin_inset Text
25349
25350 \begin_layout Standard
25351 nnn = SMALL or LARGE respectively according to the stack model used
25352 \end_layout
25353
25354 \end_inset
25355 </cell>
25356 </row>
25357 </lyxtabular>
25358
25359 \end_inset
25360
25361
25362 \end_layout
25363
25364 \begin_layout Standard
25365 In addition the following macros are defined when calling assembler:
25366 \end_layout
25367
25368 \begin_layout Standard
25369 \align center
25370 \begin_inset Tabular
25371 <lyxtabular version="3" rows="4" columns="2">
25372 <features>
25373 <column alignment="center" valignment="top" leftline="true" width="0">
25374 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25375 <row topline="true" bottomline="true">
25376 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25377 \begin_inset Text
25378
25379 \begin_layout Standard
25380 Macro
25381 \end_layout
25382
25383 \end_inset
25384 </cell>
25385 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25386 \begin_inset Text
25387
25388 \begin_layout Standard
25389 Description
25390 \end_layout
25391
25392 \end_inset
25393 </cell>
25394 </row>
25395 <row topline="true">
25396 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25397 \begin_inset Text
25398
25399 \begin_layout Standard
25400 __18Fxxxx
25401 \end_layout
25402
25403 \end_inset
25404 </cell>
25405 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25406 \begin_inset Text
25407
25408 \begin_layout Standard
25409 MCU Identification.
25410  
25411 \emph on
25412 xxxx
25413 \emph default
25414  is the microcontrol identification number, i.e.
25415  452, 6620, etc
25416 \end_layout
25417
25418 \end_inset
25419 </cell>
25420 </row>
25421 <row topline="true">
25422 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25423 \begin_inset Text
25424
25425 \begin_layout Standard
25426 SDCC_MODEL_nnn
25427 \end_layout
25428
25429 \end_inset
25430 </cell>
25431 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25432 \begin_inset Text
25433
25434 \begin_layout Standard
25435 nnn = SMALL or LARGE respectively according to the memory model used for
25436  SDCC
25437 \end_layout
25438
25439 \end_inset
25440 </cell>
25441 </row>
25442 <row topline="true" bottomline="true">
25443 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25444 \begin_inset Text
25445
25446 \begin_layout Standard
25447 STACK_MODEL_nnn
25448 \end_layout
25449
25450 \end_inset
25451 </cell>
25452 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25453 \begin_inset Text
25454
25455 \begin_layout Standard
25456 nnn = SMALL or LARGE respectively according to the stack model used
25457 \end_layout
25458
25459 \end_inset
25460 </cell>
25461 </row>
25462 </lyxtabular>
25463
25464 \end_inset
25465
25466
25467 \end_layout
25468
25469 \begin_layout Subsection
25470 Directories
25471 \end_layout
25472
25473 \begin_layout Standard
25474 PIC16
25475 \begin_inset LatexCommand \index{PIC16}
25476
25477 \end_inset
25478
25479  port uses the following directories for searching header files and libraries.
25480 \end_layout
25481
25482 \begin_layout Standard
25483 \align center
25484 \begin_inset Tabular
25485 <lyxtabular version="3" rows="3" columns="4">
25486 <features>
25487 <column alignment="center" valignment="top" leftline="true" width="0">
25488 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25489 <column alignment="center" valignment="top" width="0">
25490 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25491 <row topline="true" bottomline="true">
25492 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25493 \begin_inset Text
25494
25495 \begin_layout Standard
25496 Directory
25497 \end_layout
25498
25499 \end_inset
25500 </cell>
25501 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25502 \begin_inset Text
25503
25504 \begin_layout Standard
25505 Description
25506 \end_layout
25507
25508 \end_inset
25509 </cell>
25510 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25511 \begin_inset Text
25512
25513 \begin_layout Standard
25514 Target
25515 \end_layout
25516
25517 \end_inset
25518 </cell>
25519 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25520 \begin_inset Text
25521
25522 \begin_layout Standard
25523 Command prefix
25524 \end_layout
25525
25526 \end_inset
25527 </cell>
25528 </row>
25529 <row topline="true">
25530 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25531 \begin_inset Text
25532
25533 \begin_layout Standard
25534 PREFIX/sdcc/include/pic16
25535 \end_layout
25536
25537 \end_inset
25538 </cell>
25539 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25540 \begin_inset Text
25541
25542 \begin_layout Standard
25543 PIC16 specific headers
25544 \end_layout
25545
25546 \end_inset
25547 </cell>
25548 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25549 \begin_inset Text
25550
25551 \begin_layout Standard
25552 Compiler
25553 \end_layout
25554
25555 \end_inset
25556 </cell>
25557 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25558 \begin_inset Text
25559
25560 \begin_layout Standard
25561 -I
25562 \end_layout
25563
25564 \end_inset
25565 </cell>
25566 </row>
25567 <row topline="true" bottomline="true">
25568 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25569 \begin_inset Text
25570
25571 \begin_layout Standard
25572 PREFIX/sdcc/lib/pic16
25573 \end_layout
25574
25575 \end_inset
25576 </cell>
25577 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25578 \begin_inset Text
25579
25580 \begin_layout Standard
25581 PIC16 specific libraries
25582 \end_layout
25583
25584 \end_inset
25585 </cell>
25586 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25587 \begin_inset Text
25588
25589 \begin_layout Standard
25590 Linker
25591 \end_layout
25592
25593 \end_inset
25594 </cell>
25595 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25596 \begin_inset Text
25597
25598 \begin_layout Standard
25599 -L
25600 \end_layout
25601
25602 \end_inset
25603 </cell>
25604 </row>
25605 </lyxtabular>
25606
25607 \end_inset
25608
25609
25610 \end_layout
25611
25612 \begin_layout Subsection
25613 Pragmas
25614 \begin_inset LatexCommand \label{sub:PIC16_Pragmas}
25615
25616 \end_inset
25617
25618
25619 \end_layout
25620
25621 \begin_layout Standard
25622 The PIC16
25623 \begin_inset LatexCommand \index{PIC16}
25624
25625 \end_inset
25626
25627  port currently supports the following pragmas:
25628 \end_layout
25629
25630 \begin_layout Description
25631 stack
25632 \begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma stack}
25633
25634 \end_inset
25635
25636  This forces the code generator to initialize the stack & frame pointers
25637  at a specific address.
25638  This is an ad hoc solution for cases where no STACK directive is available
25639  in the linker script or gplink is not instructed to create a stack section.
25640 \newline
25641 The
25642  stack pragma should be used only once in a project.
25643  Multiple pragmas may result in indeterminate behaviour of the program.
25644 \begin_inset Foot
25645 status open
25646
25647 \begin_layout Standard
25648 The old format (ie.
25649  #pragma stack 0x5ff) is deprecated and will cause the stack pointer to
25650  cross page boundaries (or even exceed the available data RAM) and crash
25651  the program.
25652  Make sure that stack does not cross page boundaries when using the SMALL
25653  stack model.
25654 \end_layout
25655
25656 \end_inset
25657
25658
25659 \newline
25660 The format is as follows:
25661 \newline
25662
25663 \end_layout
25664
25665 \begin_layout LyX-Code
25666 #pragma stack bottom_address [stack_size]
25667 \newline
25668
25669 \end_layout
25670
25671 \begin_layout Standard
25672
25673 \emph on
25674 bottom_address
25675 \emph default
25676  is the lower bound of the stack section.
25677  The stack pointer initially will point at address (bottom_address+stack_size-1).
25678 \end_layout
25679
25680 \begin_layout LyX-Code
25681 Example:
25682 \end_layout
25683
25684 \begin_layout LyX-Code
25685
25686 \end_layout
25687
25688 \begin_layout LyX-Code
25689 /* initializes stack of 100 bytes at RAM address 0x200 */
25690 \end_layout
25691
25692 \begin_layout LyX-Code
25693 #pragma stack 0x200 100
25694 \end_layout
25695
25696 \begin_layout Standard
25697 If the stack_size field is omitted then a stack is created with the default
25698  size of 64.
25699  This size might be enough for most programs, but its not enough for operations
25700  with deep function nesting or excessive stack usage.
25701 \end_layout
25702
25703 \begin_layout Description
25704 code
25705 \begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma code}
25706
25707 \end_inset
25708
25709  Force a function to a static FLASH address.
25710 \end_layout
25711
25712 \begin_layout LyX-Code
25713 Example:
25714 \end_layout
25715
25716 \begin_layout LyX-Code
25717
25718 \end_layout
25719
25720 \begin_layout LyX-Code
25721 /* place function test_func at 0x4000 */
25722 \end_layout
25723
25724 \begin_layout LyX-Code
25725 #pragma code test_func 0x4000
25726 \end_layout
25727
25728 \begin_layout LyX-Code
25729
25730 \end_layout
25731
25732 \begin_layout Description
25733 library instructs the linker to use a library module.
25734 \newline
25735 Usage:
25736 \end_layout
25737
25738 \begin_layout LyX-Code
25739 #pragma library module_name
25740 \end_layout
25741
25742 \begin_layout Standard
25743
25744 \emph on
25745 module_name
25746 \emph default
25747  can be any library or object file (including its path).
25748  Note that there are four reserved keywords which have special meaning.
25749  These are:
25750 \end_layout
25751
25752 \begin_layout Standard
25753 \align center
25754 \begin_inset Tabular
25755 <lyxtabular version="3" rows="6" columns="3">
25756 <features>
25757 <column alignment="center" valignment="top" leftline="true" width="0">
25758 <column alignment="block" valignment="top" leftline="true" width="20page%">
25759 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
25760 <row topline="true" bottomline="true">
25761 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25762 \begin_inset Text
25763
25764 \begin_layout Standard
25765 Keyword
25766 \end_layout
25767
25768 \end_inset
25769 </cell>
25770 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25771 \begin_inset Text
25772
25773 \begin_layout Standard
25774 Description
25775 \end_layout
25776
25777 \end_inset
25778 </cell>
25779 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25780 \begin_inset Text
25781
25782 \begin_layout Standard
25783 Module to link
25784 \end_layout
25785
25786 \end_inset
25787 </cell>
25788 </row>
25789 <row topline="true">
25790 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25791 \begin_inset Text
25792
25793 \begin_layout Standard
25794
25795 \series bold
25796 ignore
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 ignore all library pragmas
25806 \end_layout
25807
25808 \end_inset
25809 </cell>
25810 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25811 \begin_inset Text
25812
25813 \begin_layout Standard
25814
25815 \emph on
25816 (none)
25817 \end_layout
25818
25819 \end_inset
25820 </cell>
25821 </row>
25822 <row topline="true">
25823 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25824 \begin_inset Text
25825
25826 \begin_layout Standard
25827
25828 \series bold
25829 c
25830 \end_layout
25831
25832 \end_inset
25833 </cell>
25834 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25835 \begin_inset Text
25836
25837 \begin_layout Standard
25838 link the C library
25839 \end_layout
25840
25841 \end_inset
25842 </cell>
25843 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25844 \begin_inset Text
25845
25846 \begin_layout Standard
25847
25848 \emph on
25849 libc18f
25850 \emph default
25851 .lib
25852 \end_layout
25853
25854 \end_inset
25855 </cell>
25856 </row>
25857 <row topline="true">
25858 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25859 \begin_inset Text
25860
25861 \begin_layout Standard
25862
25863 \series bold
25864 math
25865 \end_layout
25866
25867 \end_inset
25868 </cell>
25869 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25870 \begin_inset Text
25871
25872 \begin_layout Standard
25873 link the Math libarary
25874 \end_layout
25875
25876 \end_inset
25877 </cell>
25878 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25879 \begin_inset Text
25880
25881 \begin_layout Standard
25882
25883 \emph on
25884 libm18f
25885 \emph default
25886 .lib
25887 \end_layout
25888
25889 \end_inset
25890 </cell>
25891 </row>
25892 <row topline="true">
25893 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25894 \begin_inset Text
25895
25896 \begin_layout Standard
25897
25898 \series bold
25899 io
25900 \end_layout
25901
25902 \end_inset
25903 </cell>
25904 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25905 \begin_inset Text
25906
25907 \begin_layout Standard
25908 link the I/O library
25909 \end_layout
25910
25911 \end_inset
25912 </cell>
25913 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25914 \begin_inset Text
25915
25916 \begin_layout Standard
25917
25918 \emph on
25919 libio18f*
25920 \emph default
25921 .lib
25922 \end_layout
25923
25924 \end_inset
25925 </cell>
25926 </row>
25927 <row topline="true" bottomline="true">
25928 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25929 \begin_inset Text
25930
25931 \begin_layout Standard
25932
25933 \series bold
25934 debug
25935 \end_layout
25936
25937 \end_inset
25938 </cell>
25939 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25940 \begin_inset Text
25941
25942 \begin_layout Standard
25943 link the debug library
25944 \end_layout
25945
25946 \end_inset
25947 </cell>
25948 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25949 \begin_inset Text
25950
25951 \begin_layout Standard
25952
25953 \emph on
25954 libdebug
25955 \emph default
25956 .lib
25957 \end_layout
25958
25959 \end_inset
25960 </cell>
25961 </row>
25962 </lyxtabular>
25963
25964 \end_inset
25965
25966
25967 \newline
25968 * is the device number, i.e.
25969  452 for PIC18F452 MCU.
25970 \end_layout
25971
25972 \begin_layout Standard
25973 This feature allows for linking with specific libraries withoug having to
25974  explicit name them in the command line.
25975  Note that the 
25976 \noun on
25977 ignore
25978 \noun default
25979  keyword will reject all modules specified by the library pragma.
25980 \end_layout
25981
25982 \begin_layout Description
25983 udata The pragma udata instructs the compiler to emit code so that linker
25984  will place a variable at a specific memory bank.
25985 \end_layout
25986
25987 \begin_layout LyX-Code
25988 Example:
25989 \end_layout
25990
25991 \begin_layout LyX-Code
25992
25993 \end_layout
25994
25995 \begin_layout LyX-Code
25996 /* places variable foo at bank2 */
25997 \end_layout
25998
25999 \begin_layout LyX-Code
26000 #pragma udata bank2 foo
26001 \end_layout
26002
26003 \begin_layout LyX-Code
26004 char foo;
26005 \end_layout
26006
26007 \begin_layout Standard
26008 In order for this pragma to work extra SECTION directives should be added
26009  in the .lkr script.
26010  In the following example a sample .lkr file is shown:
26011 \end_layout
26012
26013 \begin_layout LyX-Code
26014
26015 \end_layout
26016
26017 \begin_layout LyX-Code
26018 // Sample linker script for the PIC18F452 processor
26019 \end_layout
26020
26021 \begin_layout LyX-Code
26022 LIBPATH .
26023 \end_layout
26024
26025 \begin_layout LyX-Code
26026 CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
26027 \end_layout
26028
26029 \begin_layout LyX-Code
26030 CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
26031 \end_layout
26032
26033 \begin_layout LyX-Code
26034 CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
26035 \end_layout
26036
26037 \begin_layout LyX-Code
26038 CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
26039 \end_layout
26040
26041 \begin_layout LyX-Code
26042 CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
26043 \end_layout
26044
26045 \begin_layout LyX-Code
26046 CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
26047 \end_layout
26048
26049 \begin_layout LyX-Code
26050 ACCESSBANK NAME=accessram  START=0x0            END=0x7F
26051 \end_layout
26052
26053 \begin_layout LyX-Code
26054
26055 \end_layout
26056
26057 \begin_layout LyX-Code
26058 DATABANK   NAME=gpr0       START=0x80           END=0xFF
26059 \end_layout
26060
26061 \begin_layout LyX-Code
26062 DATABANK   NAME=gpr1       START=0x100          END=0x1FF
26063 \end_layout
26064
26065 \begin_layout LyX-Code
26066 DATABANK   NAME=gpr2       START=0x200          END=0x2FF
26067 \end_layout
26068
26069 \begin_layout LyX-Code
26070 DATABANK   NAME=gpr3       START=0x300          END=0x3FF
26071 \end_layout
26072
26073 \begin_layout LyX-Code
26074 DATABANK   NAME=gpr4       START=0x400          END=0x4FF
26075 \end_layout
26076
26077 \begin_layout LyX-Code
26078 DATABANK   NAME=gpr5       START=0x500          END=0x5FF
26079 \end_layout
26080
26081 \begin_layout LyX-Code
26082 ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED
26083 \end_layout
26084
26085 \begin_layout LyX-Code
26086
26087 \end_layout
26088
26089 \begin_layout LyX-Code
26090 SECTION    NAME=CONFIG     ROM=config
26091 \end_layout
26092
26093 \begin_layout LyX-Code
26094
26095 \end_layout
26096
26097 \begin_layout LyX-Code
26098 SECTION    NAME=bank0      RAM=gpr0       # these SECTION directives
26099 \end_layout
26100
26101 \begin_layout LyX-Code
26102 SECTION    NAME=bank1      RAM=gpr1       # should be added to link
26103 \end_layout
26104
26105 \begin_layout LyX-Code
26106 SECTION    NAME=bank2      RAM=gpr2       # section name 'bank?' with
26107 \end_layout
26108
26109 \begin_layout LyX-Code
26110 SECTION    NAME=bank3      RAM=gpr3       # a specific DATABANK name
26111 \end_layout
26112
26113 \begin_layout LyX-Code
26114 SECTION    NAME=bank4      RAM=gpr4
26115 \end_layout
26116
26117 \begin_layout LyX-Code
26118 SECTION    NAME=bank5      RAM=gpr5
26119 \end_layout
26120
26121 \begin_layout Standard
26122 The linker will recognise the section name set in the pragma statement and
26123  will position the variable at the memory bank set with the RAM field at
26124  the SECTION line in the linker script file.
26125 \end_layout
26126
26127 \begin_layout Subsection
26128 Header Files
26129 \begin_inset LatexCommand \label{sub:PIC16_Header-Files}
26130
26131 \end_inset
26132
26133
26134 \end_layout
26135
26136 \begin_layout Standard
26137 There is one main header file
26138 \begin_inset LatexCommand \index{PIC16!Header files}
26139
26140 \end_inset
26141
26142  that can be included to the source files using the pic16
26143 \begin_inset LatexCommand \index{PIC16}
26144
26145 \end_inset
26146
26147  port.
26148  That file is the 
26149 \series bold
26150 pic18fregs.h
26151 \series default
26152 .
26153  This header file contains the definitions for the processor special registers,
26154  so it is necessary if the source accesses them.
26155  It can be included by adding the following line in the beginning of the
26156  file:
26157 \end_layout
26158
26159 \begin_layout LyX-Code
26160 #include <pic18fregs.h>
26161 \end_layout
26162
26163 \begin_layout Standard
26164 The specific microcontroller is selected within the pic18fregs.h automatically,
26165  so the same source can be used with a variety of devices.
26166 \end_layout
26167
26168 \begin_layout Subsection
26169 Libraries
26170 \end_layout
26171
26172 \begin_layout Standard
26173 The libraries
26174 \begin_inset LatexCommand \index{PIC16!Libraries}
26175
26176 \end_inset
26177
26178  that PIC16
26179 \begin_inset LatexCommand \index{PIC16}
26180
26181 \end_inset
26182
26183  port depends on are the microcontroller device libraries which contain
26184  the symbol definitions for the microcontroller special function registers.
26185  These libraries have the format pic18fxxxx.lib, where 
26186 \emph on
26187 xxxx
26188 \emph default
26189  is the microcontroller identification number.
26190  The specific library is selected automatically by the compiler at link
26191  stage according to the selected device.
26192 \end_layout
26193
26194 \begin_layout Standard
26195 Libraries are created with gplib which is part of the gputils package 
26196 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
26197
26198 \end_inset
26199
26200 .
26201 \end_layout
26202
26203 \begin_layout Subsubsection*
26204 Building the libraries
26205 \end_layout
26206
26207 \begin_layout Standard
26208 Before using SDCC/pic16 there are some libraries that need to be compiled.
26209  This process is not done automatically by SDCC since not all users use
26210  SDCC for pic16 projects.
26211  So each user should compile the libraries separately.
26212 \end_layout
26213
26214 \begin_layout Standard
26215 The steps to compile the pic16 libraries under Linux and Mac OS X are:
26216 \end_layout
26217
26218 \begin_layout LyX-Code
26219 cd device/lib/pic16
26220 \end_layout
26221
26222 \begin_layout LyX-Code
26223 ./configure
26224 \end_layout
26225
26226 \begin_layout LyX-Code
26227 make
26228 \end_layout
26229
26230 \begin_layout LyX-Code
26231 cd ..
26232 \end_layout
26233
26234 \begin_layout LyX-Code
26235 make model-pic16
26236 \end_layout
26237
26238 \begin_layout LyX-Code
26239 su -c 'make install'     # install the libraries, you need the root password
26240 \end_layout
26241
26242 \begin_layout Standard
26243 If you need to install the headers too, do:
26244 \end_layout
26245
26246 \begin_layout LyX-Code
26247 cd device/include
26248 \end_layout
26249
26250 \begin_layout LyX-Code
26251 su -c 'make install'     # install the headers, you need the root password
26252 \end_layout
26253
26254 \begin_layout Standard
26255 There exist a special target to build the I/O libraries.
26256  This target is not automatically build because it will build the I/O library
26257  for 
26258 \emph on
26259 every
26260 \emph default
26261  supported device.
26262  This way building will take quite a lot of time.
26263  Users are advised to edit the 
26264 \series bold
26265 device/lib/pic16/pics.build
26266 \series default
26267  file and then execute:
26268 \end_layout
26269
26270 \begin_layout LyX-Code
26271 make lib-io
26272 \end_layout
26273
26274 \begin_layout Subsection
26275 Adding New Devices to the Port
26276 \end_layout
26277
26278 \begin_layout Standard
26279 Adding support for a new 16
26280 \begin_inset ERT
26281 status open
26282
26283 \begin_layout Standard
26284
26285
26286 \backslash
26287 ,
26288 \end_layout
26289
26290 \end_inset
26291
26292 bit PIC MCU requires the following steps:
26293 \end_layout
26294
26295 \begin_layout Enumerate
26296 Create picDEVICE.c and picDEVICE.h from pDEVICE.inc using
26297 \newline
26298
26299 \family typewriter
26300 perl /path/to/sdcc/support/scripts/inc2h-pic16.pl /path/to/gputils/header/pDEVICE.
26301 inc
26302 \end_layout
26303
26304 \begin_layout Enumerate
26305
26306 \family typewriter
26307 mv picDEVICE.h /path/to/sdcc/device/include/pic16
26308 \end_layout
26309
26310 \begin_layout Enumerate
26311
26312 \family typewriter
26313 mv picDEVICE.c /path/to/sdcc/device/lib/pic16/libdev
26314 \end_layout
26315
26316 \begin_layout Enumerate
26317 Add DEVICE to 
26318 \family typewriter
26319 /path/to/sdcc/device/lib/pic16/pics.all
26320 \family default
26321  (and 
26322 \family typewriter
26323 .build
26324 \family default
26325 ).
26326 \newline
26327 Note: No 18f prefix here!
26328 \end_layout
26329
26330 \begin_layout Enumerate
26331 Set up the I/O library by doing 
26332 \series bold
26333 one
26334 \series default
26335  of the following:
26336 \end_layout
26337
26338 \begin_deeper
26339 \begin_layout Enumerate
26340 Adjust 
26341 \family typewriter
26342 /path/to/sdcc/device/lib/pic16/libio/*.ignore
26343 \family default
26344
26345 \newline
26346 Add your DEVICE if it does not compile in 
26347 \family typewriter
26348 adc
26349 \family default
26350
26351 \family typewriter
26352 i2c
26353 \family default
26354 , or 
26355 \family typewriter
26356 usart
26357 \family default
26358 .
26359 \end_layout
26360
26361 \begin_layout Enumerate
26362 Adjust 
26363 \family typewriter
26364 /path/to/sdcc/device/include/pic16/adc.h
26365 \newline
26366
26367 \family default
26368 Add the new devices to the correct ADC style class.
26369 \end_layout
26370
26371 \end_deeper
26372 \begin_layout Enumerate
26373 Edit 
26374 \family typewriter
26375 /path/to/sdcc/device/include/pic16/pic18fregs.h
26376 \family default
26377 .
26378  The file format is self-explanatory, just add
26379 \newline
26380
26381 \family typewriter
26382 #elif defined(picDEVICE)
26383 \newline
26384 # include <picDEVICE.h>
26385 \family default
26386
26387 \newline
26388 at the right place (keep it sorted).
26389 \end_layout
26390
26391 \begin_layout Enumerate
26392 Edit 
26393 \family typewriter
26394 /path/to/sdcc/device/include/pic16devices.txt
26395 \newline
26396
26397 \family default
26398 Copy and modify an existing entry or create a new one and insert it at the
26399  correct place (keep the file sorted).
26400 \end_layout
26401
26402 \begin_layout Enumerate
26403 Recompile the pic16 libraries.
26404 \end_layout
26405
26406 \begin_layout Subsection
26407 Memory Models
26408 \end_layout
26409
26410 \begin_layout Standard
26411 The following memory models are supported by the PIC16 port:
26412 \end_layout
26413
26414 \begin_layout Itemize
26415 small model
26416 \end_layout
26417
26418 \begin_layout Itemize
26419 large model
26420 \end_layout
26421
26422 \begin_layout Standard
26423 Memory model affects the default size of pointers within the source.
26424  The sizes are shown in the next table:
26425 \end_layout
26426
26427 \begin_layout Standard
26428 \align center
26429 \begin_inset Tabular
26430 <lyxtabular version="3" rows="3" columns="3">
26431 <features>
26432 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26433 <column alignment="center" valignment="top" leftline="true" width="0">
26434 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26435 <row topline="true" bottomline="true">
26436 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26437 \begin_inset Text
26438
26439 \begin_layout Standard
26440 Pointer sizes according to memory model
26441 \end_layout
26442
26443 \end_inset
26444 </cell>
26445 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26446 \begin_inset Text
26447
26448 \begin_layout Standard
26449 small model
26450 \end_layout
26451
26452 \end_inset
26453 </cell>
26454 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26455 \begin_inset Text
26456
26457 \begin_layout Standard
26458 large model
26459 \end_layout
26460
26461 \end_inset
26462 </cell>
26463 </row>
26464 <row topline="true" bottomline="true">
26465 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26466 \begin_inset Text
26467
26468 \begin_layout Standard
26469 code pointers
26470 \end_layout
26471
26472 \end_inset
26473 </cell>
26474 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26475 \begin_inset Text
26476
26477 \begin_layout Standard
26478 16-bits
26479 \end_layout
26480
26481 \end_inset
26482 </cell>
26483 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26484 \begin_inset Text
26485
26486 \begin_layout Standard
26487 24-bits
26488 \end_layout
26489
26490 \end_inset
26491 </cell>
26492 </row>
26493 <row topline="true" bottomline="true">
26494 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26495 \begin_inset Text
26496
26497 \begin_layout Standard
26498 data pointers
26499 \end_layout
26500
26501 \end_inset
26502 </cell>
26503 <cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
26504 \begin_inset Text
26505
26506 \begin_layout Standard
26507 16-bits
26508 \end_layout
26509
26510 \end_inset
26511 </cell>
26512 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26513 \begin_inset Text
26514
26515 \begin_layout Standard
26516 16-bits
26517 \end_layout
26518
26519 \end_inset
26520 </cell>
26521 </row>
26522 </lyxtabular>
26523
26524 \end_inset
26525
26526
26527 \end_layout
26528
26529 \begin_layout Standard
26530 It is advisable that all sources within a project are compiled with the
26531  same memory model.
26532  If one wants to override the default memory model, this can be done by
26533  declaring a pointer as 
26534 \series bold
26535 far
26536 \series default
26537  or 
26538 \series bold
26539 near
26540 \series default
26541 .
26542  Far selects large memory model's pointers, while near selects small memory
26543  model's pointers.
26544 \end_layout
26545
26546 \begin_layout Standard
26547 The standard device libraries (see 
26548 \begin_inset LatexCommand \ref{sub:PIC16_Header-Files}
26549
26550 \end_inset
26551
26552 ) contain no reference to pointers, so they can be used with both memory
26553  models.
26554 \end_layout
26555
26556 \begin_layout Subsection
26557 Stack
26558 \end_layout
26559
26560 \begin_layout Standard
26561 The stack
26562 \begin_inset LatexCommand \index{PIC16!stack}
26563
26564 \end_inset
26565
26566  implementation for the PIC16 port uses two indirect registers, FSR1 and
26567  FSR2.
26568 \end_layout
26569
26570 \begin_layout Description
26571 FSR1 is assigned as stack pointer
26572 \end_layout
26573
26574 \begin_layout Description
26575 FSR2 is assigned as frame pointer
26576 \end_layout
26577
26578 \begin_layout Standard
26579 The following stack models are supported by the PIC16 port
26580 \end_layout
26581
26582 \begin_layout Itemize
26583
26584 \noun on
26585 small
26586 \noun default
26587  model
26588 \end_layout
26589
26590 \begin_layout Itemize
26591
26592 \noun on
26593 large
26594 \noun default
26595  model
26596 \end_layout
26597
26598 \begin_layout Standard
26599
26600 \noun on
26601 Small
26602 \noun default
26603  model means that only the FSRxL byte is used to access stack and frame,
26604  while 
26605 \emph on
26606 \noun on
26607 large
26608 \emph default
26609 \noun default
26610  uses both FSRxL and FSRxH registers.
26611  The following table shows the stack/frame pointers sizes according to stack
26612  model and the maximum space they can address:
26613 \end_layout
26614
26615 \begin_layout Standard
26616 \align center
26617 \begin_inset Tabular
26618 <lyxtabular version="3" rows="3" columns="3">
26619 <features>
26620 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26621 <column alignment="center" valignment="top" leftline="true" width="0">
26622 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26623 <row topline="true" bottomline="true">
26624 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26625 \begin_inset Text
26626
26627 \begin_layout Standard
26628 Stack & Frame pointer sizes according to stack model
26629 \end_layout
26630
26631 \end_inset
26632 </cell>
26633 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26634 \begin_inset Text
26635
26636 \begin_layout Standard
26637 small
26638 \end_layout
26639
26640 \end_inset
26641 </cell>
26642 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26643 \begin_inset Text
26644
26645 \begin_layout Standard
26646 large
26647 \end_layout
26648
26649 \end_inset
26650 </cell>
26651 </row>
26652 <row topline="true">
26653 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26654 \begin_inset Text
26655
26656 \begin_layout Standard
26657 Stack pointer FSR1
26658 \end_layout
26659
26660 \end_inset
26661 </cell>
26662 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26663 \begin_inset Text
26664
26665 \begin_layout Standard
26666 8-bits
26667 \end_layout
26668
26669 \end_inset
26670 </cell>
26671 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26672 \begin_inset Text
26673
26674 \begin_layout Standard
26675 16-bits
26676 \end_layout
26677
26678 \end_inset
26679 </cell>
26680 </row>
26681 <row topline="true" bottomline="true">
26682 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26683 \begin_inset Text
26684
26685 \begin_layout Standard
26686 Frame pointer FSR2
26687 \end_layout
26688
26689 \end_inset
26690 </cell>
26691 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26692 \begin_inset Text
26693
26694 \begin_layout Standard
26695 8-bits
26696 \end_layout
26697
26698 \end_inset
26699 </cell>
26700 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26701 \begin_inset Text
26702
26703 \begin_layout Standard
26704 16-bits
26705 \end_layout
26706
26707 \end_inset
26708 </cell>
26709 </row>
26710 </lyxtabular>
26711
26712 \end_inset
26713
26714
26715 \end_layout
26716
26717 \begin_layout Standard
26718
26719 \noun on
26720 Large 
26721 \noun default
26722 stack model is currently not working properly throughout the code generator.
26723  So its use is not advised.
26724  Also there are some other points that need special care:
26725 \newline
26726
26727 \end_layout
26728
26729 \begin_layout Enumerate
26730 Do not create stack sections with size more than one physical bank (that
26731  is 256 bytes)
26732 \end_layout
26733
26734 \begin_layout Enumerate
26735 Stack sections should no cross physical bank limits (i.e.
26736  #pragma stack 0x50 0x100)
26737 \end_layout
26738
26739 \begin_layout Standard
26740 These limitations are caused by the fact that only FSRxL is modified when
26741  using SMALL stack model, so no more than 256 bytes of stack can be used.
26742  This problem will disappear after LARGE model is fully implemented.
26743 \end_layout
26744
26745 \begin_layout Subsection
26746 Functions
26747 \end_layout
26748
26749 \begin_layout Standard
26750 In addition to the standard SDCC function keywords, PIC16
26751 \begin_inset LatexCommand \index{PIC16}
26752
26753 \end_inset
26754
26755  port makes available two more:
26756 \end_layout
26757
26758 \begin_layout Description
26759 wparam
26760 \begin_inset LatexCommand \index{PIC16!wparam}
26761
26762 \end_inset
26763
26764  Use the WREG to pass one byte of the first function argument.
26765  This improves speed but you may not use this for functions with arguments
26766  that are called via function pointers, otherwise the first byte of the
26767  first parameter will get lost.
26768  Usage:
26769 \end_layout
26770
26771 \begin_layout LyX-Code
26772 void func_wparam(int a) wparam
26773 \end_layout
26774
26775 \begin_layout LyX-Code
26776 {
26777 \end_layout
26778
26779 \begin_layout LyX-Code
26780     /* WREG hold the lower part of a */
26781 \end_layout
26782
26783 \begin_layout LyX-Code
26784     /* the high part of a is stored in FSR2+2 (or +3 for large stack model)
26785  */
26786 \end_layout
26787
26788 \begin_layout LyX-Code
26789 ...
26790 \end_layout
26791
26792 \begin_layout LyX-Code
26793 }
26794 \end_layout
26795
26796 \begin_layout Description
26797 shadowregs
26798 \begin_inset LatexCommand \index{PIC16!shadowregs}
26799
26800 \end_inset
26801
26802  When entering/exiting an ISR, it is possible to take advantage of the PIC18F
26803  hardware shadow registers which hold the values of WREG, STATUS and BSR
26804  registers.
26805  This can be done by adding the keyword 
26806 \emph on
26807 shadowregs
26808 \emph default
26809  before the 
26810 \emph on
26811 interrupt
26812 \emph default
26813  keyword in the function's header.
26814 \end_layout
26815
26816 \begin_layout LyX-Code
26817 void isr_shadow(void) shadowregs interrupt 1
26818 \end_layout
26819
26820 \begin_layout LyX-Code
26821 {
26822 \end_layout
26823
26824 \begin_layout LyX-Code
26825 ...
26826 \end_layout
26827
26828 \begin_layout LyX-Code
26829 }
26830 \end_layout
26831
26832 \begin_layout Standard
26833
26834 \emph on
26835 shadowregs
26836 \emph default
26837  instructs the code generator not to store/restore WREG, STATUS, BSR when
26838  entering/exiting the ISR.
26839 \end_layout
26840
26841 \begin_layout Subsection
26842 Function return values
26843 \end_layout
26844
26845 \begin_layout Standard
26846 Return values from functions are placed to the appropriate registers following
26847  a modified Microchip policy optimized for SDCC.
26848  The following table shows these registers:
26849 \end_layout
26850
26851 \begin_layout Standard
26852 \align center
26853 \begin_inset Tabular
26854 <lyxtabular version="3" rows="6" columns="2">
26855 <features>
26856 <column alignment="center" valignment="top" leftline="true" width="0">
26857 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26858 <row topline="true" bottomline="true">
26859 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26860 \begin_inset Text
26861
26862 \begin_layout Standard
26863 size
26864 \end_layout
26865
26866 \end_inset
26867 </cell>
26868 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26869 \begin_inset Text
26870
26871 \begin_layout Standard
26872 destination register
26873 \end_layout
26874
26875 \end_inset
26876 </cell>
26877 </row>
26878 <row topline="true">
26879 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26880 \begin_inset Text
26881
26882 \begin_layout Standard
26883 8 bits
26884 \end_layout
26885
26886 \end_inset
26887 </cell>
26888 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26889 \begin_inset Text
26890
26891 \begin_layout Standard
26892 WREG
26893 \end_layout
26894
26895 \end_inset
26896 </cell>
26897 </row>
26898 <row topline="true">
26899 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26900 \begin_inset Text
26901
26902 \begin_layout Standard
26903 16 bits
26904 \end_layout
26905
26906 \end_inset
26907 </cell>
26908 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26909 \begin_inset Text
26910
26911 \begin_layout Standard
26912 PRODL:WREG
26913 \end_layout
26914
26915 \end_inset
26916 </cell>
26917 </row>
26918 <row topline="true">
26919 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26920 \begin_inset Text
26921
26922 \begin_layout Standard
26923 24 bits
26924 \end_layout
26925
26926 \end_inset
26927 </cell>
26928 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26929 \begin_inset Text
26930
26931 \begin_layout Standard
26932 PRODH:PRODL:WREG
26933 \end_layout
26934
26935 \end_inset
26936 </cell>
26937 </row>
26938 <row topline="true">
26939 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26940 \begin_inset Text
26941
26942 \begin_layout Standard
26943 32 bits
26944 \end_layout
26945
26946 \end_inset
26947 </cell>
26948 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26949 \begin_inset Text
26950
26951 \begin_layout Standard
26952 FSR0L:PRODH:PRODL:WREG
26953 \end_layout
26954
26955 \end_inset
26956 </cell>
26957 </row>
26958 <row topline="true" bottomline="true">
26959 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26960 \begin_inset Text
26961
26962 \begin_layout Standard
26963 >32 bits
26964 \end_layout
26965
26966 \end_inset
26967 </cell>
26968 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26969 \begin_inset Text
26970
26971 \begin_layout Standard
26972 on stack, FSR0 points to the beginning
26973 \end_layout
26974
26975 \end_inset
26976 </cell>
26977 </row>
26978 </lyxtabular>
26979
26980 \end_inset
26981
26982
26983 \end_layout
26984
26985 \begin_layout Subsection
26986 Interrupts
26987 \end_layout
26988
26989 \begin_layout Standard
26990 An interrupt
26991 \begin_inset LatexCommand \index{PIC16!interrupt}
26992
26993 \end_inset
26994
26995  service routine (ISR) is declared using the 
26996 \emph on
26997 interrupt
26998 \emph default
26999  keyword.
27000 \end_layout
27001
27002 \begin_layout LyX-Code
27003 void isr(void) interrupt 
27004 \emph on
27005 n
27006 \end_layout
27007
27008 \begin_layout LyX-Code
27009 {
27010 \end_layout
27011
27012 \begin_layout LyX-Code
27013 ...
27014 \end_layout
27015
27016 \begin_layout LyX-Code
27017 }
27018 \end_layout
27019
27020 \begin_layout Standard
27021
27022 \emph on
27023 n
27024 \emph default
27025  is the interrupt number, which for PIC18F devices can be:
27026 \end_layout
27027
27028 \begin_layout Standard
27029 \align center
27030 \begin_inset Tabular
27031 <lyxtabular version="3" rows="4" columns="3">
27032 <features>
27033 <column alignment="center" valignment="top" leftline="true" width="0">
27034 <column alignment="center" valignment="top" leftline="true" width="0">
27035 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27036 <row topline="true" bottomline="true">
27037 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27038 \begin_inset Text
27039
27040 \begin_layout Standard
27041
27042 \emph on
27043 n
27044 \end_layout
27045
27046 \end_inset
27047 </cell>
27048 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27049 \begin_inset Text
27050
27051 \begin_layout Standard
27052 Interrupt Vector
27053 \end_layout
27054
27055 \end_inset
27056 </cell>
27057 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27058 \begin_inset Text
27059
27060 \begin_layout Standard
27061 Interrupt Vector Address
27062 \end_layout
27063
27064 \end_inset
27065 </cell>
27066 </row>
27067 <row topline="true">
27068 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27069 \begin_inset Text
27070
27071 \begin_layout Standard
27072 0
27073 \end_layout
27074
27075 \end_inset
27076 </cell>
27077 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27078 \begin_inset Text
27079
27080 \begin_layout Standard
27081 RESET vector
27082 \end_layout
27083
27084 \end_inset
27085 </cell>
27086 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27087 \begin_inset Text
27088
27089 \begin_layout Standard
27090 0x000000
27091 \end_layout
27092
27093 \end_inset
27094 </cell>
27095 </row>
27096 <row topline="true">
27097 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27098 \begin_inset Text
27099
27100 \begin_layout Standard
27101
27102 \family roman
27103 \series medium
27104 \shape up
27105 \size normal
27106 \emph off
27107 \bar no
27108 \noun off
27109 \color none
27110 1
27111 \end_layout
27112
27113 \end_inset
27114 </cell>
27115 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27116 \begin_inset Text
27117
27118 \begin_layout Standard
27119
27120 \family roman
27121 \series medium
27122 \shape up
27123 \size normal
27124 \emph off
27125 \bar no
27126 \noun off
27127 \color none
27128 HIGH priority interrupts
27129 \end_layout
27130
27131 \end_inset
27132 </cell>
27133 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27134 \begin_inset Text
27135
27136 \begin_layout Standard
27137 0x000008
27138 \end_layout
27139
27140 \end_inset
27141 </cell>
27142 </row>
27143 <row topline="true" bottomline="true">
27144 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27145 \begin_inset Text
27146
27147 \begin_layout Standard
27148 2
27149 \end_layout
27150
27151 \end_inset
27152 </cell>
27153 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27154 \begin_inset Text
27155
27156 \begin_layout Standard
27157 LOW priority interrupts
27158 \end_layout
27159
27160 \end_inset
27161 </cell>
27162 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27163 \begin_inset Text
27164
27165 \begin_layout Standard
27166 0x000018
27167 \end_layout
27168
27169 \end_inset
27170 </cell>
27171 </row>
27172 </lyxtabular>
27173
27174 \end_inset
27175
27176
27177 \end_layout
27178
27179 \begin_layout Standard
27180 When generating assembly code for ISR the code generator places a 
27181 \noun on
27182 goto 
27183 \noun default
27184 instruction at the 
27185 \emph on
27186 Interrupt Vector Address
27187 \emph default
27188  which points at the genetated ISR.
27189  This single GOTO instruction is part of an automatically generated 
27190 \emph on
27191 interrupt entry point
27192 \emph default
27193  function.
27194  The actuall ISR code is placed as normally would in the code space.
27195  Upon interrupt request, the GOTO instruction is executed which jumps to
27196  the ISR code.
27197  When declaring interrupt functions as _naked this GOTO instruction is 
27198 \series bold
27199 not
27200 \series default
27201  generated.
27202  The whole interrupt functions is therefore placed at the Interrupt Vector
27203  Address of the specific interrupt.
27204  This is not a problem for the LOW priority interrupts, but it is a problem
27205  for the RESET and the HIGH priority interrupts because code may be written
27206  at the next interrupt's vector address and cause undeterminate program
27207  behaviour if that interrupt is raised.
27208 \begin_inset Foot
27209 status open
27210
27211 \begin_layout Standard
27212 This is not a problem when
27213 \end_layout
27214
27215 \begin_layout Enumerate
27216 this is a HIGH interrupt ISR and LOW interrupts are 
27217 \emph on
27218 disabled
27219 \emph default
27220  or not used.
27221 \end_layout
27222
27223 \begin_layout Enumerate
27224 when the ISR is small enough not to reach the next interrupt's vector address.
27225 \end_layout
27226
27227 \end_inset
27228
27229
27230 \end_layout
27231
27232 \begin_layout Standard
27233
27234 \emph on
27235 n
27236 \emph default
27237  may be omitted.
27238  This way a function is generated similar to an ISR, but it is not assigned
27239  to any interrupt.
27240 \end_layout
27241
27242 \begin_layout Standard
27243 When entering an interrupt, currently the PIC16
27244 \begin_inset LatexCommand \index{PIC16}
27245
27246 \end_inset
27247
27248  port automatically saves the following registers:
27249 \end_layout
27250
27251 \begin_layout Itemize
27252 WREG
27253 \end_layout
27254
27255 \begin_layout Itemize
27256 STATUS
27257 \end_layout
27258
27259 \begin_layout Itemize
27260 BSR
27261 \end_layout
27262
27263 \begin_layout Itemize
27264 PROD (PRODL and PRODH)
27265 \end_layout
27266
27267 \begin_layout Itemize
27268 FSR0 (FSR0L and FSR0H)
27269 \end_layout
27270
27271 \begin_layout Standard
27272 These registers are restored upon return from the interrupt routine.
27273 \begin_inset Foot
27274 status open
27275
27276 \begin_layout Standard
27277 NOTE that when the _naked attribute is specified for an interrupt routine,
27278  then NO registers are stored or restored.
27279 \end_layout
27280
27281 \end_inset
27282
27283
27284 \end_layout
27285
27286 \begin_layout Subsection
27287 Generic Pointers
27288 \end_layout
27289
27290 \begin_layout Standard
27291 Generic pointers are implemented in PIC16 port as 3-byte (24-bit) types.
27292  There are 3 types of generic pointers currently implemented data, code
27293  and eeprom pointers.
27294  They are differentiated by the value of the 7th and 6th bits of the upper
27295  byte:
27296 \end_layout
27297
27298 \begin_layout Standard
27299 \align center
27300 \begin_inset Tabular
27301 <lyxtabular version="3" rows="5" columns="5">
27302 <features>
27303 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27304 <column alignment="center" valignment="top" width="0">
27305 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27306 <column alignment="center" valignment="top" width="0">
27307 <column alignment="left" valignment="top" rightline="true" width="0">
27308 <row topline="true" bottomline="true">
27309 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27310 \begin_inset Text
27311
27312 \begin_layout Standard
27313 pointer type
27314 \end_layout
27315
27316 \end_inset
27317 </cell>
27318 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27319 \begin_inset Text
27320
27321 \begin_layout Standard
27322 7th bit
27323 \end_layout
27324
27325 \end_inset
27326 </cell>
27327 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27328 \begin_inset Text
27329
27330 \begin_layout Standard
27331 6th bit
27332 \end_layout
27333
27334 \end_inset
27335 </cell>
27336 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27337 \begin_inset Text
27338
27339 \begin_layout Standard
27340 rest of the pointer
27341 \end_layout
27342
27343 \end_inset
27344 </cell>
27345 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27346 \begin_inset Text
27347
27348 \begin_layout Standard
27349 description
27350 \end_layout
27351
27352 \end_inset
27353 </cell>
27354 </row>
27355 <row topline="true" bottomline="true">
27356 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27357 \begin_inset Text
27358
27359 \begin_layout Standard
27360 data 
27361 \end_layout
27362
27363 \end_inset
27364 </cell>
27365 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27366 \begin_inset Text
27367
27368 \begin_layout Standard
27369 1
27370 \end_layout
27371
27372 \end_inset
27373 </cell>
27374 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27375 \begin_inset Text
27376
27377 \begin_layout Standard
27378 0
27379 \end_layout
27380
27381 \end_inset
27382 </cell>
27383 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27384 \begin_inset Text
27385
27386 \begin_layout Standard
27387
27388 \family typewriter
27389 \shape slanted
27390 \emph on
27391 uuuuuu uuuuxxxx xxxxxxxx
27392 \end_layout
27393
27394 \end_inset
27395 </cell>
27396 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27397 \begin_inset Text
27398
27399 \begin_layout Standard
27400 a 12-bit data pointer in data RAM memory
27401 \end_layout
27402
27403 \end_inset
27404 </cell>
27405 </row>
27406 <row bottomline="true">
27407 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27408 \begin_inset Text
27409
27410 \begin_layout Standard
27411 code
27412 \end_layout
27413
27414 \end_inset
27415 </cell>
27416 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27417 \begin_inset Text
27418
27419 \begin_layout Standard
27420 0
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 0
27430 \end_layout
27431
27432 \end_inset
27433 </cell>
27434 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27435 \begin_inset Text
27436
27437 \begin_layout Standard
27438
27439 \family typewriter
27440 \shape slanted
27441 \emph on
27442 uxxxxx xxxxxxxx xxxxxxxx
27443 \end_layout
27444
27445 \end_inset
27446 </cell>
27447 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27448 \begin_inset Text
27449
27450 \begin_layout Standard
27451 a 21-bit code pointer in FLASH memory
27452 \end_layout
27453
27454 \end_inset
27455 </cell>
27456 </row>
27457 <row bottomline="true">
27458 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27459 \begin_inset Text
27460
27461 \begin_layout Standard
27462 eeprom
27463 \end_layout
27464
27465 \end_inset
27466 </cell>
27467 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27468 \begin_inset Text
27469
27470 \begin_layout Standard
27471 0
27472 \end_layout
27473
27474 \end_inset
27475 </cell>
27476 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27477 \begin_inset Text
27478
27479 \begin_layout Standard
27480 1
27481 \end_layout
27482
27483 \end_inset
27484 </cell>
27485 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27486 \begin_inset Text
27487
27488 \begin_layout Standard
27489
27490 \family typewriter
27491 \shape slanted
27492 \emph on
27493 uuuuuu uuuuuuxx xxxxxxxx
27494 \end_layout
27495
27496 \end_inset
27497 </cell>
27498 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27499 \begin_inset Text
27500
27501 \begin_layout Standard
27502 a 10-bit eeprom pointer in EEPROM memory
27503 \end_layout
27504
27505 \end_inset
27506 </cell>
27507 </row>
27508 <row bottomline="true">
27509 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27510 \begin_inset Text
27511
27512 \begin_layout Standard
27513 (unimplemented)
27514 \end_layout
27515
27516 \end_inset
27517 </cell>
27518 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27519 \begin_inset Text
27520
27521 \begin_layout Standard
27522 1
27523 \end_layout
27524
27525 \end_inset
27526 </cell>
27527 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27528 \begin_inset Text
27529
27530 \begin_layout Standard
27531 1
27532 \end_layout
27533
27534 \end_inset
27535 </cell>
27536 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27537 \begin_inset Text
27538
27539 \begin_layout Standard
27540
27541 \family typewriter
27542 \shape slanted
27543 \emph on
27544 xxxxxx xxxxxxxx xxxxxxxx
27545 \end_layout
27546
27547 \end_inset
27548 </cell>
27549 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27550 \begin_inset Text
27551
27552 \begin_layout Standard
27553 unimplemented pointer type
27554 \end_layout
27555
27556 \end_inset
27557 </cell>
27558 </row>
27559 </lyxtabular>
27560
27561 \end_inset
27562
27563
27564 \end_layout
27565
27566 \begin_layout Standard
27567 Generic pointer are read and written with a set of library functions which
27568  read/write 1, 2, 3, 4 bytes.
27569 \end_layout
27570
27571 \begin_layout Subsection
27572 PIC16 C Libraries
27573 \end_layout
27574
27575 \begin_layout Subsubsection
27576 Standard I/O Streams
27577 \end_layout
27578
27579 \begin_layout Standard
27580 In the 
27581 \emph on
27582 stdio.h
27583 \emph default
27584  the type FILE is defined as:
27585 \end_layout
27586
27587 \begin_layout LyX-Code
27588 typedef char * FILE;
27589 \end_layout
27590
27591 \begin_layout Standard
27592 This type is the stream type implemented I/O in the PIC18F devices.
27593  Also the standard input and output streams are declared in stdio.h:
27594 \end_layout
27595
27596 \begin_layout LyX-Code
27597 extern FILE * stdin;
27598 \end_layout
27599
27600 \begin_layout LyX-Code
27601 extern FILE * stdout;
27602 \end_layout
27603
27604 \begin_layout Standard
27605 The FILE type is actually a generic pointer which defines one more type
27606  of generic pointers, the 
27607 \emph on
27608 stream 
27609 \emph default
27610 pointer.
27611  This new type has the format:
27612 \end_layout
27613
27614 \begin_layout Standard
27615 \align center
27616 \begin_inset Tabular
27617 <lyxtabular version="3" rows="2" columns="7">
27618 <features>
27619 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27620 <column alignment="center" valignment="top" width="0">
27621 <column alignment="center" valignment="top" leftline="true" width="0">
27622 <column alignment="center" valignment="top" leftline="true" width="0">
27623 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27624 <column alignment="center" valignment="top" width="0">
27625 <column alignment="left" valignment="top" rightline="true" width="0">
27626 <row topline="true" bottomline="true">
27627 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27628 \begin_inset Text
27629
27630 \begin_layout Standard
27631 pointer type
27632 \end_layout
27633
27634 \end_inset
27635 </cell>
27636 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27637 \begin_inset Text
27638
27639 \begin_layout Standard
27640 <7:6>
27641 \end_layout
27642
27643 \end_inset
27644 </cell>
27645 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27646 \begin_inset Text
27647
27648 \begin_layout Standard
27649 <5>
27650 \end_layout
27651
27652 \end_inset
27653 </cell>
27654 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27655 \begin_inset Text
27656
27657 \begin_layout Standard
27658 <4>
27659 \end_layout
27660
27661 \end_inset
27662 </cell>
27663 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27664 \begin_inset Text
27665
27666 \begin_layout Standard
27667 <3:0>
27668 \end_layout
27669
27670 \end_inset
27671 </cell>
27672 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27673 \begin_inset Text
27674
27675 \begin_layout Standard
27676 rest of the pointer
27677 \end_layout
27678
27679 \end_inset
27680 </cell>
27681 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27682 \begin_inset Text
27683
27684 \begin_layout Standard
27685 descrption
27686 \end_layout
27687
27688 \end_inset
27689 </cell>
27690 </row>
27691 <row topline="true" bottomline="true">
27692 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27693 \begin_inset Text
27694
27695 \begin_layout Standard
27696 stream
27697 \end_layout
27698
27699 \end_inset
27700 </cell>
27701 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27702 \begin_inset Text
27703
27704 \begin_layout Standard
27705 00
27706 \end_layout
27707
27708 \end_inset
27709 </cell>
27710 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27711 \begin_inset Text
27712
27713 \begin_layout Standard
27714 1
27715 \end_layout
27716
27717 \end_inset
27718 </cell>
27719 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27720 \begin_inset Text
27721
27722 \begin_layout Standard
27723 0
27724 \end_layout
27725
27726 \end_inset
27727 </cell>
27728 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27729 \begin_inset Text
27730
27731 \begin_layout Standard
27732 nnnn
27733 \end_layout
27734
27735 \end_inset
27736 </cell>
27737 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27738 \begin_inset Text
27739
27740 \begin_layout Standard
27741
27742 \family typewriter
27743 \shape slanted
27744 \emph on
27745 uuuuuuuu uuuuuuuu
27746 \end_layout
27747
27748 \end_inset
27749 </cell>
27750 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27751 \begin_inset Text
27752
27753 \begin_layout Standard
27754 upper byte high nubble is 0x2n, the rest are zeroes
27755 \end_layout
27756
27757 \end_inset
27758 </cell>
27759 </row>
27760 </lyxtabular>
27761
27762 \end_inset
27763
27764
27765 \end_layout
27766
27767 \begin_layout Standard
27768 Currently implemented there are 3 types of streams defined:
27769 \end_layout
27770
27771 \begin_layout Standard
27772 \align center
27773 \begin_inset Tabular
27774 <lyxtabular version="3" rows="4" columns="4">
27775 <features>
27776 <column alignment="center" valignment="top" leftline="true" width="0">
27777 <column alignment="center" valignment="top" leftline="true" width="0">
27778 <column alignment="center" valignment="top" leftline="true" width="0">
27779 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27780 <row topline="true" bottomline="true">
27781 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27782 \begin_inset Text
27783
27784 \begin_layout Standard
27785 stream type
27786 \end_layout
27787
27788 \end_inset
27789 </cell>
27790 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27791 \begin_inset Text
27792
27793 \begin_layout Standard
27794 value
27795 \end_layout
27796
27797 \end_inset
27798 </cell>
27799 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27800 \begin_inset Text
27801
27802 \begin_layout Standard
27803 module
27804 \end_layout
27805
27806 \end_inset
27807 </cell>
27808 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27809 \begin_inset Text
27810
27811 \begin_layout Standard
27812 description
27813 \end_layout
27814
27815 \end_inset
27816 </cell>
27817 </row>
27818 <row topline="true">
27819 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27820 \begin_inset Text
27821
27822 \begin_layout Standard
27823 STREAM_USART
27824 \end_layout
27825
27826 \end_inset
27827 </cell>
27828 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27829 \begin_inset Text
27830
27831 \begin_layout Standard
27832
27833 \family typewriter
27834 0x200000UL
27835 \end_layout
27836
27837 \end_inset
27838 </cell>
27839 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27840 \begin_inset Text
27841
27842 \begin_layout Standard
27843 USART
27844 \end_layout
27845
27846 \end_inset
27847 </cell>
27848 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27849 \begin_inset Text
27850
27851 \begin_layout Standard
27852 Writes/Reads characters via the USART peripheral
27853 \end_layout
27854
27855 \end_inset
27856 </cell>
27857 </row>
27858 <row topline="true">
27859 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27860 \begin_inset Text
27861
27862 \begin_layout Standard
27863 STREAM_MSSP
27864 \end_layout
27865
27866 \end_inset
27867 </cell>
27868 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27869 \begin_inset Text
27870
27871 \begin_layout Standard
27872
27873 \family typewriter
27874 0x210000UL
27875 \end_layout
27876
27877 \end_inset
27878 </cell>
27879 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27880 \begin_inset Text
27881
27882 \begin_layout Standard
27883 MSSP
27884 \end_layout
27885
27886 \end_inset
27887 </cell>
27888 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27889 \begin_inset Text
27890
27891 \begin_layout Standard
27892 Writes/Reads characters via the MSSP peripheral
27893 \end_layout
27894
27895 \end_inset
27896 </cell>
27897 </row>
27898 <row topline="true" bottomline="true">
27899 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27900 \begin_inset Text
27901
27902 \begin_layout Standard
27903 STREAM_USER
27904 \end_layout
27905
27906 \end_inset
27907 </cell>
27908 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27909 \begin_inset Text
27910
27911 \begin_layout Standard
27912
27913 \family typewriter
27914 0x2f0000UL
27915 \end_layout
27916
27917 \end_inset
27918 </cell>
27919 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27920 \begin_inset Text
27921
27922 \begin_layout Standard
27923 (none)
27924 \end_layout
27925
27926 \end_inset
27927 </cell>
27928 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27929 \begin_inset Text
27930
27931 \begin_layout Standard
27932 Writes/Reads characters via used defined functions
27933 \end_layout
27934
27935 \end_inset
27936 </cell>
27937 </row>
27938 </lyxtabular>
27939
27940 \end_inset
27941
27942
27943 \end_layout
27944
27945 \begin_layout Standard
27946 The stream identifiers are declared as macros in the stdio.h header.
27947 \end_layout
27948
27949 \begin_layout Standard
27950 In the libc library there exist the functions that are used to write to
27951  each of the above streams.
27952  These are
27953 \end_layout
27954
27955 \begin_layout Description
27956 _
27957 \begin_inset ERT
27958 status collapsed
27959
27960 \begin_layout Standard
27961
27962
27963 \backslash
27964 /
27965 \end_layout
27966
27967 \end_inset
27968
27969 _stream_usart_putchar writes a character at the USART stream
27970 \end_layout
27971
27972 \begin_layout Description
27973 _
27974 \begin_inset ERT
27975 status collapsed
27976
27977 \begin_layout Standard
27978
27979
27980 \backslash
27981 /
27982 \end_layout
27983
27984 \end_inset
27985
27986 _stream_mssp_putchar writes a character at the MSSP stream
27987 \end_layout
27988
27989 \begin_layout Description
27990 putchar dummy function.
27991  This writes a character to a user specified manner.
27992 \end_layout
27993
27994 \begin_layout Standard
27995 In order to increase performance 
27996 \emph on
27997 putchar 
27998 \emph default
27999 is declared in stdio.h as having its parameter in WREG (it has the wparam
28000  keyword).
28001  In stdio.h exists the macro PUTCHAR(arg) that defines the putchar function
28002  in a user-friendly way.
28003  
28004 \emph on
28005 arg
28006 \emph default
28007  is the name of the variable that holds the character to print.
28008  An example follows:
28009 \end_layout
28010
28011 \begin_layout LyX-Code
28012 #include <pic18fregs.h>
28013 \newline
28014 #include <stdio.h>
28015 \newline
28016
28017 \newline
28018 PUTCHAR( c )
28019 \end_layout
28020
28021 \begin_layout LyX-Code
28022 {
28023 \end_layout
28024
28025 \begin_layout LyX-Code
28026     PORTA = c;    /* dump character c to PORTA */
28027 \end_layout
28028
28029 \begin_layout LyX-Code
28030
28031 \newline
28032
28033 \newline
28034 void main(void)
28035 \end_layout
28036
28037 \begin_layout LyX-Code
28038 {
28039 \end_layout
28040
28041 \begin_layout LyX-Code
28042     stdout = STREAM_USER;    /* this is not necessary, since stdout points
28043 \end_layout
28044
28045 \begin_layout LyX-Code
28046                               * by default to STREAM_USER */
28047 \end_layout
28048
28049 \begin_layout LyX-Code
28050     printf (
28051 \begin_inset Quotes sld
28052 \end_inset
28053
28054 This is a printf test
28055 \backslash
28056 n
28057 \begin_inset Quotes srd
28058 \end_inset
28059
28060 );
28061 \end_layout
28062
28063 \begin_layout LyX-Code
28064 }
28065 \end_layout
28066
28067 \begin_layout LyX-Code
28068
28069 \end_layout
28070
28071 \begin_layout Subsubsection
28072 Printing functions
28073 \end_layout
28074
28075 \begin_layout Standard
28076 PIC16 contains an implementation of the printf-family of functions.
28077  There exist the following functions:
28078 \end_layout
28079
28080 \begin_layout LyX-Code
28081 extern unsigned int sprintf(char *buf, char *fmt, ...);
28082 \end_layout
28083
28084 \begin_layout LyX-Code
28085 extern unsigned int vsprintf(char *buf, char *fmt, va_list ap);
28086 \end_layout
28087
28088 \begin_layout LyX-Code
28089
28090 \end_layout
28091
28092 \begin_layout LyX-Code
28093 extern unsigned int printf(char *fmt, ...);
28094 \end_layout
28095
28096 \begin_layout LyX-Code
28097 extern unsigned int vprintf(char *fmt, va_lista ap);
28098 \end_layout
28099
28100 \begin_layout LyX-Code
28101
28102 \end_layout
28103
28104 \begin_layout LyX-Code
28105 extern unsigned int fprintf(FILE *fp, char *fmt, ...);
28106 \end_layout
28107
28108 \begin_layout LyX-Code
28109 extern unsigned int vfprintf(FILE *fp, char *fmt, va_list ap);
28110 \end_layout
28111
28112 \begin_layout Standard
28113 For sprintf and vsprintf 
28114 \emph on
28115 buf 
28116 \emph default
28117 should normally be a data pointer where the resulting string will be placed.
28118  No range checking is done so the user should allocate the necessery buffer.
28119  For fprintf and vfprintf 
28120 \emph on
28121 fp
28122 \emph default
28123  should be a stream pointer (i.e.
28124  stdout, STREAM_MSSP, etc...).
28125 \end_layout
28126
28127 \begin_layout Subsubsection
28128 Signals
28129 \end_layout
28130
28131 \begin_layout Standard
28132 The PIC18F family of microcontrollers supports a number of interrupt sources.
28133  A list of these interrupts is shown in the following table:
28134 \end_layout
28135
28136 \begin_layout Standard
28137 \align center
28138 \begin_inset Tabular
28139 <lyxtabular version="3" rows="11" columns="4">
28140 <features>
28141 <column alignment="left" valignment="top" leftline="true" width="0">
28142 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28143 <column alignment="left" valignment="top" leftline="true" width="0">
28144 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28145 <row topline="true" bottomline="true">
28146 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28147 \begin_inset Text
28148
28149 \begin_layout Standard
28150 signal name
28151 \end_layout
28152
28153 \end_inset
28154 </cell>
28155 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28156 \begin_inset Text
28157
28158 \begin_layout Standard
28159 description
28160 \end_layout
28161
28162 \end_inset
28163 </cell>
28164 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28165 \begin_inset Text
28166
28167 \begin_layout Standard
28168 signal name
28169 \end_layout
28170
28171 \end_inset
28172 </cell>
28173 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28174 \begin_inset Text
28175
28176 \begin_layout Standard
28177 descritpion
28178 \end_layout
28179
28180 \end_inset
28181 </cell>
28182 </row>
28183 <row topline="true">
28184 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28185 \begin_inset Text
28186
28187 \begin_layout Standard
28188 SIG_RB
28189 \end_layout
28190
28191 \end_inset
28192 </cell>
28193 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28194 \begin_inset Text
28195
28196 \begin_layout Standard
28197 PORTB change interrupt
28198 \end_layout
28199
28200 \end_inset
28201 </cell>
28202 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28203 \begin_inset Text
28204
28205 \begin_layout Standard
28206 SIG_EE
28207 \end_layout
28208
28209 \end_inset
28210 </cell>
28211 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28212 \begin_inset Text
28213
28214 \begin_layout Standard
28215 EEPROM/FLASH write complete interrupt
28216 \end_layout
28217
28218 \end_inset
28219 </cell>
28220 </row>
28221 <row topline="true">
28222 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28223 \begin_inset Text
28224
28225 \begin_layout Standard
28226 SIG_INT0
28227 \end_layout
28228
28229 \end_inset
28230 </cell>
28231 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28232 \begin_inset Text
28233
28234 \begin_layout Standard
28235 INT0 external interrupt
28236 \end_layout
28237
28238 \end_inset
28239 </cell>
28240 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28241 \begin_inset Text
28242
28243 \begin_layout Standard
28244 SIG_BCOL
28245 \end_layout
28246
28247 \end_inset
28248 </cell>
28249 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28250 \begin_inset Text
28251
28252 \begin_layout Standard
28253 Bus collision interrupt
28254 \end_layout
28255
28256 \end_inset
28257 </cell>
28258 </row>
28259 <row topline="true">
28260 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28261 \begin_inset Text
28262
28263 \begin_layout Standard
28264 SIG_INT1
28265 \end_layout
28266
28267 \end_inset
28268 </cell>
28269 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28270 \begin_inset Text
28271
28272 \begin_layout Standard
28273 INT1 external interrupt
28274 \end_layout
28275
28276 \end_inset
28277 </cell>
28278 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28279 \begin_inset Text
28280
28281 \begin_layout Standard
28282 SIG_LVD
28283 \end_layout
28284
28285 \end_inset
28286 </cell>
28287 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28288 \begin_inset Text
28289
28290 \begin_layout Standard
28291 Low voltage detect interrupt
28292 \end_layout
28293
28294 \end_inset
28295 </cell>
28296 </row>
28297 <row topline="true">
28298 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28299 \begin_inset Text
28300
28301 \begin_layout Standard
28302 SIG_INT2
28303 \end_layout
28304
28305 \end_inset
28306 </cell>
28307 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28308 \begin_inset Text
28309
28310 \begin_layout Standard
28311 INT2 external interrupt
28312 \end_layout
28313
28314 \end_inset
28315 </cell>
28316 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28317 \begin_inset Text
28318
28319 \begin_layout Standard
28320 SIG_PSP
28321 \end_layout
28322
28323 \end_inset
28324 </cell>
28325 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28326 \begin_inset Text
28327
28328 \begin_layout Standard
28329 Parallel slave port interrupt
28330 \end_layout
28331
28332 \end_inset
28333 </cell>
28334 </row>
28335 <row topline="true">
28336 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28337 \begin_inset Text
28338
28339 \begin_layout Standard
28340 SIG_CCP1
28341 \end_layout
28342
28343 \end_inset
28344 </cell>
28345 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28346 \begin_inset Text
28347
28348 \begin_layout Standard
28349 CCP1 module interrupt
28350 \end_layout
28351
28352 \end_inset
28353 </cell>
28354 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28355 \begin_inset Text
28356
28357 \begin_layout Standard
28358 SIG_AD
28359 \end_layout
28360
28361 \end_inset
28362 </cell>
28363 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28364 \begin_inset Text
28365
28366 \begin_layout Standard
28367 AD convertion complete interrupt
28368 \end_layout
28369
28370 \end_inset
28371 </cell>
28372 </row>
28373 <row topline="true">
28374 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28375 \begin_inset Text
28376
28377 \begin_layout Standard
28378 SIG_CCP2
28379 \end_layout
28380
28381 \end_inset
28382 </cell>
28383 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28384 \begin_inset Text
28385
28386 \begin_layout Standard
28387 CCP2 module interrupt
28388 \end_layout
28389
28390 \end_inset
28391 </cell>
28392 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28393 \begin_inset Text
28394
28395 \begin_layout Standard
28396 SIG_RC
28397 \end_layout
28398
28399 \end_inset
28400 </cell>
28401 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28402 \begin_inset Text
28403
28404 \begin_layout Standard
28405 USART receive interrupt
28406 \end_layout
28407
28408 \end_inset
28409 </cell>
28410 </row>
28411 <row topline="true">
28412 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28413 \begin_inset Text
28414
28415 \begin_layout Standard
28416 SIG_TMR0
28417 \end_layout
28418
28419 \end_inset
28420 </cell>
28421 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28422 \begin_inset Text
28423
28424 \begin_layout Standard
28425 TMR0 overflow interrupt
28426 \end_layout
28427
28428 \end_inset
28429 </cell>
28430 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28431 \begin_inset Text
28432
28433 \begin_layout Standard
28434 SIG_TX
28435 \end_layout
28436
28437 \end_inset
28438 </cell>
28439 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28440 \begin_inset Text
28441
28442 \begin_layout Standard
28443 USART transmit interrupt
28444 \end_layout
28445
28446 \end_inset
28447 </cell>
28448 </row>
28449 <row topline="true">
28450 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28451 \begin_inset Text
28452
28453 \begin_layout Standard
28454 SIG_TMR1
28455 \end_layout
28456
28457 \end_inset
28458 </cell>
28459 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28460 \begin_inset Text
28461
28462 \begin_layout Standard
28463 TMR1 overflow interrupt
28464 \end_layout
28465
28466 \end_inset
28467 </cell>
28468 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28469 \begin_inset Text
28470
28471 \begin_layout Standard
28472 SIG_MSSP
28473 \end_layout
28474
28475 \end_inset
28476 </cell>
28477 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28478 \begin_inset Text
28479
28480 \begin_layout Standard
28481 SSP receive/transmit interrupt
28482 \end_layout
28483
28484 \end_inset
28485 </cell>
28486 </row>
28487 <row topline="true">
28488 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28489 \begin_inset Text
28490
28491 \begin_layout Standard
28492 SIG_TMR2
28493 \end_layout
28494
28495 \end_inset
28496 </cell>
28497 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28498 \begin_inset Text
28499
28500 \begin_layout Standard
28501 TMR2 matches PR2 interrupt
28502 \end_layout
28503
28504 \end_inset
28505 </cell>
28506 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28507 \begin_inset Text
28508
28509 \begin_layout Standard
28510
28511 \end_layout
28512
28513 \end_inset
28514 </cell>
28515 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28516 \begin_inset Text
28517
28518 \begin_layout Standard
28519
28520 \end_layout
28521
28522 \end_inset
28523 </cell>
28524 </row>
28525 <row topline="true" bottomline="true">
28526 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28527 \begin_inset Text
28528
28529 \begin_layout Standard
28530 SIG_TMR3
28531 \end_layout
28532
28533 \end_inset
28534 </cell>
28535 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28536 \begin_inset Text
28537
28538 \begin_layout Standard
28539 TMR3 overflow interrupt
28540 \end_layout
28541
28542 \end_inset
28543 </cell>
28544 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28545 \begin_inset Text
28546
28547 \begin_layout Standard
28548
28549 \end_layout
28550
28551 \end_inset
28552 </cell>
28553 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28554 \begin_inset Text
28555
28556 \begin_layout Standard
28557
28558 \end_layout
28559
28560 \end_inset
28561 </cell>
28562 </row>
28563 </lyxtabular>
28564
28565 \end_inset
28566
28567
28568 \end_layout
28569
28570 \begin_layout Standard
28571 The prototypes for these names are defined in the header file 
28572 \emph on
28573 signal.h
28574 \emph default
28575  .
28576 \end_layout
28577
28578 \begin_layout Standard
28579 In order to simplify signal handling, a number of macros is provided:
28580 \end_layout
28581
28582 \begin_layout List
28583 \labelwidthstring 00.00.0000
28584 DEF_INTHIGH(name) begin the definition of the interrupt dispatch table for
28585  high priority interrupts.
28586  
28587 \emph on
28588 name
28589 \emph default
28590  is the function name to use.
28591 \end_layout
28592
28593 \begin_layout List
28594 \labelwidthstring 00.00.0000
28595 DEF_INTLOW(name) begin the definition of the interrupt dispatch table fo
28596  low priority interrupt.
28597  
28598 \emph on
28599 name
28600 \emph default
28601  is the function name to use.
28602 \end_layout
28603
28604 \begin_layout List
28605 \labelwidthstring 00.00.0000
28606 DEF_HANDLER(sig,handler) define a handler for signal 
28607 \emph on
28608 sig.
28609 \end_layout
28610
28611 \begin_layout List
28612 \labelwidthstring 00.00.0000
28613 END_DEF end the declaration of the dispatch table.
28614 \end_layout
28615
28616 \begin_layout Standard
28617 Additionally there are two more macros to simplify the declaration of the
28618  signal handler:
28619 \end_layout
28620
28621 \begin_layout List
28622 \labelwidthstring 00.00.0000
28623
28624 \series medium
28625 SIGHANDLER(handler) 
28626 \series default
28627 this declares the function prototype for the 
28628 \emph on
28629 handler
28630 \emph default
28631  function.
28632 \end_layout
28633
28634 \begin_layout List
28635 \labelwidthstring 00.00.0000
28636 SIGHANDLERNAKED(handler) same as SIGHANDLER() but declares a naked function.
28637 \end_layout
28638
28639 \begin_layout Standard
28640 An example of using the macros above is shown below:
28641 \end_layout
28642
28643 \begin_layout LyX-Code
28644 #include <pic18fregs.h>
28645 \end_layout
28646
28647 \begin_layout LyX-Code
28648 #include <signal.h>
28649 \newline
28650
28651 \newline
28652 DEF_INTHIGH(high_int)
28653 \end_layout
28654
28655 \begin_layout LyX-Code
28656 DEF_HANDLER(SIG_TMR0, _tmr0_handler)
28657 \end_layout
28658
28659 \begin_layout LyX-Code
28660 DEF_HANDLER(SIG_BCOL, _bcol_handler)
28661 \end_layout
28662
28663 \begin_layout LyX-Code
28664 END_DEF
28665 \newline
28666
28667 \newline
28668 SIGHANDLER(_tmr0_handler)
28669 \end_layout
28670
28671 \begin_layout LyX-Code
28672 {
28673 \end_layout
28674
28675 \begin_layout LyX-Code
28676   /* action to be taken when timer 0 overflows */
28677 \end_layout
28678
28679 \begin_layout LyX-Code
28680 }
28681 \newline
28682
28683 \newline
28684 SIGHANDLERNAKED(_bcol_handler)
28685 \end_layout
28686
28687 \begin_layout LyX-Code
28688 {
28689 \end_layout
28690
28691 \begin_layout LyX-Code
28692   _asm
28693 \end_layout
28694
28695 \begin_layout LyX-Code
28696     /* action to be taken when bus collision occurs */
28697 \end_layout
28698
28699 \begin_layout LyX-Code
28700     retfie
28701 \end_layout
28702
28703 \begin_layout LyX-Code
28704  _endasm;
28705 \end_layout
28706
28707 \begin_layout LyX-Code
28708 }
28709 \end_layout
28710
28711 \begin_layout Standard
28712
28713 \series bold
28714 NOTES:
28715 \series default
28716  Special care should be taken when using the above scheme:
28717 \end_layout
28718
28719 \begin_layout Itemize
28720 do not place a colon (;) at the end of the DEF_* and END_DEF macros.
28721 \end_layout
28722
28723 \begin_layout Itemize
28724 when declaring SIGHANDLERNAKED handler never forget to use 
28725 \emph on
28726 retfie
28727 \emph default
28728  for proper returning.
28729 \end_layout
28730
28731 \begin_layout Subsection
28732 PIC16 Port -- Tips
28733 \end_layout
28734
28735 \begin_layout Standard
28736 Here you can find some general tips for compiling programs with SDCC/pic16.
28737 \end_layout
28738
28739 \begin_layout Subsubsection
28740 Stack size
28741 \end_layout
28742
28743 \begin_layout Standard
28744 The default stack
28745 \begin_inset LatexCommand \index{PIC16!stack}
28746
28747 \end_inset
28748
28749  size (that is 64 bytes) probably is enough for many programs.
28750  One must take care that when there are many levels of function nesting,
28751  or there is excessive usage of stack, its size should be extended.
28752  An example of such a case is the printf/sprintf family of functions.
28753  If you encounter problems like not being able to print integers, then you
28754  need to set the stack size around the maximum (256 for small stack model).
28755  The following diagram shows what happens when calling printf to print an
28756  integer:
28757 \end_layout
28758
28759 \begin_layout LyX-Code
28760 printf () --> ltoa () --> ultoa () --> divschar ()
28761 \end_layout
28762
28763 \begin_layout Standard
28764 It is should be understood that stack is easily consumed when calling complicate
28765 d functions.
28766  Using command line arguments like -
28767 \begin_inset ERT
28768 status collapsed
28769
28770 \begin_layout Standard
28771
28772
28773 \backslash
28774 /
28775 \end_layout
28776
28777 \end_inset
28778
28779 -fommit-frame-pointer might reduce stack usage by not creating unnecessery
28780  stack frames.
28781  Other ways to reduce stack usage may exist.
28782 \end_layout
28783
28784 \begin_layout Subsection
28785 Known Bugs
28786 \end_layout
28787
28788 \begin_layout Standard
28789 The PIC16 Port currently does not pass SDCC's regression test
28790 \begin_inset LatexCommand \index{Regression test (PIC16)}
28791
28792 \end_inset
28793
28794  suite (see section 
28795 \begin_inset LatexCommand \ref{sec:Quality-control}
28796
28797 \end_inset
28798
28799 ) and thus the snapshot build regression tests for the PIC16 target are
28800  currently disabled for all hosts
28801 \emph on
28802 .
28803 \end_layout
28804
28805 \begin_layout Chapter
28806 Debugging
28807 \end_layout
28808
28809 \begin_layout Standard
28810 There are several approaches to debugging your code.
28811  This chapter is meant to show your options and to give detail on some of
28812  them:
28813 \newline
28814
28815 \newline
28816 When writing your code:
28817 \end_layout
28818
28819 \begin_layout Itemize
28820 write your code with debugging in mind (avoid duplicating code, put conceptually
28821  similar variables into structs, use structured code, have strategic points
28822  within your code where all variables are consistent, ...)
28823 \end_layout
28824
28825 \begin_layout Itemize
28826 run a syntax-checking tool like splint
28827 \begin_inset LatexCommand \index{splint (syntax checking tool)}
28828
28829 \end_inset
28830
28831
28832 \begin_inset LatexCommand \index{lint (syntax checking tool)}
28833
28834 \end_inset
28835
28836  (see -
28837 \begin_inset ERT
28838 status collapsed
28839
28840 \begin_layout Standard
28841
28842
28843 \backslash
28844 /
28845 \end_layout
28846
28847 \end_inset
28848
28849 -more-pedantic 
28850 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
28851
28852 \end_inset
28853
28854 ) over the code.
28855 \end_layout
28856
28857 \begin_layout Itemize
28858 for the high level code use a C-compiler (like f.e.
28859  GCC) to compile run and debug the code on your host.
28860  See (see -
28861 \begin_inset ERT
28862 status collapsed
28863
28864 \begin_layout Standard
28865
28866
28867 \backslash
28868 /
28869 \end_layout
28870
28871 \end_inset
28872
28873 -more-pedantic 
28874 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
28875
28876 \end_inset
28877
28878 ) on how to handle syntax extensions like __xdata, __at(), ...
28879  
28880 \end_layout
28881
28882 \begin_layout Itemize
28883 use another C-compiler to compile code for your target.
28884  Always an option but not recommended:) And not very likely to help you.
28885  If you seriously consider walking this path you should at least occasionally
28886  check portability of your code.
28887  Most commercial compiler vendors will offer an evaluation version so you
28888  can test compile your code or snippets of your code.
28889 \end_layout
28890
28891 \begin_layout Standard
28892 Debugging on a simulator:
28893 \end_layout
28894
28895 \begin_layout Itemize
28896 there is a separate section about SDCDB (section 
28897 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
28898
28899 \end_inset
28900
28901 ) below.
28902 \end_layout
28903
28904 \begin_layout Itemize
28905 or (8051 specific) use a freeware/commercial simulator which interfaces
28906  to the AOMF
28907 \begin_inset LatexCommand \index{AOMF, AOMF51}
28908
28909 \end_inset
28910
28911  file (see 
28912 \begin_inset LatexCommand \ref{OMF file}
28913
28914 \end_inset
28915
28916 ) optionally generated by SDCC.
28917 \end_layout
28918
28919 \begin_layout Standard
28920 Debugging On-target: 
28921 \end_layout
28922
28923 \begin_layout Itemize
28924 use a MCU port pin to serially output debug data to the RS232 port of your
28925  host.
28926  You'll probably want some level shifting device typically involving a MAX232
28927  or similar IC.
28928  If the hardware serial port of the MCU is not available search for 'Software
28929  UART' in your favourite search machine.
28930 \end_layout
28931
28932 \begin_layout Itemize
28933 use an on-target monitor.
28934  In this context a monitor is a small program which usually accepts commands
28935  via a serial line and allows to set program counter, to single step through
28936  a program and read/write memory locations.
28937  For the 8051 good examples of monitors are paulmon and cmon51 (see section
28938  
28939 \begin_inset LatexCommand \ref{sec:Related-open-source-tools}
28940
28941 \end_inset
28942
28943 ).
28944 \end_layout
28945
28946 \begin_layout Itemize
28947 toggle MCU port pins at strategic points within your code and use an oscilloscop
28948 e.
28949  A 
28950 \emph on
28951 digital oscilloscope
28952 \emph default
28953
28954 \begin_inset LatexCommand \index{Oscilloscope}
28955
28956 \end_inset
28957
28958  with deep trace memory is really helpful especially if you have to debug
28959  a realtime application.
28960  If you need to monitor more pins than your oscilloscope provides you can
28961  sometimes get away with a small R-2R network.
28962  On a single channel oscilloscope you could f.e.
28963  monitor 2 push-pull driven pins by connecting one via a 10\InsetSpace ~
28964 k
28965 \begin_inset Formula $\Omega$
28966 \end_inset
28967
28968  resistor and the other one by a 5\InsetSpace ~
28969 k
28970 \begin_inset Formula $\Omega$
28971 \end_inset
28972
28973  resistor to the oscilloscope probe (check output drive capability of the
28974  pins you want to monitor).
28975  If you need to monitor many more pins a 
28976 \emph on
28977 logic analyzer
28978 \emph default
28979  will be handy.
28980 \end_layout
28981
28982 \begin_layout Itemize
28983 use an ICE (
28984 \emph on
28985 i
28986 \emph default
28987
28988 \emph on
28989 c
28990 \emph default
28991 ircuit 
28992 \emph on
28993 e
28994 \emph default
28995 mulator
28996 \begin_inset LatexCommand \index{ICE (in circuit emulator)}
28997
28998 \end_inset
28999
29000 ).
29001  Usually very expensive.
29002  And very nice to have too.
29003  And usually locks you (for years...) to the devices the ICE can emulate.
29004  
29005 \end_layout
29006
29007 \begin_layout Itemize
29008 use a remote debugger.
29009  In most 8-bit systems the symbol information is not available on the target,
29010  and a complete debugger is too bulky for the target system.
29011  Therefore usually a debugger on the host system connects to an on-target
29012  debugging stub which accepts only primitive commands.
29013  
29014 \newline
29015 Terms to enter into your favourite search engine could be 'remote debugging',
29016  'gdb stub' or 'inferior debugger'.
29017  (is there one?)
29018 \end_layout
29019
29020 \begin_layout Itemize
29021 use an on target hardware debugger.
29022  Some of the more modern MCUs include hardware support for setting break
29023  points and monitoring/changing variables by using dedicated hardware pins.
29024  This facility doesn't require additional code to run on the target and
29025  
29026 \emph on
29027 usually
29028 \emph default
29029  doesn't affect runtime behaviour until a breakpoint is hit.
29030  For the mcs51 most hardware debuggers use the AOMF
29031 \begin_inset LatexCommand \index{AOMF, AOMF51}
29032
29033 \end_inset
29034
29035  file (see 
29036 \begin_inset LatexCommand \ref{OMF file}
29037
29038 \end_inset
29039
29040 ) as input file.
29041  
29042 \end_layout
29043
29044 \begin_layout Standard
29045 Last not least:
29046 \end_layout
29047
29048 \begin_layout Itemize
29049 if you are not familiar with any of the following terms you're likely to
29050  run into problems rather sooner than later: 
29051 \emph on
29052 volatile
29053 \emph default
29054
29055 \emph on
29056 atomic
29057 \emph default
29058
29059 \emph on
29060 memory map
29061 \emph default
29062
29063 \emph on
29064 overlay
29065 \emph default
29066 .
29067  As an embedded programmer you 
29068 \emph on
29069 have
29070 \emph default
29071  to know them so why not look them up 
29072 \emph on
29073 before
29074 \emph default
29075  you have problems?)
29076 \end_layout
29077
29078 \begin_layout Itemize
29079 tell someone else about your problem (actually this is a surprisingly effective
29080  means to hunt down the bug even if the listener is not familiar with your
29081  environment).
29082  As 'failure to communicate' is probably one of the job-induced deformations
29083  of an embedded programmer this is highly encouraged.
29084 \end_layout
29085
29086 \begin_layout Section
29087 Debugging with SDCDB
29088 \begin_inset LatexCommand \label{cha:Debugging-with-SDCDB}
29089
29090 \end_inset
29091
29092
29093 \begin_inset LatexCommand \index{SDCDB (debugger)}
29094
29095 \end_inset
29096
29097  
29098 \end_layout
29099
29100 \begin_layout Standard
29101 SDCC is distributed with a source level debugger
29102 \begin_inset LatexCommand \index{Debugger}
29103
29104 \end_inset
29105
29106 .
29107  The debugger uses a command line interface, the command repertoire of the
29108  debugger has been kept as close to gdb
29109 \begin_inset LatexCommand \index{gdb}
29110
29111 \end_inset
29112
29113  (the GNU debugger) as possible.
29114  The configuration and build process is part of the standard compiler installati
29115 on, which also builds and installs the debugger in the target directory
29116  specified during configuration.
29117  The debugger allows you debug BOTH at the C source and at the ASM source
29118  level.
29119 \end_layout
29120
29121 \begin_layout Subsection
29122 Compiling for Debugging
29123 \end_layout
29124
29125 \begin_layout Standard
29126 The -
29127 \begin_inset ERT
29128 status collapsed
29129
29130 \begin_layout Standard
29131
29132
29133 \backslash
29134 /
29135 \end_layout
29136
29137 \end_inset
29138
29139 -debug
29140 \begin_inset LatexCommand \index{-\/-debug}
29141
29142 \end_inset
29143
29144  option must be specified for all files for which debug information is to
29145  be generated.
29146  The compiler generates a .adb file for each of these files.
29147  The linker creates the .cdb
29148 \begin_inset LatexCommand \index{<file>.cdb}
29149
29150 \end_inset
29151
29152  file from the .adb
29153 \begin_inset LatexCommand \index{<file>.adb}
29154
29155 \end_inset
29156
29157  files and the address information.
29158  This .cdb is used by the debugger.
29159 \end_layout
29160
29161 \begin_layout Subsection
29162 How the Debugger Works
29163 \end_layout
29164
29165 \begin_layout Standard
29166 When the -
29167 \begin_inset ERT
29168 status collapsed
29169
29170 \begin_layout Standard
29171
29172
29173 \backslash
29174 /
29175 \end_layout
29176
29177 \end_inset
29178
29179 -debug option is specified the compiler generates extra symbol information
29180  some of which are put into the assembler source and some are put into the
29181  .adb file.
29182  Then the linker creates the .cdb file from the individual .adb files with
29183  the address information for the symbols.
29184  The debugger reads the symbolic information generated by the compiler &
29185  the address information generated by the linker.
29186  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
29187  execution is controlled by the debugger.
29188  When a command is issued for the debugger, it translates it into appropriate
29189  commands for the simulator.
29190  (Currently SDCDM only connects to the simulator but 
29191 \emph on
29192 newcdb
29193 \emph default
29194  at 
29195 \begin_inset LatexCommand \url{http://ec2drv.sf.net/}
29196
29197 \end_inset
29198
29199  is an effort to connect directly to the hardware.) 
29200 \end_layout
29201
29202 \begin_layout Subsection
29203 Starting the Debugger SDCDB
29204 \end_layout
29205
29206 \begin_layout Standard
29207 The debugger can be started using the following command line.
29208  (Assume the file you are debugging has the file name foo).
29209 \newline
29210
29211 \newline
29212
29213 \family sans
29214 \series bold
29215 sdcdb foo
29216 \newline
29217
29218 \family default
29219 \series default
29220
29221 \newline
29222 The debugger will look for the following files.
29223 \end_layout
29224
29225 \begin_layout Itemize
29226 foo.c - the source file.
29227 \end_layout
29228
29229 \begin_layout Itemize
29230 foo.cdb - the debugger symbol information file.
29231 \end_layout
29232
29233 \begin_layout Itemize
29234 foo.ihx - the Intel hex format
29235 \begin_inset LatexCommand \index{Intel hex format}
29236
29237 \end_inset
29238
29239  object file.
29240 \end_layout
29241
29242 \begin_layout Subsection
29243 SDCDB Command Line Options
29244 \end_layout
29245
29246 \begin_layout Itemize
29247 -
29248 \begin_inset ERT
29249 status collapsed
29250
29251 \begin_layout Standard
29252
29253
29254 \backslash
29255 /
29256 \end_layout
29257
29258 \end_inset
29259
29260 -directory=<source file directory> this option can used to specify the directory
29261  search list.
29262  The debugger will look into the directory list specified for source, cdb
29263  & ihx files.
29264  The items in the directory list must be separated by ':', e.g.
29265  if the source files can be in the directories /home/src1 and /home/src2,
29266  the -
29267 \begin_inset ERT
29268 status collapsed
29269
29270 \begin_layout Standard
29271
29272
29273 \backslash
29274 /
29275 \end_layout
29276
29277 \end_inset
29278
29279 -directory option should be -
29280 \begin_inset ERT
29281 status collapsed
29282
29283 \begin_layout Standard
29284
29285
29286 \backslash
29287 /
29288 \end_layout
29289
29290 \end_inset
29291
29292 -directory=/home/src1:/home/src2.
29293  Note there can be no spaces in the option.
29294  
29295 \end_layout
29296
29297 \begin_layout Itemize
29298 -cd <directory> - change to the <directory>.
29299 \end_layout
29300
29301 \begin_layout Itemize
29302 -fullname - used by GUI front ends.
29303 \end_layout
29304
29305 \begin_layout Itemize
29306 -cpu <cpu-type> - this argument is passed to the simulator please see the
29307  simulator docs for details.
29308 \end_layout
29309
29310 \begin_layout Itemize
29311 -X <Clock frequency > this options is passed to the simulator please see
29312  the simulator docs for details.
29313 \end_layout
29314
29315 \begin_layout Itemize
29316 -s <serial port file> passed to simulator see the simulator docs for details.
29317 \end_layout
29318
29319 \begin_layout Itemize
29320 -S <serial in,out> passed to simulator see the simulator docs for details.
29321 \end_layout
29322
29323 \begin_layout Itemize
29324 -k <port number> passed to simulator see the simulator docs for details.
29325 \end_layout
29326
29327 \begin_layout Subsection
29328 SDCDB Debugger Commands
29329 \end_layout
29330
29331 \begin_layout Standard
29332 As mentioned earlier the command interface for the debugger has been deliberatel
29333 y kept as close the GNU debugger gdb, as possible.
29334  This will help the integration with existing graphical user interfaces
29335  (like ddd, xxgdb or xemacs) existing for the GNU debugger.
29336  If you use a graphical user interface for the debugger you can skip this
29337  section.
29338 \end_layout
29339
29340 \begin_layout Subsubsection*
29341 break [line | file:line | function | file:function]
29342 \end_layout
29343
29344 \begin_layout Standard
29345 Set breakpoint at specified line or function:
29346 \newline
29347
29348 \newline
29349
29350 \family sans
29351 \series bold
29352 sdcdb>break 100 
29353 \newline
29354 sdcdb>break foo.c:100
29355 \newline
29356 sdcdb>break funcfoo
29357 \newline
29358 sdcdb>break foo.c:funcfoo
29359 \end_layout
29360
29361 \begin_layout Subsubsection*
29362 clear [line | file:line | function | file:function ]
29363 \end_layout
29364
29365 \begin_layout Standard
29366 Clear breakpoint at specified line or function:
29367 \newline
29368
29369 \newline
29370
29371 \family sans
29372 \series bold
29373 sdcdb>clear 100
29374 \newline
29375 sdcdb>clear foo.c:100
29376 \newline
29377 sdcdb>clear funcfoo
29378 \newline
29379 sdcdb>clear foo.c:funcfoo
29380 \end_layout
29381
29382 \begin_layout Subsubsection*
29383 continue
29384 \end_layout
29385
29386 \begin_layout Standard
29387 Continue program being debugged, after breakpoint.
29388 \end_layout
29389
29390 \begin_layout Subsubsection*
29391 finish
29392 \end_layout
29393
29394 \begin_layout Standard
29395 Execute till the end of the current function.
29396 \end_layout
29397
29398 \begin_layout Subsubsection*
29399 delete [n]
29400 \end_layout
29401
29402 \begin_layout Standard
29403 Delete breakpoint number 'n'.
29404  If used without any option clear ALL user defined break points.
29405 \end_layout
29406
29407 \begin_layout Subsubsection*
29408 info [break | stack | frame | registers ]
29409 \end_layout
29410
29411 \begin_layout Itemize
29412 info break - list all breakpoints
29413 \end_layout
29414
29415 \begin_layout Itemize
29416 info stack - show the function call stack.
29417 \end_layout
29418
29419 \begin_layout Itemize
29420 info frame - show information about the current execution frame.
29421 \end_layout
29422
29423 \begin_layout Itemize
29424 info registers - show content of all registers.
29425 \end_layout
29426
29427 \begin_layout Subsubsection*
29428 step
29429 \end_layout
29430
29431 \begin_layout Standard
29432 Step program until it reaches a different source line.
29433  Note: pressing <return> repeats the last command.
29434 \end_layout
29435
29436 \begin_layout Subsubsection*
29437 next
29438 \end_layout
29439
29440 \begin_layout Standard
29441 Step program, proceeding through subroutine calls.
29442 \end_layout
29443
29444 \begin_layout Subsubsection*
29445 run
29446 \end_layout
29447
29448 \begin_layout Standard
29449 Start debugged program.
29450 \end_layout
29451
29452 \begin_layout Subsubsection*
29453 ptype variable 
29454 \end_layout
29455
29456 \begin_layout Standard
29457 Print type information of the variable.
29458 \end_layout
29459
29460 \begin_layout Subsubsection*
29461 print variable
29462 \end_layout
29463
29464 \begin_layout Standard
29465 print value of variable.
29466 \end_layout
29467
29468 \begin_layout Subsubsection*
29469 file filename
29470 \end_layout
29471
29472 \begin_layout Standard
29473 load the given file name.
29474  Note this is an alternate method of loading file for debugging.
29475 \end_layout
29476
29477 \begin_layout Subsubsection*
29478 frame
29479 \end_layout
29480
29481 \begin_layout Standard
29482 print information about current frame.
29483 \end_layout
29484
29485 \begin_layout Subsubsection*
29486 set srcmode
29487 \end_layout
29488
29489 \begin_layout Standard
29490 Toggle between C source & assembly source.
29491 \end_layout
29492
29493 \begin_layout Subsubsection*
29494 ! simulator command
29495 \end_layout
29496
29497 \begin_layout Standard
29498 Send the string following '!' to the simulator, the simulator response is
29499  displayed.
29500  Note the debugger does not interpret the command being sent to the simulator,
29501  so if a command like 'go' is sent the debugger can loose its execution
29502  context and may display incorrect values.
29503 \end_layout
29504
29505 \begin_layout Subsubsection*
29506 quit
29507 \end_layout
29508
29509 \begin_layout Standard
29510 "Watch me now.
29511  Iam going Down.
29512  My name is Bobby Brown"
29513 \end_layout
29514
29515 \begin_layout Subsection
29516 Interfacing SDCDB with DDD
29517 \end_layout
29518
29519 \begin_layout Standard
29520 \begin_inset Note Note
29521 status collapsed
29522
29523 \begin_layout Standard
29524 The screenshot was converted from png to eps with: 
29525 \begin_inset Quotes sld
29526 \end_inset
29527
29528 bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps
29529 \begin_inset Quotes srd
29530 \end_inset
29531
29532  which produces a pretty compact eps file which is free from compression
29533  artifacts.
29534 \end_layout
29535
29536 \begin_layout Standard
29537 The screenshot was included in sdccman.lyx cvs version 1.120 but later removed
29538  as this broke the build system on Sourceforge (pdf-file was broken.
29539  pdflatex does not accept eps files).
29540 \end_layout
29541
29542 \end_inset
29543
29544
29545 \end_layout
29546
29547 \begin_layout Standard
29548 The 
29549 \emph on
29550 p
29551 \emph default
29552 ortable 
29553 \emph on
29554 n
29555 \emph default
29556 etwork 
29557 \emph on
29558 g
29559 \emph default
29560 raphics File 
29561 \size footnotesize
29562
29563 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/doc/figures/ddd_example.png}
29564
29565 \end_inset
29566
29567
29568 \size default
29569  shows a screenshot of a debugging session with DDD
29570 \begin_inset LatexCommand \index{DDD (debugger)}
29571
29572 \end_inset
29573
29574  (Unix only) on a simulated 8032.
29575  The debugging session might not run as smoothly as the screenshot suggests.
29576  The debugger allows setting of breakpoints, displaying and changing variables,
29577  single stepping through C and assembler code.
29578  
29579 \newline
29580 The source was compiled with 
29581 \family sans
29582 \series bold
29583
29584 \newline
29585
29586 \newline
29587 sdcc -
29588 \family default
29589 \series default
29590
29591 \begin_inset ERT
29592 status collapsed
29593
29594 \begin_layout Standard
29595
29596
29597 \backslash
29598 /
29599 \end_layout
29600
29601 \end_inset
29602
29603
29604 \family sans
29605 \series bold
29606 -debug ddd_example.c
29607 \family default
29608 \series default
29609  
29610 \family sans
29611 \series bold
29612
29613 \newline
29614
29615 \family default
29616 \series default
29617
29618 \newline
29619 and DDD was invoked with 
29620 \family sans
29621 \series bold
29622
29623 \newline
29624
29625 \newline
29626 ddd -debugger "sdcdb -cpu 8032 ddd_example"
29627 \end_layout
29628
29629 \begin_layout Standard
29630 \begin_inset Note Note
29631 status open
29632
29633 \begin_layout Standard
29634 Check that the double quotes or an apostroph within the command line survive
29635  the LyX tool chain.
29636  Previously the apostrophs got slanted in the PDF output so a cut and paste
29637  did not work.
29638 \end_layout
29639
29640 \end_inset
29641
29642
29643 \end_layout
29644
29645 \begin_layout Subsection
29646 Interfacing SDCDB with XEmacs
29647 \begin_inset LatexCommand \index{XEmacs}
29648
29649 \end_inset
29650
29651
29652 \begin_inset LatexCommand \index{Emacs}
29653
29654 \end_inset
29655
29656
29657 \end_layout
29658
29659 \begin_layout Standard
29660 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
29661  sdcdb.el and sdcdbsrc.el.
29662  These two files can be found in the $(prefix)/bin directory after the installat
29663 ion is complete.
29664  These files need to be loaded into XEmacs for the interface to work.
29665  This can be done at XEmacs startup time by inserting the following into
29666  your '.xemacs' file (which can be found in your HOME directory): 
29667 \newline
29668
29669 \newline
29670
29671 \family typewriter
29672 (load-file sdcdbsrc.el) 
29673 \family default
29674
29675 \newline
29676
29677 \newline
29678 .xemacs is a lisp file so the () around the command is REQUIRED.
29679  The files can also be loaded dynamically while XEmacs is running, set the
29680  environment variable 'EMACSLOADPATH' to the installation bin directory
29681  (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
29682  To start the interface enter the following command: 
29683 \newline
29684
29685 \newline
29686
29687 \family sans
29688 \series bold
29689 ESC-x sdcdbsrc
29690 \family default
29691 \series default
29692
29693 \newline
29694
29695 \newline
29696 You will prompted to enter the file name to be debugged.
29697  
29698 \newline
29699
29700 \newline
29701 The command line options that are passed to the simulator directly are
29702  bound to default values in the file sdcdbsrc.el.
29703  The variables are listed below, these values maybe changed as required.
29704 \end_layout
29705
29706 \begin_layout Itemize
29707 sdcdbsrc-cpu-type '51
29708 \end_layout
29709
29710 \begin_layout Itemize
29711 sdcdbsrc-frequency '11059200
29712 \end_layout
29713
29714 \begin_layout Itemize
29715 sdcdbsrc-serial nil
29716 \end_layout
29717
29718 \begin_layout Standard
29719 The following is a list of key mapping for the debugger interface.
29720 \end_layout
29721
29722 \begin_layout Standard
29723 \InsetSpace ~
29724
29725 \family typewriter
29726
29727 \newline
29728 ;;\InsetSpace ~
29729 Current Listing :: 
29730 \newline
29731 ;;key\InsetSpace ~
29732 \InsetSpace ~
29733 \InsetSpace ~
29734 \InsetSpace ~
29735 \InsetSpace ~
29736 \InsetSpace ~
29737 \InsetSpace ~
29738 \InsetSpace ~
29739 \InsetSpace ~
29740 \InsetSpace ~
29741 \InsetSpace ~
29742 \InsetSpace ~
29743 \InsetSpace ~
29744 \InsetSpace ~
29745 binding\InsetSpace ~
29746 \InsetSpace ~
29747 \InsetSpace ~
29748 \InsetSpace ~
29749 \InsetSpace ~
29750 \InsetSpace ~
29751 \InsetSpace ~
29752 \InsetSpace ~
29753 \InsetSpace ~
29754 \InsetSpace ~
29755 \InsetSpace ~
29756 \InsetSpace ~
29757 \InsetSpace ~
29758 \InsetSpace ~
29759 \InsetSpace ~
29760 \InsetSpace ~
29761 \InsetSpace ~
29762 \InsetSpace ~
29763 \InsetSpace ~
29764 \InsetSpace ~
29765 \InsetSpace ~
29766 \InsetSpace ~
29767 Comment 
29768 \newline
29769 ;;---\InsetSpace ~
29770 \InsetSpace ~
29771 \InsetSpace ~
29772 \InsetSpace ~
29773 \InsetSpace ~
29774 \InsetSpace ~
29775 \InsetSpace ~
29776 \InsetSpace ~
29777 \InsetSpace ~
29778 \InsetSpace ~
29779 \InsetSpace ~
29780 \InsetSpace ~
29781 \InsetSpace ~
29782 \InsetSpace ~
29783 -------\InsetSpace ~
29784 \InsetSpace ~
29785 \InsetSpace ~
29786 \InsetSpace ~
29787 \InsetSpace ~
29788 \InsetSpace ~
29789 \InsetSpace ~
29790 \InsetSpace ~
29791 \InsetSpace ~
29792 \InsetSpace ~
29793 \InsetSpace ~
29794 \InsetSpace ~
29795 \InsetSpace ~
29796 \InsetSpace ~
29797 \InsetSpace ~
29798 \InsetSpace ~
29799 \InsetSpace ~
29800 \InsetSpace ~
29801 \InsetSpace ~
29802 \InsetSpace ~
29803 \InsetSpace ~
29804 \InsetSpace ~
29805 -------
29806 \newline
29807 ;; 
29808 \newline
29809 ;;\InsetSpace ~
29810 n\InsetSpace ~
29811 \InsetSpace ~
29812 \InsetSpace ~
29813 \InsetSpace ~
29814 \InsetSpace ~
29815 \InsetSpace ~
29816 \InsetSpace ~
29817 \InsetSpace ~
29818 \InsetSpace ~
29819 \InsetSpace ~
29820 \InsetSpace ~
29821 \InsetSpace ~
29822 \InsetSpace ~
29823 \InsetSpace ~
29824 \InsetSpace ~
29825 sdcdb-next-fro
29826 m-src\InsetSpace ~
29827 \InsetSpace ~
29828 \InsetSpace ~
29829 \InsetSpace ~
29830 \InsetSpace ~
29831 \InsetSpace ~
29832 \InsetSpace ~
29833 \InsetSpace ~
29834 \InsetSpace ~
29835 \InsetSpace ~
29836 SDCDB next command 
29837 \newline
29838 ;;\InsetSpace ~
29839 b\InsetSpace ~
29840 \InsetSpace ~
29841 \InsetSpace ~
29842 \InsetSpace ~
29843 \InsetSpace ~
29844 \InsetSpace ~
29845 \InsetSpace ~
29846 \InsetSpace ~
29847 \InsetSpace ~
29848 \InsetSpace ~
29849 \InsetSpace ~
29850 \InsetSpace ~
29851 \InsetSpace ~
29852 \InsetSpace ~
29853 \InsetSpace ~
29854 sdcdb-back-from-src\InsetSpace ~
29855 \InsetSpace ~
29856 \InsetSpace ~
29857 \InsetSpace ~
29858 \InsetSpace ~
29859 \InsetSpace ~
29860 \InsetSpace ~
29861 \InsetSpace ~
29862 \InsetSpace ~
29863 \InsetSpace ~
29864 SDCDB back command 
29865 \newline
29866 ;;\InsetSpace ~
29867 c\InsetSpace ~
29868 \InsetSpace ~
29869 \InsetSpace ~
29870 \InsetSpace ~
29871 \InsetSpace ~
29872 \InsetSpace ~
29873 \InsetSpace ~
29874 \InsetSpace ~
29875 \InsetSpace ~
29876 \InsetSpace ~
29877 \InsetSpace ~
29878 \InsetSpace ~
29879 \InsetSpace ~
29880 \InsetSpace ~
29881 \InsetSpace ~
29882 sdcdb-cont-f
29883 rom-src\InsetSpace ~
29884 \InsetSpace ~
29885 \InsetSpace ~
29886 \InsetSpace ~
29887 \InsetSpace ~
29888 \InsetSpace ~
29889 \InsetSpace ~
29890 \InsetSpace ~
29891 \InsetSpace ~
29892 \InsetSpace ~
29893 SDCDB continue command
29894 \newline
29895 ;;\InsetSpace ~
29896 s\InsetSpace ~
29897 \InsetSpace ~
29898 \InsetSpace ~
29899 \InsetSpace ~
29900 \InsetSpace ~
29901 \InsetSpace ~
29902 \InsetSpace ~
29903 \InsetSpace ~
29904 \InsetSpace ~
29905 \InsetSpace ~
29906 \InsetSpace ~
29907 \InsetSpace ~
29908 \InsetSpace ~
29909 \InsetSpace ~
29910 \InsetSpace ~
29911 sdcdb-step-from-src\InsetSpace ~
29912 \InsetSpace ~
29913 \InsetSpace ~
29914 \InsetSpace ~
29915 \InsetSpace ~
29916 \InsetSpace ~
29917 \InsetSpace ~
29918 \InsetSpace ~
29919 \InsetSpace ~
29920 \InsetSpace ~
29921 SDCDB step command 
29922 \newline
29923 ;;\InsetSpace ~
29924 ?\InsetSpace ~
29925 \InsetSpace ~
29926 \InsetSpace ~
29927 \InsetSpace ~
29928 \InsetSpace ~
29929 \InsetSpace ~
29930 \InsetSpace ~
29931 \InsetSpace ~
29932 \InsetSpace ~
29933 \InsetSpace ~
29934 \InsetSpace ~
29935 \InsetSpace ~
29936 \InsetSpace ~
29937 \InsetSpace ~
29938 \InsetSpace ~
29939 sdcdb-w
29940 hatis-c-sexp\InsetSpace ~
29941 \InsetSpace ~
29942 \InsetSpace ~
29943 \InsetSpace ~
29944 \InsetSpace ~
29945 \InsetSpace ~
29946 \InsetSpace ~
29947 \InsetSpace ~
29948 \InsetSpace ~
29949 \InsetSpace ~
29950 SDCDB ptypecommand for data at 
29951 \newline
29952 ;;\InsetSpace ~
29953 \InsetSpace ~
29954 \InsetSpace ~
29955 \InsetSpace ~
29956 \InsetSpace ~
29957 \InsetSpace ~
29958 \InsetSpace ~
29959 \InsetSpace ~
29960 \InsetSpace ~
29961 \InsetSpace ~
29962 \InsetSpace ~
29963 \InsetSpace ~
29964 \InsetSpace ~
29965 \InsetSpace ~
29966 \InsetSpace ~
29967 \InsetSpace ~
29968 \InsetSpace ~
29969 \InsetSpace ~
29970 \InsetSpace ~
29971 \InsetSpace ~
29972 \InsetSpace ~
29973 \InsetSpace ~
29974 \InsetSpace ~
29975 \InsetSpace ~
29976 \InsetSpace ~
29977 \InsetSpace ~
29978 \InsetSpace ~
29979 \InsetSpace ~
29980 \InsetSpace ~
29981 \InsetSpace ~
29982 \InsetSpace ~
29983 \InsetSpace ~
29984 \InsetSpace ~
29985 \InsetSpace ~
29986 \InsetSpace ~
29987 \InsetSpace ~
29988 \InsetSpace ~
29989 \InsetSpace ~
29990 \InsetSpace ~
29991 \InsetSpace ~
29992 \InsetSpace ~
29993 \InsetSpace ~
29994 \InsetSpace ~
29995 \InsetSpace ~
29996 \InsetSpace ~
29997 \InsetSpace ~
29998 \InsetSpace ~
29999 buffer point 
30000 \newline
30001 ;;\InsetSpace ~
30002 x\InsetSpace ~
30003 \InsetSpace ~
30004 \InsetSpace ~
30005 \InsetSpace ~
30006 \InsetSpace ~
30007 \InsetSpace ~
30008 \InsetSpace ~
30009 \InsetSpace ~
30010 \InsetSpace ~
30011 \InsetSpace ~
30012 \InsetSpace ~
30013 \InsetSpace ~
30014 \InsetSpace ~
30015 \InsetSpace ~
30016 \InsetSpace ~
30017 sdcdbsrc-delete\InsetSpace ~
30018 \InsetSpace ~
30019 \InsetSpace ~
30020 \InsetSpace ~
30021 \InsetSpace ~
30022 \InsetSpace ~
30023 \InsetSpace ~
30024 \InsetSpace ~
30025 \InsetSpace ~
30026 \InsetSpace ~
30027 \InsetSpace ~
30028 \InsetSpace ~
30029 \InsetSpace ~
30030 \InsetSpace ~
30031 SDCD
30032 B Delete all breakpoints if no arg 
30033 \newline
30034 ;;\InsetSpace ~
30035 \InsetSpace ~
30036 \InsetSpace ~
30037 \InsetSpace ~
30038 \InsetSpace ~
30039 \InsetSpace ~
30040 \InsetSpace ~
30041 \InsetSpace ~
30042 \InsetSpace ~
30043 \InsetSpace ~
30044 \InsetSpace ~
30045 \InsetSpace ~
30046 \InsetSpace ~
30047 \InsetSpace ~
30048 \InsetSpace ~
30049 \InsetSpace ~
30050 \InsetSpace ~
30051 \InsetSpace ~
30052 \InsetSpace ~
30053 \InsetSpace ~
30054 \InsetSpace ~
30055 \InsetSpace ~
30056 \InsetSpace ~
30057 \InsetSpace ~
30058 \InsetSpace ~
30059 \InsetSpace ~
30060 \InsetSpace ~
30061 \InsetSpace ~
30062 \InsetSpace ~
30063 \InsetSpace ~
30064 \InsetSpace ~
30065 \InsetSpace ~
30066 \InsetSpace ~
30067 \InsetSpace ~
30068 \InsetSpace ~
30069 \InsetSpace ~
30070 \InsetSpace ~
30071 \InsetSpace ~
30072 \InsetSpace ~
30073 \InsetSpace ~
30074 \InsetSpace ~
30075 \InsetSpace ~
30076 \InsetSpace ~
30077 \InsetSpace ~
30078 \InsetSpace ~
30079 \InsetSpace ~
30080 \InsetSpace ~
30081 given or delete arg (C-u arg x) 
30082 \newline
30083 ;;\InsetSpace ~
30084 m\InsetSpace ~
30085 \InsetSpace ~
30086 \InsetSpace ~
30087 \InsetSpace ~
30088 \InsetSpace ~
30089 \InsetSpace ~
30090 \InsetSpace ~
30091 \InsetSpace ~
30092 \InsetSpace ~
30093 \InsetSpace ~
30094 \InsetSpace ~
30095 \InsetSpace ~
30096 \InsetSpace ~
30097 \InsetSpace ~
30098 \InsetSpace ~
30099 sdcdbsrc
30100 -frame\InsetSpace ~
30101 \InsetSpace ~
30102 \InsetSpace ~
30103 \InsetSpace ~
30104 \InsetSpace ~
30105 \InsetSpace ~
30106 \InsetSpace ~
30107 \InsetSpace ~
30108 \InsetSpace ~
30109 \InsetSpace ~
30110 \InsetSpace ~
30111 \InsetSpace ~
30112 \InsetSpace ~
30113 \InsetSpace ~
30114 \InsetSpace ~
30115 SDCDB Display current frame if no arg, 
30116 \newline
30117 ;;\InsetSpace ~
30118 \InsetSpace ~
30119 \InsetSpace ~
30120 \InsetSpace ~
30121 \InsetSpace ~
30122 \InsetSpace ~
30123 \InsetSpace ~
30124 \InsetSpace ~
30125 \InsetSpace ~
30126 \InsetSpace ~
30127 \InsetSpace ~
30128 \InsetSpace ~
30129 \InsetSpace ~
30130 \InsetSpace ~
30131 \InsetSpace ~
30132 \InsetSpace ~
30133 \InsetSpace ~
30134 \InsetSpace ~
30135 \InsetSpace ~
30136 \InsetSpace ~
30137 \InsetSpace ~
30138 \InsetSpace ~
30139 \InsetSpace ~
30140 \InsetSpace ~
30141 \InsetSpace ~
30142 \InsetSpace ~
30143 \InsetSpace ~
30144 \InsetSpace ~
30145 \InsetSpace ~
30146 \InsetSpace ~
30147 \InsetSpace ~
30148 \InsetSpace ~
30149 \InsetSpace ~
30150 \InsetSpace ~
30151 \InsetSpace ~
30152 \InsetSpace ~
30153 \InsetSpace ~
30154 \InsetSpace ~
30155 \InsetSpace ~
30156 \InsetSpace ~
30157 \InsetSpace ~
30158 \InsetSpace ~
30159 \InsetSpace ~
30160 \InsetSpace ~
30161 \InsetSpace ~
30162 \InsetSpace ~
30163 \InsetSpace ~
30164 given or display frame arg
30165  
30166 \newline
30167 ;;\InsetSpace ~
30168 \InsetSpace ~
30169 \InsetSpace ~
30170 \InsetSpace ~
30171 \InsetSpace ~
30172 \InsetSpace ~
30173 \InsetSpace ~
30174 \InsetSpace ~
30175 \InsetSpace ~
30176 \InsetSpace ~
30177 \InsetSpace ~
30178 \InsetSpace ~
30179 \InsetSpace ~
30180 \InsetSpace ~
30181 \InsetSpace ~
30182 \InsetSpace ~
30183 \InsetSpace ~
30184 \InsetSpace ~
30185 \InsetSpace ~
30186 \InsetSpace ~
30187 \InsetSpace ~
30188 \InsetSpace ~
30189 \InsetSpace ~
30190 \InsetSpace ~
30191 \InsetSpace ~
30192 \InsetSpace ~
30193 \InsetSpace ~
30194 \InsetSpace ~
30195 \InsetSpace ~
30196 \InsetSpace ~
30197 \InsetSpace ~
30198 \InsetSpace ~
30199 \InsetSpace ~
30200 \InsetSpace ~
30201 \InsetSpace ~
30202 \InsetSpace ~
30203 \InsetSpace ~
30204 \InsetSpace ~
30205 \InsetSpace ~
30206 \InsetSpace ~
30207 \InsetSpace ~
30208 \InsetSpace ~
30209 \InsetSpace ~
30210 \InsetSpace ~
30211 \InsetSpace ~
30212 \InsetSpace ~
30213 \InsetSpace ~
30214 buffer point 
30215 \newline
30216 ;;\InsetSpace ~
30217 !\InsetSpace ~
30218 \InsetSpace ~
30219 \InsetSpace ~
30220 \InsetSpace ~
30221 \InsetSpace ~
30222 \InsetSpace ~
30223 \InsetSpace ~
30224 \InsetSpace ~
30225 \InsetSpace ~
30226 \InsetSpace ~
30227 \InsetSpace ~
30228 \InsetSpace ~
30229 \InsetSpace ~
30230 \InsetSpace ~
30231 \InsetSpace ~
30232 sdcdbsrc-goto-sdcdb\InsetSpace ~
30233 \InsetSpace ~
30234 \InsetSpace ~
30235 \InsetSpace ~
30236 \InsetSpace ~
30237 \InsetSpace ~
30238 \InsetSpace ~
30239 \InsetSpace ~
30240 \InsetSpace ~
30241 \InsetSpace ~
30242 Goto the SDCDB output buffer 
30243 \newline
30244 ;;\InsetSpace ~
30245 p\InsetSpace ~
30246 \InsetSpace ~
30247 \InsetSpace ~
30248 \InsetSpace ~
30249 \InsetSpace ~
30250 \InsetSpace ~
30251 \InsetSpace ~
30252 \InsetSpace ~
30253 \InsetSpace ~
30254 \InsetSpace ~
30255 \InsetSpace ~
30256 \InsetSpace ~
30257 \InsetSpace ~
30258 \InsetSpace ~
30259 \InsetSpace ~
30260 sdcdb-prin
30261 t-c-sexp\InsetSpace ~
30262 \InsetSpace ~
30263 \InsetSpace ~
30264 \InsetSpace ~
30265 \InsetSpace ~
30266 \InsetSpace ~
30267 \InsetSpace ~
30268 \InsetSpace ~
30269 \InsetSpace ~
30270 \InsetSpace ~
30271 \InsetSpace ~
30272 SDCDB print command for data at 
30273 \newline
30274 ;;\InsetSpace ~
30275 \InsetSpace ~
30276 \InsetSpace ~
30277 \InsetSpace ~
30278 \InsetSpace ~
30279 \InsetSpace ~
30280 \InsetSpace ~
30281 \InsetSpace ~
30282 \InsetSpace ~
30283 \InsetSpace ~
30284 \InsetSpace ~
30285 \InsetSpace ~
30286 \InsetSpace ~
30287 \InsetSpace ~
30288 \InsetSpace ~
30289 \InsetSpace ~
30290 \InsetSpace ~
30291 \InsetSpace ~
30292 \InsetSpace ~
30293 \InsetSpace ~
30294 \InsetSpace ~
30295 \InsetSpace ~
30296 \InsetSpace ~
30297 \InsetSpace ~
30298 \InsetSpace ~
30299 \InsetSpace ~
30300 \InsetSpace ~
30301 \InsetSpace ~
30302 \InsetSpace ~
30303 \InsetSpace ~
30304 \InsetSpace ~
30305 \InsetSpace ~
30306 \InsetSpace ~
30307 \InsetSpace ~
30308 \InsetSpace ~
30309 \InsetSpace ~
30310 \InsetSpace ~
30311 \InsetSpace ~
30312 \InsetSpace ~
30313 \InsetSpace ~
30314 \InsetSpace ~
30315 \InsetSpace ~
30316 \InsetSpace ~
30317 \InsetSpace ~
30318 \InsetSpace ~
30319 \InsetSpace ~
30320 \InsetSpace ~
30321 buffer point 
30322 \newline
30323 ;;\InsetSpace ~
30324 g\InsetSpace ~
30325 \InsetSpace ~
30326 \InsetSpace ~
30327 \InsetSpace ~
30328 \InsetSpace ~
30329 \InsetSpace ~
30330 \InsetSpace ~
30331 \InsetSpace ~
30332 \InsetSpace ~
30333 \InsetSpace ~
30334 \InsetSpace ~
30335 \InsetSpace ~
30336 \InsetSpace ~
30337 \InsetSpace ~
30338 \InsetSpace ~
30339 sdcdbsrc-goto-sdcdb\InsetSpace ~
30340 \InsetSpace ~
30341 \InsetSpace ~
30342 \InsetSpace ~
30343 \InsetSpace ~
30344 \InsetSpace ~
30345 \InsetSpace ~
30346 \InsetSpace ~
30347 \InsetSpace ~
30348 \InsetSpace ~
30349 Got
30350 o the SDCDB output buffer 
30351 \newline
30352 ;;\InsetSpace ~
30353 t\InsetSpace ~
30354 \InsetSpace ~
30355 \InsetSpace ~
30356 \InsetSpace ~
30357 \InsetSpace ~
30358 \InsetSpace ~
30359 \InsetSpace ~
30360 \InsetSpace ~
30361 \InsetSpace ~
30362 \InsetSpace ~
30363 \InsetSpace ~
30364 \InsetSpace ~
30365 \InsetSpace ~
30366 \InsetSpace ~
30367 \InsetSpace ~
30368 sdcdbsrc-mode\InsetSpace ~
30369 \InsetSpace ~
30370 \InsetSpace ~
30371 \InsetSpace ~
30372 \InsetSpace ~
30373 \InsetSpace ~
30374 \InsetSpace ~
30375 \InsetSpace ~
30376 \InsetSpace ~
30377 \InsetSpace ~
30378 \InsetSpace ~
30379 \InsetSpace ~
30380 \InsetSpace ~
30381 \InsetSpace ~
30382 \InsetSpace ~
30383 \InsetSpace ~
30384 Toggles Sdcdbsrc mode (turns it
30385  off) 
30386 \newline
30387 ;; 
30388 \newline
30389 ;;\InsetSpace ~
30390 C-c\InsetSpace ~
30391 C-f\InsetSpace ~
30392 \InsetSpace ~
30393 \InsetSpace ~
30394 \InsetSpace ~
30395 \InsetSpace ~
30396 \InsetSpace ~
30397 \InsetSpace ~
30398 \InsetSpace ~
30399 \InsetSpace ~
30400 sdcdb-finish-from-src\InsetSpace ~
30401 \InsetSpace ~
30402 \InsetSpace ~
30403 \InsetSpace ~
30404 \InsetSpace ~
30405 \InsetSpace ~
30406 \InsetSpace ~
30407 \InsetSpace ~
30408 SDCDB finish command 
30409 \newline
30410 ;; 
30411 \newline
30412 ;;\InsetSpace ~
30413 C-x\InsetSpace ~
30414 SPC\InsetSpace ~
30415 \InsetSpace ~
30416 \InsetSpace ~
30417 \InsetSpace ~
30418 \InsetSpace ~
30419 \InsetSpace ~
30420 \InsetSpace ~
30421 \InsetSpace ~
30422 \InsetSpace ~
30423 sdcdb-brea
30424 k\InsetSpace ~
30425 \InsetSpace ~
30426 \InsetSpace ~
30427 \InsetSpace ~
30428 \InsetSpace ~
30429 \InsetSpace ~
30430 \InsetSpace ~
30431 \InsetSpace ~
30432 \InsetSpace ~
30433 \InsetSpace ~
30434 \InsetSpace ~
30435 \InsetSpace ~
30436 \InsetSpace ~
30437 \InsetSpace ~
30438 \InsetSpace ~
30439 \InsetSpace ~
30440 \InsetSpace ~
30441 \InsetSpace ~
30442 Set break for line with point 
30443 \newline
30444 ;;\InsetSpace ~
30445 ESC\InsetSpace ~
30446 t\InsetSpace ~
30447 \InsetSpace ~
30448 \InsetSpace ~
30449 \InsetSpace ~
30450 \InsetSpace ~
30451 \InsetSpace ~
30452 \InsetSpace ~
30453 \InsetSpace ~
30454 \InsetSpace ~
30455 \InsetSpace ~
30456 \InsetSpace ~
30457 sdcdbsrc-mode\InsetSpace ~
30458 \InsetSpace ~
30459 \InsetSpace ~
30460 \InsetSpace ~
30461 \InsetSpace ~
30462 \InsetSpace ~
30463 \InsetSpace ~
30464 \InsetSpace ~
30465 \InsetSpace ~
30466 \InsetSpace ~
30467 \InsetSpace ~
30468 \InsetSpace ~
30469 \InsetSpace ~
30470 \InsetSpace ~
30471 \InsetSpace ~
30472 \InsetSpace ~
30473 Toggle Sdcdbsrc mode 
30474 \newline
30475 ;;\InsetSpace ~
30476 ESC\InsetSpace ~
30477 m\InsetSpace ~
30478 \InsetSpace ~
30479 \InsetSpace ~
30480 \InsetSpace ~
30481 \InsetSpace ~
30482 \InsetSpace ~
30483 \InsetSpace ~
30484 \InsetSpace ~
30485 \InsetSpace ~
30486 \InsetSpace ~
30487 \InsetSpace ~
30488 sdc
30489 dbsrc-srcmode\InsetSpace ~
30490 \InsetSpace ~
30491 \InsetSpace ~
30492 \InsetSpace ~
30493 \InsetSpace ~
30494 \InsetSpace ~
30495 \InsetSpace ~
30496 \InsetSpace ~
30497 \InsetSpace ~
30498 \InsetSpace ~
30499 \InsetSpace ~
30500 \InsetSpace ~
30501 \InsetSpace ~
30502 Toggle list mode 
30503 \newline
30504 ;; 
30505 \newline
30506
30507 \family default
30508
30509 \newpage
30510
30511 \end_layout
30512
30513 \begin_layout Chapter
30514 TIPS
30515 \end_layout
30516
30517 \begin_layout Standard
30518 Here are a few guidelines that will help the compiler generate more efficient
30519  code, some of the tips are specific to this compiler others are generally
30520  good programming practice.
30521 \end_layout
30522
30523 \begin_layout Itemize
30524 Use the smallest data type to represent your data-value.
30525  If it is known in advance that the value is going to be less than 256 then
30526  use an 'unsigned char' instead of a 'short' or 'int'.
30527  Please note, that ANSI C requires both signed and unsigned chars to be
30528  promoted to 'signed int'
30529 \begin_inset LatexCommand \index{promotion to signed int}
30530
30531 \end_inset
30532
30533
30534 \begin_inset Marginal
30535 status collapsed
30536
30537 \begin_layout Standard
30538
30539 \series bold
30540 \InsetSpace ~
30541 !
30542 \end_layout
30543
30544 \end_inset
30545
30546  before doing any operation.
30547  This promotion
30548 \begin_inset LatexCommand \index{type promotion}
30549
30550 \end_inset
30551
30552
30553 \begin_inset LatexCommand \label{type promotion}
30554
30555 \end_inset
30556
30557  can be omitted, if the result is the same.
30558  The effect of the promotion rules together with the sign-extension is often
30559  surprising:
30560 \end_layout
30561
30562 \begin_deeper
30563 \begin_layout Verse
30564
30565 \family typewriter
30566 unsigned char uc = 0xfe;
30567 \newline
30568 if (uc * uc < 0) /* this is true! */
30569 \newline
30570 {
30571 \newline
30572 \InsetSpace ~
30573 \InsetSpace ~
30574 \InsetSpace ~
30575 \InsetSpace ~
30576 ....
30577 \newline
30578 }
30579 \end_layout
30580
30581 \begin_layout Standard
30582
30583 \family typewriter
30584 uc * uc
30585 \family default
30586  is evaluated as 
30587 \family typewriter
30588 (int) uc * (int) uc = (int) 0xfe * (int) 0xfe = (int) 0xfc04 = -1024
30589 \family default
30590 .
30591  
30592 \newline
30593 Another one:
30594 \end_layout
30595
30596 \begin_layout Verse
30597
30598 \family typewriter
30599 (unsigned char) -12 / (signed char) -3 = ...
30600 \end_layout
30601
30602 \begin_layout Standard
30603 No, the result is not 4:
30604 \end_layout
30605
30606 \begin_layout Verse
30607
30608 \family typewriter
30609 (int) (unsigned char) -12 / (int) (signed char) -3 =
30610 \newline
30611 (int) (unsigned char)
30612  0xf4 / (int) (signed char) 0xfd =
30613 \newline
30614 (int) 0x00f4 / (int) 0xfffd =
30615 \newline
30616 (int) 0x00f4
30617  / (int) 0xfffd =
30618 \newline
30619 (int) 244 / (int) -3 =
30620 \newline
30621 (int) -81 = (int) 0xffaf;
30622 \end_layout
30623
30624 \begin_layout Standard
30625 Don't complain, that gcc gives you a different result.
30626  gcc uses 32 bit ints, while SDCC uses 16 bit ints.
30627  Therefore the results are different.
30628 \newline
30629 From 
30630 \begin_inset Quotes sld
30631 \end_inset
30632
30633 comp.lang.c FAQ
30634 \begin_inset Quotes srd
30635 \end_inset
30636
30637 :
30638 \end_layout
30639
30640 \begin_layout Quote
30641
30642 \emph on
30643 If well-defined overflow characteristics are important and negative values
30644  are not, or if you want to steer clear of sign-extension problems when
30645  manipulating bits or bytes, use one of the corresponding unsigned types.
30646  (Beware when mixing signed and unsigned values in expressions, though.)
30647 \newline
30648 Although
30649  character types (especially unsigned char) can be used as "tiny" integers,
30650  doing so is sometimes more trouble than it's worth, due to unpredictable
30651  sign extension and increased code size.
30652 \end_layout
30653
30654 \end_deeper
30655 \begin_layout Itemize
30656 Use unsigned when it is known in advance that the value is not going to
30657  be negative.
30658  This helps especially if you are doing division or multiplication, bit-shifting
30659  or are using an array index.
30660 \end_layout
30661
30662 \begin_layout Itemize
30663 NEVER jump into a LOOP.
30664 \end_layout
30665
30666 \begin_layout Itemize
30667 Declare the variables to be local
30668 \begin_inset LatexCommand \index{local variables}
30669
30670 \end_inset
30671
30672  whenever possible, especially loop control variables (induction).
30673 \end_layout
30674
30675 \begin_layout Itemize
30676 Have a look at the assembly listing to get a 
30677 \begin_inset Quotes sld
30678 \end_inset
30679
30680 feeling
30681 \begin_inset Quotes srd
30682 \end_inset
30683
30684  for the code generation.
30685 \end_layout
30686
30687 \begin_layout Section
30688 Porting code from or to other compilers
30689 \begin_inset LatexCommand \label{sec:Porting-code-to-other-compilers}
30690
30691 \end_inset
30692
30693
30694 \end_layout
30695
30696 \begin_layout Itemize
30697 check whether endianness of the compilers differs and adapt where needed.
30698 \end_layout
30699
30700 \begin_layout Itemize
30701 check the device specific header files
30702 \begin_inset LatexCommand \index{Header files}
30703
30704 \end_inset
30705
30706
30707 \begin_inset LatexCommand \index{Include files}
30708
30709 \end_inset
30710
30711  for compiler specific syntax.
30712  Eventually include the file <compiler.h
30713 \begin_inset LatexCommand \index{compiler.h (include file)}
30714
30715 \end_inset
30716
30717
30718 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/compiler.h?view=markup}
30719
30720 \end_inset
30721
30722  to allow using common header files.
30723  (see f.e.
30724  cc2510fx.h 
30725 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/cc2510fx.h?view=markup}
30726
30727 \end_inset
30728
30729 ).
30730 \end_layout
30731
30732 \begin_layout Itemize
30733 check whether the startup code contains the correct initialization (watchdog,
30734  peripherals).
30735 \end_layout
30736
30737 \begin_layout Itemize
30738 check whether the sizes of short, int, long match.
30739 \end_layout
30740
30741 \begin_layout Itemize
30742 check if some 16 or 32 bit hardware registers require a specific addressing
30743  order (least significant or most significant byte first) and adapt if needed
30744  (
30745 \emph on
30746 first
30747 \emph default
30748  and 
30749 \emph on
30750 last
30751 \emph default
30752  relate to time and not to lower/upper memory location here, so this is
30753  
30754 \emph on
30755 not
30756 \emph default
30757  the same as endianness).
30758 \end_layout
30759
30760 \begin_layout Itemize
30761 check whether the keyword 
30762 \emph on
30763 volatile
30764 \emph default
30765  is used where needed.
30766  The compilers might differ in their optimization characteristics (as different
30767  versions of the same compiler might also use more clever optimizations
30768  this is good idea anyway).
30769  See section 
30770 \begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
30771
30772 \end_inset
30773
30774 .
30775 \end_layout
30776
30777 \begin_layout Itemize
30778 check that the compilers are not told to supress warnings.
30779 \end_layout
30780
30781 \begin_layout Itemize
30782 check and convert compiler specific extensions (interrupts, memory areas,
30783  pragmas etc.).
30784 \end_layout
30785
30786 \begin_layout Itemize
30787 check for differences in type promotion.
30788  Especially check for math operations on 
30789 \family typewriter
30790 char
30791 \family default
30792  or 
30793 \family typewriter
30794 unsigned char
30795 \family default
30796  variables.
30797  For the sake of C99 compatibility SDCC will probably promote these to 
30798 \family typewriter
30799 int
30800 \family default
30801  more often than other compilers.
30802  Eventually insert explicit casts to 
30803 \family typewriter
30804 (char) 
30805 \family default
30806 or
30807 \family typewriter
30808  (unsigned char)
30809 \family default
30810 .
30811  Also check that the ~\InsetSpace ~
30812 operator
30813 \begin_inset LatexCommand \index{\~\/ Operator}
30814
30815 \end_inset
30816
30817  is not used on 
30818 \family typewriter
30819 bit
30820 \begin_inset LatexCommand \index{bit}
30821
30822 \end_inset
30823
30824
30825 \family default
30826  variables, use the !\InsetSpace ~
30827 operator instead.
30828  See sections 
30829 \begin_inset LatexCommand \ref{type promotion}
30830
30831 \end_inset
30832
30833  and 
30834 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
30835
30836 \end_inset
30837
30838 .
30839 \end_layout
30840
30841 \begin_layout Itemize
30842 check the assembly code generated for interrupt routines (f.e.
30843  for calls to possibly non-reentrant library functions).
30844 \end_layout
30845
30846 \begin_layout Itemize
30847 check whether timing loops result in proper timing (or preferably consider
30848  a rewrite of the code with timer based delays instead).
30849 \end_layout
30850
30851 \begin_layout Itemize
30852 check for differences in printf parameters (some compilers push (va_arg
30853 \begin_inset LatexCommand \index{vararg, va\_arg}
30854
30855 \end_inset
30856
30857 ) char variables as 
30858 \family typewriter
30859 int
30860 \family default
30861  others push them as 
30862 \family typewriter
30863 char
30864 \family default
30865 .
30866  See section 
30867 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
30868
30869 \end_inset
30870
30871 ).
30872 \end_layout
30873
30874 \begin_layout Itemize
30875 check the resulting memory map
30876 \begin_inset LatexCommand \index{Memory map}
30877
30878 \end_inset
30879
30880 .
30881  Usage of different memory spaces: code, stack, data (for mcs51/ds390 additional
30882 ly idata, pdata, xdata).
30883  Eventually check if unexpected library functions are included.
30884 \end_layout
30885
30886 \begin_layout Section
30887 Tools
30888 \begin_inset LatexCommand \index{Tools}
30889
30890 \end_inset
30891
30892  included in the distribution
30893 \end_layout
30894
30895 \begin_layout Standard
30896 \align left
30897 \begin_inset Tabular
30898 <lyxtabular version="3" rows="12" columns="3">
30899 <features>
30900 <column alignment="left" valignment="top" leftline="true" width="0pt">
30901 <column alignment="left" valignment="top" leftline="true" width="0pt">
30902 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
30903 <row topline="true" bottomline="true">
30904 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30905 \begin_inset Text
30906
30907 \begin_layout Standard
30908
30909 \series bold
30910 Name
30911 \end_layout
30912
30913 \end_inset
30914 </cell>
30915 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30916 \begin_inset Text
30917
30918 \begin_layout Standard
30919
30920 \series bold
30921 Purpose
30922 \end_layout
30923
30924 \end_inset
30925 </cell>
30926 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30927 \begin_inset Text
30928
30929 \begin_layout Standard
30930
30931 \series bold
30932 Directory
30933 \end_layout
30934
30935 \end_inset
30936 </cell>
30937 </row>
30938 <row topline="true">
30939 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30940 \begin_inset Text
30941
30942 \begin_layout Standard
30943 uCsim
30944 \begin_inset LatexCommand \index{uCsim}
30945
30946 \end_inset
30947
30948
30949 \end_layout
30950
30951 \end_inset
30952 </cell>
30953 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30954 \begin_inset Text
30955
30956 \begin_layout Standard
30957 Simulator for various architectures
30958 \end_layout
30959
30960 \end_inset
30961 </cell>
30962 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30963 \begin_inset Text
30964
30965 \begin_layout Standard
30966 sdcc/sim/ucsim
30967 \end_layout
30968
30969 \end_inset
30970 </cell>
30971 </row>
30972 <row topline="true">
30973 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30974 \begin_inset Text
30975
30976 \begin_layout Standard
30977 keil2sdcc.pl
30978 \end_layout
30979
30980 \end_inset
30981 </cell>
30982 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30983 \begin_inset Text
30984
30985 \begin_layout Standard
30986 header file
30987 \begin_inset LatexCommand \index{Header files}
30988
30989 \end_inset
30990
30991
30992 \begin_inset LatexCommand \index{Include files}
30993
30994 \end_inset
30995
30996  conversion
30997 \end_layout
30998
30999 \end_inset
31000 </cell>
31001 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31002 \begin_inset Text
31003
31004 \begin_layout Standard
31005 sdcc/support/scripts
31006 \end_layout
31007
31008 \end_inset
31009 </cell>
31010 </row>
31011 <row topline="true">
31012 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31013 \begin_inset Text
31014
31015 \begin_layout Standard
31016 mh2h.c
31017 \end_layout
31018
31019 \end_inset
31020 </cell>
31021 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31022 \begin_inset Text
31023
31024 \begin_layout Standard
31025 header file conversion
31026 \end_layout
31027
31028 \end_inset
31029 </cell>
31030 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31031 \begin_inset Text
31032
31033 \begin_layout Standard
31034 sdcc/support/scripts
31035 \end_layout
31036
31037 \end_inset
31038 </cell>
31039 </row>
31040 <row topline="true">
31041 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31042 \begin_inset Text
31043
31044 \begin_layout Standard
31045 as-gbz80
31046 \end_layout
31047
31048 \end_inset
31049 </cell>
31050 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31051 \begin_inset Text
31052
31053 \begin_layout Standard
31054 Assembler
31055 \end_layout
31056
31057 \end_inset
31058 </cell>
31059 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31060 \begin_inset Text
31061
31062 \begin_layout Standard
31063
31064 \family roman
31065 \series medium
31066 \shape up
31067 \size normal
31068 \emph off
31069 \bar no
31070 \noun off
31071 \color none
31072 sdcc/bin
31073 \end_layout
31074
31075 \end_inset
31076 </cell>
31077 </row>
31078 <row topline="true">
31079 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31080 \begin_inset Text
31081
31082 \begin_layout Standard
31083 as-z80
31084 \end_layout
31085
31086 \end_inset
31087 </cell>
31088 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31089 \begin_inset Text
31090
31091 \begin_layout Standard
31092 Assembler
31093 \end_layout
31094
31095 \end_inset
31096 </cell>
31097 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31098 \begin_inset Text
31099
31100 \begin_layout Standard
31101
31102 \family roman
31103 \series medium
31104 \shape up
31105 \size normal
31106 \emph off
31107 \bar no
31108 \noun off
31109 \color none
31110 sdcc/bin
31111 \end_layout
31112
31113 \end_inset
31114 </cell>
31115 </row>
31116 <row topline="true">
31117 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31118 \begin_inset Text
31119
31120 \begin_layout Standard
31121 asx8051
31122 \end_layout
31123
31124 \end_inset
31125 </cell>
31126 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31127 \begin_inset Text
31128
31129 \begin_layout Standard
31130 Assembler
31131 \end_layout
31132
31133 \end_inset
31134 </cell>
31135 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31136 \begin_inset Text
31137
31138 \begin_layout Standard
31139
31140 \family roman
31141 \series medium
31142 \shape up
31143 \size normal
31144 \emph off
31145 \bar no
31146 \noun off
31147 \color none
31148 sdcc/bin
31149 \end_layout
31150
31151 \end_inset
31152 </cell>
31153 </row>
31154 <row topline="true">
31155 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31156 \begin_inset Text
31157
31158 \begin_layout Standard
31159 SDCDB
31160 \end_layout
31161
31162 \end_inset
31163 </cell>
31164 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31165 \begin_inset Text
31166
31167 \begin_layout Standard
31168 Simulator
31169 \end_layout
31170
31171 \end_inset
31172 </cell>
31173 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31174 \begin_inset Text
31175
31176 \begin_layout Standard
31177
31178 \family roman
31179 \series medium
31180 \shape up
31181 \size normal
31182 \emph off
31183 \bar no
31184 \noun off
31185 \color none
31186 sdcc/bin
31187 \end_layout
31188
31189 \end_inset
31190 </cell>
31191 </row>
31192 <row topline="true">
31193 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31194 \begin_inset Text
31195
31196 \begin_layout Standard
31197 aslink
31198 \end_layout
31199
31200 \end_inset
31201 </cell>
31202 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31203 \begin_inset Text
31204
31205 \begin_layout Standard
31206 Linker
31207 \end_layout
31208
31209 \end_inset
31210 </cell>
31211 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31212 \begin_inset Text
31213
31214 \begin_layout Standard
31215
31216 \family roman
31217 \series medium
31218 \shape up
31219 \size normal
31220 \emph off
31221 \bar no
31222 \noun off
31223 \color none
31224 sdcc/bin
31225 \end_layout
31226
31227 \end_inset
31228 </cell>
31229 </row>
31230 <row topline="true">
31231 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31232 \begin_inset Text
31233
31234 \begin_layout Standard
31235 link-z80
31236 \end_layout
31237
31238 \end_inset
31239 </cell>
31240 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31241 \begin_inset Text
31242
31243 \begin_layout Standard
31244 Linker
31245 \end_layout
31246
31247 \end_inset
31248 </cell>
31249 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31250 \begin_inset Text
31251
31252 \begin_layout Standard
31253
31254 \family roman
31255 \series medium
31256 \shape up
31257 \size normal
31258 \emph off
31259 \bar no
31260 \noun off
31261 \color none
31262 sdcc/bin
31263 \end_layout
31264
31265 \end_inset
31266 </cell>
31267 </row>
31268 <row topline="true">
31269 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31270 \begin_inset Text
31271
31272 \begin_layout Standard
31273 link-gbz80
31274 \end_layout
31275
31276 \end_inset
31277 </cell>
31278 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31279 \begin_inset Text
31280
31281 \begin_layout Standard
31282 Linker
31283 \end_layout
31284
31285 \end_inset
31286 </cell>
31287 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31288 \begin_inset Text
31289
31290 \begin_layout Standard
31291
31292 \family roman
31293 \series medium
31294 \shape up
31295 \size normal
31296 \emph off
31297 \bar no
31298 \noun off
31299 \color none
31300 sdcc/bin
31301 \end_layout
31302
31303 \end_inset
31304 </cell>
31305 </row>
31306 <row topline="true" bottomline="true">
31307 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31308 \begin_inset Text
31309
31310 \begin_layout Standard
31311 packihx
31312 \end_layout
31313
31314 \end_inset
31315 </cell>
31316 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31317 \begin_inset Text
31318
31319 \begin_layout Standard
31320 Intel Hex packer 
31321 \begin_inset LatexCommand \index{packihx (tool)}
31322
31323 \end_inset
31324
31325
31326 \end_layout
31327
31328 \end_inset
31329 </cell>
31330 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31331 \begin_inset Text
31332
31333 \begin_layout Standard
31334
31335 \family roman
31336 \series medium
31337 \shape up
31338 \size normal
31339 \emph off
31340 \bar no
31341 \noun off
31342 \color none
31343 sdcc/bin
31344 \end_layout
31345
31346 \end_inset
31347 </cell>
31348 </row>
31349 </lyxtabular>
31350
31351 \end_inset
31352
31353
31354 \newline
31355
31356 \end_layout
31357
31358 \begin_layout Section
31359 Documentation
31360 \begin_inset LatexCommand \index{Documentation}
31361
31362 \end_inset
31363
31364  included in the distribution
31365 \end_layout
31366
31367 \begin_layout Standard
31368 \align left
31369 \begin_inset Tabular
31370 <lyxtabular version="3" rows="10" columns="2">
31371 <features>
31372 <column alignment="block" valignment="top" leftline="true" width="40col%">
31373 <column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
31374 <row topline="true" bottomline="true" endhead="true">
31375 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31376 \begin_inset Text
31377
31378 \begin_layout Standard
31379
31380 \series bold
31381 Subject / Title
31382 \end_layout
31383
31384 \end_inset
31385 </cell>
31386 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31387 \begin_inset Text
31388
31389 \begin_layout Standard
31390
31391 \series bold
31392 Filename / Where to get
31393 \end_layout
31394
31395 \end_inset
31396 </cell>
31397 </row>
31398 <row topline="true">
31399 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31400 \begin_inset Text
31401
31402 \begin_layout Standard
31403 SDCC Compiler User Guide
31404 \end_layout
31405
31406 \end_inset
31407 </cell>
31408 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31409 \begin_inset Text
31410
31411 \begin_layout Standard
31412 You're reading it right now
31413 \emph on
31414  \InsetSpace ~
31415 \InsetSpace ~
31416 \InsetSpace ~
31417
31418 \hfill
31419 online at:
31420 \emph default
31421
31422 \newline
31423
31424 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
31425
31426 \end_inset
31427
31428
31429 \end_layout
31430
31431 \end_inset
31432 </cell>
31433 </row>
31434 <row topline="true">
31435 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31436 \begin_inset Text
31437
31438 \begin_layout Standard
31439 Changelog of SDCC
31440 \end_layout
31441
31442 \end_inset
31443 </cell>
31444 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31445 \begin_inset Text
31446
31447 \begin_layout Standard
31448 sdcc/Changelog
31449 \emph on
31450  \InsetSpace ~
31451 \InsetSpace ~
31452 \InsetSpace ~
31453
31454 \hfill
31455 online at:
31456 \emph default
31457
31458 \newline
31459
31460 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog}
31461
31462 \end_inset
31463
31464
31465 \end_layout
31466
31467 \end_inset
31468 </cell>
31469 </row>
31470 <row topline="true">
31471 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31472 \begin_inset Text
31473
31474 \begin_layout Standard
31475 ASXXXX
31476 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
31477
31478 \end_inset
31479
31480
31481 \begin_inset LatexCommand \index{Assembler documentation}
31482
31483 \end_inset
31484
31485  Assemblers and
31486 \newline
31487 ASLINK
31488 \begin_inset LatexCommand \index{aslink}
31489
31490 \end_inset
31491
31492
31493 \begin_inset LatexCommand \index{Linker documentation}
31494
31495 \end_inset
31496
31497  Relocating Linker
31498 \end_layout
31499
31500 \end_inset
31501 </cell>
31502 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31503 \begin_inset Text
31504
31505 \begin_layout Standard
31506 sdcc/as/doc/asxhtm.html 
31507 \emph on
31508 \InsetSpace ~
31509 \InsetSpace ~
31510 \InsetSpace ~
31511
31512 \hfill
31513 online at:
31514 \emph default
31515
31516 \newline
31517
31518 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
31519
31520 \end_inset
31521
31522
31523 \end_layout
31524
31525 \end_inset
31526 </cell>
31527 </row>
31528 <row topline="true">
31529 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31530 \begin_inset Text
31531
31532 \begin_layout Standard
31533 SDCC regression test
31534 \begin_inset LatexCommand \index{Regression test}
31535
31536 \end_inset
31537
31538
31539 \end_layout
31540
31541 \end_inset
31542 </cell>
31543 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31544 \begin_inset Text
31545
31546 \begin_layout Standard
31547 sdcc/doc/test_suite_spec.pdf 
31548 \emph on
31549 \InsetSpace ~
31550 \InsetSpace ~
31551 \InsetSpace ~
31552
31553 \hfill
31554 online at:
31555 \emph default
31556
31557 \newline
31558
31559 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
31560
31561 \end_inset
31562
31563
31564 \end_layout
31565
31566 \end_inset
31567 </cell>
31568 </row>
31569 <row topline="true">
31570 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31571 \begin_inset Text
31572
31573 \begin_layout Standard
31574 Various notes
31575 \end_layout
31576
31577 \end_inset
31578 </cell>
31579 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31580 \begin_inset Text
31581
31582 \begin_layout Standard
31583 sdcc/doc/* 
31584 \emph on
31585 \InsetSpace ~
31586 \InsetSpace ~
31587 \InsetSpace ~
31588
31589 \hfill
31590 online at:
31591 \emph default
31592
31593 \newline
31594
31595 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/doc/}
31596
31597 \end_inset
31598
31599
31600 \end_layout
31601
31602 \end_inset
31603 </cell>
31604 </row>
31605 <row topline="true">
31606 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31607 \begin_inset Text
31608
31609 \begin_layout Standard
31610 Notes on debugging with SDCDB
31611 \begin_inset LatexCommand \index{SDCDB (debugger)}
31612
31613 \end_inset
31614
31615
31616 \end_layout
31617
31618 \end_inset
31619 </cell>
31620 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31621 \begin_inset Text
31622
31623 \begin_layout Standard
31624 sdcc/debugger/README 
31625 \emph on
31626 \InsetSpace ~
31627 \InsetSpace ~
31628 \InsetSpace ~
31629
31630 \hfill
31631 online at
31632 \emph default
31633 :
31634 \newline
31635
31636 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README}
31637
31638 \end_inset
31639
31640
31641 \end_layout
31642
31643 \end_inset
31644 </cell>
31645 </row>
31646 <row topline="true">
31647 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31648 \begin_inset Text
31649
31650 \begin_layout Standard
31651 uCsim
31652 \begin_inset LatexCommand \index{uCsim}
31653
31654 \end_inset
31655
31656  Software simulator for microcontrollers
31657 \end_layout
31658
31659 \end_inset
31660 </cell>
31661 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31662 \begin_inset Text
31663
31664 \begin_layout Standard
31665
31666 \family roman
31667 \series medium
31668 \shape up
31669 \size normal
31670 \emph off
31671 \bar no
31672 \noun off
31673 \color none
31674 sdcc/sim/ucsim/doc
31675 \family default
31676 \series default
31677 \shape default
31678 \size default
31679 \emph default
31680 \bar default
31681 \noun default
31682 /index.html 
31683 \emph on
31684 \InsetSpace ~
31685 \InsetSpace ~
31686 \InsetSpace ~
31687
31688 \hfill
31689 online at:
31690 \emph default
31691
31692 \newline
31693
31694 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html}
31695
31696 \end_inset
31697
31698
31699 \end_layout
31700
31701 \end_inset
31702 </cell>
31703 </row>
31704 <row topline="true">
31705 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31706 \begin_inset Text
31707
31708 \begin_layout Standard
31709 Temporary notes on the pic16
31710 \begin_inset LatexCommand \index{PIC16}
31711
31712 \end_inset
31713
31714  port
31715 \end_layout
31716
31717 \end_inset
31718 </cell>
31719 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31720 \begin_inset Text
31721
31722 \begin_layout Standard
31723 sdcc/src/pic16/NOTES 
31724 \emph on
31725 \InsetSpace ~
31726 \InsetSpace ~
31727 \InsetSpace ~
31728
31729 \hfill
31730 online at:
31731 \newline
31732
31733 \emph default
31734
31735 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES}
31736
31737 \end_inset
31738
31739
31740 \end_layout
31741
31742 \end_inset
31743 </cell>
31744 </row>
31745 <row topline="true" bottomline="true">
31746 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31747 \begin_inset Text
31748
31749 \begin_layout Standard
31750 SDCC internal documentation (debugging file format)
31751 \end_layout
31752
31753 \end_inset
31754 </cell>
31755 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31756 \begin_inset Text
31757
31758 \begin_layout Standard
31759 sdcc/doc/
31760 \family roman
31761 \series medium
31762 \shape up
31763 \size normal
31764 \emph off
31765 \bar no
31766 \noun off
31767 \color none
31768 cdbfileformat.pd
31769 \family default
31770 \series default
31771 \shape default
31772 \size default
31773 \emph default
31774 \bar default
31775 \noun default
31776 f
31777 \emph on
31778  \InsetSpace ~
31779 \InsetSpace ~
31780 \InsetSpace ~
31781
31782 \hfill
31783 online at:
31784 \emph default
31785
31786 \newline
31787
31788 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/cdbfileformat.pdf}
31789
31790 \end_inset
31791
31792
31793 \end_layout
31794
31795 \end_inset
31796 </cell>
31797 </row>
31798 </lyxtabular>
31799
31800 \end_inset
31801
31802
31803 \newline
31804
31805 \end_layout
31806
31807 \begin_layout Section
31808 Related open source tools
31809 \begin_inset LatexCommand \label{sec:Related-open-source-tools}
31810
31811 \end_inset
31812
31813
31814 \begin_inset LatexCommand \index{Related tools}
31815
31816 \end_inset
31817
31818
31819 \end_layout
31820
31821 \begin_layout Standard
31822 \align left
31823 \begin_inset Tabular
31824 <lyxtabular version="3" rows="16" columns="3">
31825 <features>
31826 <column alignment="left" valignment="top" leftline="true" width="0pt">
31827 <column alignment="block" valignment="top" leftline="true" width="30line%">
31828 <column alignment="left" valignment="top" leftline="true" rightline="true" width="40col%">
31829 <row topline="true" bottomline="true">
31830 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31831 \begin_inset Text
31832
31833 \begin_layout Standard
31834
31835 \series bold
31836 Name
31837 \end_layout
31838
31839 \end_inset
31840 </cell>
31841 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31842 \begin_inset Text
31843
31844 \begin_layout Standard
31845
31846 \series bold
31847 Purpose
31848 \end_layout
31849
31850 \end_inset
31851 </cell>
31852 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31853 \begin_inset Text
31854
31855 \begin_layout Standard
31856
31857 \series bold
31858 Where to get
31859 \end_layout
31860
31861 \end_inset
31862 </cell>
31863 </row>
31864 <row topline="true">
31865 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31866 \begin_inset Text
31867
31868 \begin_layout Standard
31869 gpsim
31870 \begin_inset LatexCommand \index{gpsim (pic simulator)}
31871
31872 \end_inset
31873
31874
31875 \end_layout
31876
31877 \end_inset
31878 </cell>
31879 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31880 \begin_inset Text
31881
31882 \begin_layout Standard
31883 PIC simulator
31884 \end_layout
31885
31886 \end_inset
31887 </cell>
31888 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31889 \begin_inset Text
31890
31891 \begin_layout Standard
31892 \begin_inset LatexCommand \url{http://www.dattalo.com/gnupic/gpsim.html}
31893
31894 \end_inset
31895
31896
31897 \end_layout
31898
31899 \end_inset
31900 </cell>
31901 </row>
31902 <row topline="true">
31903 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31904 \begin_inset Text
31905
31906 \begin_layout Standard
31907 gputils
31908 \begin_inset LatexCommand \index{gputils (pic tools)}
31909
31910 \end_inset
31911
31912
31913 \end_layout
31914
31915 \end_inset
31916 </cell>
31917 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31918 \begin_inset Text
31919
31920 \begin_layout Standard
31921 GNU PIC utilities
31922 \end_layout
31923
31924 \end_inset
31925 </cell>
31926 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31927 \begin_inset Text
31928
31929 \begin_layout Standard
31930 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
31931
31932 \end_inset
31933
31934
31935 \end_layout
31936
31937 \end_inset
31938 </cell>
31939 </row>
31940 <row topline="true">
31941 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31942 \begin_inset Text
31943
31944 \begin_layout Standard
31945 flP5
31946 \end_layout
31947
31948 \end_inset
31949 </cell>
31950 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31951 \begin_inset Text
31952
31953 \begin_layout Standard
31954 PIC programmer
31955 \end_layout
31956
31957 \end_inset
31958 </cell>
31959 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31960 \begin_inset Text
31961
31962 \begin_layout Standard
31963 \begin_inset LatexCommand \url{http://freshmeat.net/projects/flp5/}
31964
31965 \end_inset
31966
31967
31968 \end_layout
31969
31970 \end_inset
31971 </cell>
31972 </row>
31973 <row topline="true">
31974 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31975 \begin_inset Text
31976
31977 \begin_layout Standard
31978 ec2drv/newcdb
31979 \end_layout
31980
31981 \end_inset
31982 </cell>
31983 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31984 \begin_inset Text
31985
31986 \begin_layout Standard
31987 Tools for Silicon Laboratories JTAG debug adapter, partly based on SDCDB
31988  (Unix only)
31989 \end_layout
31990
31991 \end_inset
31992 </cell>
31993 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31994 \begin_inset Text
31995
31996 \begin_layout Standard
31997 \begin_inset LatexCommand \url{http://sourceforge.net/projects/ec2drv}
31998
31999 \end_inset
32000
32001
32002 \end_layout
32003
32004 \end_inset
32005 </cell>
32006 </row>
32007 <row topline="true">
32008 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32009 \begin_inset Text
32010
32011 \begin_layout Standard
32012 indent
32013 \begin_inset LatexCommand \index{indent (source formatting tool)}
32014
32015 \end_inset
32016
32017
32018 \end_layout
32019
32020 \end_inset
32021 </cell>
32022 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32023 \begin_inset Text
32024
32025 \begin_layout Standard
32026 Formats C source - Master of the white spaces
32027 \end_layout
32028
32029 \end_inset
32030 </cell>
32031 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32032 \begin_inset Text
32033
32034 \begin_layout Standard
32035 \begin_inset LatexCommand \url{http://directory.fsf.org/GNU/indent.html}
32036
32037 \end_inset
32038
32039
32040 \end_layout
32041
32042 \end_inset
32043 </cell>
32044 </row>
32045 <row topline="true">
32046 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32047 \begin_inset Text
32048
32049 \begin_layout Standard
32050 srecord
32051 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
32052
32053 \end_inset
32054
32055
32056 \end_layout
32057
32058 \end_inset
32059 </cell>
32060 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32061 \begin_inset Text
32062
32063 \begin_layout Standard
32064 Object file conversion, checksumming, ...
32065 \end_layout
32066
32067 \end_inset
32068 </cell>
32069 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32070 \begin_inset Text
32071
32072 \begin_layout Standard
32073 \begin_inset LatexCommand \url{http://sourceforge.net/projects/srecord}
32074
32075 \end_inset
32076
32077
32078 \end_layout
32079
32080 \end_inset
32081 </cell>
32082 </row>
32083 <row topline="true">
32084 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32085 \begin_inset Text
32086
32087 \begin_layout Standard
32088 objdump
32089 \begin_inset LatexCommand \index{objdump (tool)}
32090
32091 \end_inset
32092
32093
32094 \end_layout
32095
32096 \end_inset
32097 </cell>
32098 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32099 \begin_inset Text
32100
32101 \begin_layout Standard
32102 Object file conversion, ...
32103 \end_layout
32104
32105 \end_inset
32106 </cell>
32107 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32108 \begin_inset Text
32109
32110 \begin_layout Standard
32111 Part of binutils (should be there anyway)
32112 \end_layout
32113
32114 \end_inset
32115 </cell>
32116 </row>
32117 <row topline="true">
32118 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32119 \begin_inset Text
32120
32121 \begin_layout Standard
32122 cmon51
32123 \end_layout
32124
32125 \end_inset
32126 </cell>
32127 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32128 \begin_inset Text
32129
32130 \begin_layout Standard
32131 8051 monitor (hex up-/download, single step, disassemble)
32132 \end_layout
32133
32134 \end_inset
32135 </cell>
32136 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32137 \begin_inset Text
32138
32139 \begin_layout Standard
32140 \begin_inset LatexCommand \url{http://sourceforge.net/projects/cmon51}
32141
32142 \end_inset
32143
32144
32145 \end_layout
32146
32147 \end_inset
32148 </cell>
32149 </row>
32150 <row topline="true">
32151 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32152 \begin_inset Text
32153
32154 \begin_layout Standard
32155 doxygen
32156 \begin_inset LatexCommand \index{doxygen (source documentation tool)}
32157
32158 \end_inset
32159
32160
32161 \end_layout
32162
32163 \end_inset
32164 </cell>
32165 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32166 \begin_inset Text
32167
32168 \begin_layout Standard
32169 Source code documentation system
32170 \end_layout
32171
32172 \end_inset
32173 </cell>
32174 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32175 \begin_inset Text
32176
32177 \begin_layout Standard
32178 \begin_inset LatexCommand \url{http://www.doxygen.org}
32179
32180 \end_inset
32181
32182
32183 \end_layout
32184
32185 \end_inset
32186 </cell>
32187 </row>
32188 <row topline="true">
32189 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32190 \begin_inset Text
32191
32192 \begin_layout Standard
32193 kdevelop
32194 \end_layout
32195
32196 \end_inset
32197 </cell>
32198 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32199 \begin_inset Text
32200
32201 \begin_layout Standard
32202 IDE (has anyone tried integrating SDCC & SDCDB? Unix only)
32203 \end_layout
32204
32205 \end_inset
32206 </cell>
32207 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32208 \begin_inset Text
32209
32210 \begin_layout Standard
32211 \begin_inset LatexCommand \url{http://www.kdevelop.org}
32212
32213 \end_inset
32214
32215
32216 \end_layout
32217
32218 \end_inset
32219 </cell>
32220 </row>
32221 <row topline="true">
32222 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32223 \begin_inset Text
32224
32225 \begin_layout Standard
32226 paulmon
32227 \end_layout
32228
32229 \end_inset
32230 </cell>
32231 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32232 \begin_inset Text
32233
32234 \begin_layout Standard
32235 8051 monitor (hex up-/download, single step, disassemble)
32236 \end_layout
32237
32238 \end_inset
32239 </cell>
32240 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32241 \begin_inset Text
32242
32243 \begin_layout Standard
32244 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/paulmon2.html}
32245
32246 \end_inset
32247
32248
32249 \end_layout
32250
32251 \end_inset
32252 </cell>
32253 </row>
32254 <row topline="true">
32255 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32256 \begin_inset Text
32257
32258 \begin_layout Standard
32259 splint
32260 \begin_inset LatexCommand \index{splint (syntax checking tool)}
32261
32262 \end_inset
32263
32264
32265 \end_layout
32266
32267 \end_inset
32268 </cell>
32269 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32270 \begin_inset Text
32271
32272 \begin_layout Standard
32273 Statically checks c sources (see 
32274 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
32275
32276 \end_inset
32277
32278 )
32279 \end_layout
32280
32281 \end_inset
32282 </cell>
32283 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32284 \begin_inset Text
32285
32286 \begin_layout Standard
32287 \begin_inset LatexCommand \url{http://www.splint.org}
32288
32289 \end_inset
32290
32291
32292 \end_layout
32293
32294 \end_inset
32295 </cell>
32296 </row>
32297 <row topline="true" bottomline="true">
32298 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32299 \begin_inset Text
32300
32301 \begin_layout Standard
32302 ddd
32303 \begin_inset LatexCommand \index{DDD (debugger)}
32304
32305 \end_inset
32306
32307
32308 \end_layout
32309
32310 \end_inset
32311 </cell>
32312 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32313 \begin_inset Text
32314
32315 \begin_layout Standard
32316 Debugger, serves nicely as GUI to SDCDB
32317 \begin_inset LatexCommand \index{SDCDB (debugger)}
32318
32319 \end_inset
32320
32321  (Unix only)
32322 \end_layout
32323
32324 \end_inset
32325 </cell>
32326 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32327 \begin_inset Text
32328
32329 \begin_layout Standard
32330 \begin_inset LatexCommand \url{http://www.gnu.org/software/ddd/}
32331
32332 \end_inset
32333
32334
32335 \end_layout
32336
32337 \end_inset
32338 </cell>
32339 </row>
32340 <row bottomline="true">
32341 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32342 \begin_inset Text
32343
32344 \begin_layout Standard
32345 d52
32346 \begin_inset LatexCommand \index{d52}
32347
32348 \end_inset
32349
32350
32351 \begin_inset LatexCommand \index{d52 (disassembler)}
32352
32353 \end_inset
32354
32355
32356 \end_layout
32357
32358 \end_inset
32359 </cell>
32360 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32361 \begin_inset Text
32362
32363 \begin_layout Standard
32364 Disassembler, can count instruction cycles
32365 \begin_inset LatexCommand \index{instruction cycles (count)}
32366
32367 \end_inset
32368
32369 , use with options -pnd
32370 \end_layout
32371
32372 \end_inset
32373 </cell>
32374 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32375 \begin_inset Text
32376
32377 \begin_layout Standard
32378 \begin_inset LatexCommand \url{http://www.8052.com/users/disasm/}
32379
32380 \end_inset
32381
32382
32383 \end_layout
32384
32385 \end_inset
32386 </cell>
32387 </row>
32388 <row bottomline="true">
32389 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32390 \begin_inset Text
32391
32392 \begin_layout Standard
32393 cmake
32394 \begin_inset LatexCommand \index{cmake}
32395
32396 \end_inset
32397
32398
32399 \end_layout
32400
32401 \end_inset
32402 </cell>
32403 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32404 \begin_inset Text
32405
32406 \begin_layout Standard
32407 Cross platform build system, generates Makefiles
32408 \begin_inset LatexCommand \index{Makefile}
32409
32410 \end_inset
32411
32412  and project workspaces
32413 \begin_inset LatexCommand \index{project workspace}
32414
32415 \end_inset
32416
32417
32418 \end_layout
32419
32420 \end_inset
32421 </cell>
32422 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32423 \begin_inset Text
32424
32425 \begin_layout Standard
32426 \begin_inset LatexCommand \url{http://www.cmake.org}
32427
32428 \end_inset
32429
32430  \InsetSpace ~
32431 \InsetSpace ~
32432 \InsetSpace ~
32433 \InsetSpace ~
32434 and a dedicated wiki entry: 
32435 \begin_inset LatexCommand \url{http://www.cmake.org/Wiki/CmakeSdcc}
32436
32437 \end_inset
32438
32439
32440 \end_layout
32441
32442 \end_inset
32443 </cell>
32444 </row>
32445 </lyxtabular>
32446
32447 \end_inset
32448
32449
32450 \newline
32451
32452 \end_layout
32453
32454 \begin_layout Section
32455 Related documentation / recommended reading
32456 \end_layout
32457
32458 \begin_layout Standard
32459 \align left
32460 \begin_inset Tabular
32461 <lyxtabular version="3" rows="7" columns="3">
32462 <features>
32463 <column alignment="left" valignment="top" leftline="true" width="0pt">
32464 <column alignment="left" valignment="top" leftline="true" width="0">
32465 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
32466 <row topline="true" bottomline="true">
32467 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32468 \begin_inset Text
32469
32470 \begin_layout Standard
32471
32472 \series bold
32473 Name
32474 \end_layout
32475
32476 \end_inset
32477 </cell>
32478 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32479 \begin_inset Text
32480
32481 \begin_layout Standard
32482
32483 \series bold
32484 Subject / Title
32485 \end_layout
32486
32487 \end_inset
32488 </cell>
32489 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32490 \begin_inset Text
32491
32492 \begin_layout Standard
32493
32494 \series bold
32495 Where to get
32496 \end_layout
32497
32498 \end_inset
32499 </cell>
32500 </row>
32501 <row topline="true">
32502 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32503 \begin_inset Text
32504
32505 \begin_layout Standard
32506
32507 \family roman
32508 \series medium
32509 \shape up
32510 \size normal
32511 \emph off
32512 \bar no
32513 \noun off
32514 \color none
32515 c-refcard.pdf
32516 \end_layout
32517
32518 \end_inset
32519 </cell>
32520 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32521 \begin_inset Text
32522
32523 \begin_layout Standard
32524 C Reference Card
32525 \begin_inset LatexCommand \index{C Reference card}
32526
32527 \end_inset
32528
32529 , 2 pages
32530 \end_layout
32531
32532 \end_inset
32533 </cell>
32534 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32535 \begin_inset Text
32536
32537 \begin_layout Standard
32538 \begin_inset LatexCommand \url{http://refcards.com/refcards/c/index.html}
32539
32540 \end_inset
32541
32542
32543 \end_layout
32544
32545 \end_inset
32546 </cell>
32547 </row>
32548 <row topline="true">
32549 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32550 \begin_inset Text
32551
32552 \begin_layout Standard
32553 c-faq
32554 \end_layout
32555
32556 \end_inset
32557 </cell>
32558 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32559 \begin_inset Text
32560
32561 \begin_layout Standard
32562 C-FAQ
32563 \begin_inset LatexCommand \index{C FAQ}
32564
32565 \end_inset
32566
32567
32568 \end_layout
32569
32570 \end_inset
32571 </cell>
32572 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32573 \begin_inset Text
32574
32575 \begin_layout Standard
32576 \begin_inset LatexCommand \url{http://www.c-faq.com}
32577
32578 \end_inset
32579
32580
32581 \end_layout
32582
32583 \end_inset
32584 </cell>
32585 </row>
32586 <row topline="true">
32587 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32588 \begin_inset Text
32589
32590 \begin_layout Standard
32591 ISO/IEC 9899:TC2
32592 \end_layout
32593
32594 \end_inset
32595 </cell>
32596 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32597 \begin_inset Text
32598
32599 \begin_layout Standard
32600 \begin_inset Quotes sld
32601 \end_inset
32602
32603 C-Standard
32604 \begin_inset Quotes srd
32605 \end_inset
32606
32607
32608 \end_layout
32609
32610 \end_inset
32611 </cell>
32612 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32613 \begin_inset Text
32614
32615 \begin_layout Standard
32616
32617 \size footnotesize
32618 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
32619
32620 \end_inset
32621
32622
32623 \end_layout
32624
32625 \end_inset
32626 </cell>
32627 </row>
32628 <row topline="true">
32629 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32630 \begin_inset Text
32631
32632 \begin_layout Standard
32633 ISO/IEC DTR 18037
32634 \end_layout
32635
32636 \end_inset
32637 </cell>
32638 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32639 \begin_inset Text
32640
32641 \begin_layout Standard
32642 \begin_inset Quotes sld
32643 \end_inset
32644
32645 Extensions for Embedded C
32646 \begin_inset Quotes srd
32647 \end_inset
32648
32649
32650 \end_layout
32651
32652 \end_inset
32653 </cell>
32654 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32655 \begin_inset Text
32656
32657 \begin_layout Standard
32658
32659 \size footnotesize
32660 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1021.pdf}
32661
32662 \end_inset
32663
32664
32665 \end_layout
32666
32667 \end_inset
32668 </cell>
32669 </row>
32670 <row topline="true">
32671 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32672 \begin_inset Text
32673
32674 \begin_layout Standard
32675
32676 \end_layout
32677
32678 \end_inset
32679 </cell>
32680 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32681 \begin_inset Text
32682
32683 \begin_layout Standard
32684 Latest datasheet of target CPU
32685 \end_layout
32686
32687 \end_inset
32688 </cell>
32689 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32690 \begin_inset Text
32691
32692 \begin_layout Standard
32693 vendor
32694 \end_layout
32695
32696 \end_inset
32697 </cell>
32698 </row>
32699 <row topline="true" bottomline="true">
32700 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32701 \begin_inset Text
32702
32703 \begin_layout Standard
32704
32705 \end_layout
32706
32707 \end_inset
32708 </cell>
32709 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32710 \begin_inset Text
32711
32712 \begin_layout Standard
32713 Revision history of datasheet
32714 \end_layout
32715
32716 \end_inset
32717 </cell>
32718 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32719 \begin_inset Text
32720
32721 \begin_layout Standard
32722 vendor
32723 \end_layout
32724
32725 \end_inset
32726 </cell>
32727 </row>
32728 </lyxtabular>
32729
32730 \end_inset
32731
32732
32733 \newline
32734
32735 \end_layout
32736
32737 \begin_layout Section
32738 Application notes specifically for SDCC
32739 \end_layout
32740
32741 \begin_layout Standard
32742 SDCC makes no claims about the completeness of this list and about up-to-datenes
32743 s or correctness of the application notes
32744 \begin_inset LatexCommand \index{Application notes}
32745
32746 \end_inset
32747
32748 .
32749 \end_layout
32750
32751 \begin_layout Standard
32752 \align left
32753
32754 \size footnotesize
32755 \begin_inset Tabular
32756 <lyxtabular version="3" rows="7" columns="3">
32757 <features>
32758 <column alignment="block" valignment="top" leftline="true" width="17col%">
32759 <column alignment="block" valignment="top" leftline="true" width="27col%">
32760 <column alignment="block" valignment="top" leftline="true" rightline="true" width="57col%">
32761 <row topline="true" bottomline="true">
32762 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32763 \begin_inset Text
32764
32765 \begin_layout Standard
32766
32767 \series bold
32768 \size footnotesize
32769 Vendor
32770 \end_layout
32771
32772 \end_inset
32773 </cell>
32774 <cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
32775 \begin_inset Text
32776
32777 \begin_layout Standard
32778
32779 \series bold
32780 \size footnotesize
32781 Subject / Title
32782 \end_layout
32783
32784 \end_inset
32785 </cell>
32786 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32787 \begin_inset Text
32788
32789 \begin_layout Standard
32790
32791 \series bold
32792 \size footnotesize
32793 Where to get
32794 \end_layout
32795
32796 \end_inset
32797 </cell>
32798 </row>
32799 <row topline="true">
32800 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32801 \begin_inset Text
32802
32803 \begin_layout Standard
32804
32805 \size footnotesize
32806 Maxim / Dallas
32807 \end_layout
32808
32809 \end_inset
32810 </cell>
32811 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32812 \begin_inset Text
32813
32814 \begin_layout Standard
32815
32816 \size footnotesize
32817 Using the SDCC Compiler for the DS80C400
32818 \begin_inset LatexCommand \index{DS80C400}
32819
32820 \end_inset
32821
32822
32823 \end_layout
32824
32825 \end_inset
32826 </cell>
32827 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32828 \begin_inset Text
32829
32830 \begin_layout Standard
32831
32832 \size footnotesize
32833 \begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3346.pdf}
32834
32835 \end_inset
32836
32837
32838 \end_layout
32839
32840 \end_inset
32841 </cell>
32842 </row>
32843 <row topline="true">
32844 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32845 \begin_inset Text
32846
32847 \begin_layout Standard
32848
32849 \size footnotesize
32850 Maxim / Dallas
32851 \end_layout
32852
32853 \end_inset
32854 </cell>
32855 <cell multicolumn="1" alignment="left" valignment="top" topline="true" leftline="true" usebox="none" width="30line%">
32856 \begin_inset Text
32857
32858 \begin_layout Standard
32859
32860 \size footnotesize
32861 Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450
32862 \begin_inset LatexCommand \index{DS89C4x0}
32863
32864 \end_inset
32865
32866  Family of Microcontrollers
32867 \end_layout
32868
32869 \end_inset
32870 </cell>
32871 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32872 \begin_inset Text
32873
32874 \begin_layout Standard
32875
32876 \size footnotesize
32877 \begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3477.pdf}
32878
32879 \end_inset
32880
32881
32882 \end_layout
32883
32884 \end_inset
32885 </cell>
32886 </row>
32887 <row topline="true">
32888 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32889 \begin_inset Text
32890
32891 \begin_layout Standard
32892
32893 \size footnotesize
32894 Silicon Laboratories / Cygnal
32895 \end_layout
32896
32897 \end_inset
32898 </cell>
32899 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32900 \begin_inset Text
32901
32902 \begin_layout Standard
32903
32904 \size footnotesize
32905 Integrating SDCC 8051 Tools Into The Silicon Labs IDE
32906 \begin_inset LatexCommand \index{IDE}
32907
32908 \end_inset
32909
32910
32911 \end_layout
32912
32913 \end_inset
32914 </cell>
32915 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32916 \begin_inset Text
32917
32918 \begin_layout Standard
32919
32920 \size footnotesize
32921 \begin_inset LatexCommand \url{http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/en/an198.pdf}
32922
32923 \end_inset
32924
32925
32926 \end_layout
32927
32928 \end_inset
32929 </cell>
32930 </row>
32931 <row topline="true">
32932 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32933 \begin_inset Text
32934
32935 \begin_layout Standard
32936
32937 \size footnotesize
32938 Ramtron / Goal Semiconductor
32939 \end_layout
32940
32941 \end_inset
32942 </cell>
32943 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32944 \begin_inset Text
32945
32946 \begin_layout Standard
32947
32948 \size footnotesize
32949 Interfacing SDCC to Syn and Textpad
32950 \end_layout
32951
32952 \end_inset
32953 </cell>
32954 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32955 \begin_inset Text
32956
32957 \begin_layout Standard
32958
32959 \size footnotesize
32960 \begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
32961
32962 \end_inset
32963
32964
32965 \end_layout
32966
32967 \end_inset
32968 </cell>
32969 </row>
32970 <row topline="true">
32971 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32972 \begin_inset Text
32973
32974 \begin_layout Standard
32975
32976 \size footnotesize
32977 Ramtron / Goal Semiconductor
32978 \end_layout
32979
32980 \end_inset
32981 </cell>
32982 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32983 \begin_inset Text
32984
32985 \begin_layout Standard
32986
32987 \size footnotesize
32988 Installing and Configuring SDCC and Crimson Editor 
32989 \end_layout
32990
32991 \end_inset
32992 </cell>
32993 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32994 \begin_inset Text
32995
32996 \begin_layout Standard
32997
32998 \size footnotesize
32999 \begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
33000
33001 \end_inset
33002
33003
33004 \end_layout
33005
33006 \end_inset
33007 </cell>
33008 </row>
33009 <row topline="true" bottomline="true">
33010 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33011 \begin_inset Text
33012
33013 \begin_layout Standard
33014
33015 \size footnotesize
33016 Texas Instruments
33017 \end_layout
33018
33019 \end_inset
33020 </cell>
33021 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33022 \begin_inset Text
33023
33024 \begin_layout Standard
33025
33026 \size footnotesize
33027 MSC12xx Programming with SDCC
33028 \end_layout
33029
33030 \end_inset
33031 </cell>
33032 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33033 \begin_inset Text
33034
33035 \begin_layout Standard
33036
33037 \size footnotesize
33038 \begin_inset LatexCommand \url{http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sbaa109&fileType=pdf}
33039
33040 \end_inset
33041
33042
33043 \end_layout
33044
33045 \end_inset
33046 </cell>
33047 </row>
33048 </lyxtabular>
33049
33050 \end_inset
33051
33052
33053 \end_layout
33054
33055 \begin_layout Section
33056 Some Questions
33057 \end_layout
33058
33059 \begin_layout Standard
33060 Some questions answered, some pointers given - it might be time to in turn
33061  ask 
33062 \emph on
33063 you
33064 \emph default
33065  some questions: 
33066 \end_layout
33067
33068 \begin_layout Itemize
33069 can you solve your project with the selected microcontroller? Would you
33070  find out early or rather late that your target is too small/slow/whatever?
33071  Can you switch to a slightly better device if it doesn't fit?
33072 \end_layout
33073
33074 \begin_layout Itemize
33075 should you solve the problem with an 8 bit CPU? Or would a 16/32 bit CPU
33076  and/or another programming language be more adequate? Would an operating
33077  system on the target device help?
33078 \end_layout
33079
33080 \begin_layout Itemize
33081 if you solved the problem, will the marketing department be happy?
33082 \end_layout
33083
33084 \begin_layout Itemize
33085 if the marketing department is happy, will customers be happy?
33086 \end_layout
33087
33088 \begin_layout Itemize
33089 if you're the project manager, marketing department and maybe even the customer
33090  in one person, have you tried to see the project from the outside?
33091 \end_layout
33092
33093 \begin_layout Itemize
33094 is the project done if you think it is done? Or is just that other interface/pro
33095 tocol/feature/configuration/option missing? How about website, manual(s),
33096  internationali(z|s)ation, packaging, labels, 2nd source for components,
33097  electromagnetic compatability/interference, documentation for production,
33098  production test software, update mechanism, patent issues?
33099 \end_layout
33100
33101 \begin_layout Itemize
33102 is your project adequately positioned in that magic triangle: fame, fortune,
33103  fun?
33104 \end_layout
33105
33106 \begin_layout Standard
33107 Maybe not all answers to these questions are known and some answers may
33108  even be 
33109 \emph on
33110 no
33111 \emph default
33112 , nevertheless knowing these questions may help you to avoid burnout
33113 \begin_inset Foot
33114 status open
33115
33116 \begin_layout Standard
33117 burnout is bad for electronic devices, programmers and motorcycle tyres
33118 \end_layout
33119
33120 \end_inset
33121
33122 .
33123  Chances are you didn't want to hear some of them...
33124 \end_layout
33125
33126 \begin_layout Chapter
33127 Support
33128 \begin_inset LatexCommand \index{Support}
33129
33130 \end_inset
33131
33132
33133 \end_layout
33134
33135 \begin_layout Standard
33136 SDCC has grown to be a large project.
33137  The compiler alone (without the preprocessor, assembler and linker) is
33138  well over 150,000 lines of code (blank stripped).
33139  The open source nature of this project is a key to its continued growth
33140  and support.
33141  You gain the benefit and support of many active software developers and
33142  end users.
33143  Is SDCC perfect? No, that's why we need your help.
33144  The developers take pride in fixing reported bugs.
33145  You can help by reporting the bugs and helping other SDCC users.
33146  There are lots of ways to contribute, and we encourage you to take part
33147  in making SDCC a great software package.
33148  
33149 \end_layout
33150
33151 \begin_layout Standard
33152 The SDCC project is hosted on the SDCC sourceforge site at 
33153 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/sdcc}
33154
33155 \end_inset
33156
33157 .
33158  You'll find the complete set of mailing lists
33159 \begin_inset LatexCommand \index{Mailing list(s)}
33160
33161 \end_inset
33162
33163 , forums, bug reporting system, patch submission
33164 \begin_inset LatexCommand \index{Patch submission}
33165
33166 \end_inset
33167
33168  system, download
33169 \begin_inset LatexCommand \index{download}
33170
33171 \end_inset
33172
33173  area and Subversion code repository
33174 \begin_inset LatexCommand \index{Subversion code repository}
33175
33176 \end_inset
33177
33178  there.
33179 \end_layout
33180
33181 \begin_layout Section
33182 Reporting Bugs
33183 \begin_inset LatexCommand \index{Bug reporting}
33184
33185 \end_inset
33186
33187
33188 \begin_inset LatexCommand \index{Reporting bugs}
33189
33190 \end_inset
33191
33192
33193 \end_layout
33194
33195 \begin_layout Standard
33196 The recommended way of reporting bugs is using the infrastructure of the
33197  sourceforge site.
33198  You can follow the status of bug reports there and have an overview about
33199  the known bugs.
33200 \end_layout
33201
33202 \begin_layout Standard
33203 Bug reports are automatically forwarded to the developer mailing list and
33204  will be fixed ASAP.
33205  When reporting a bug, it is very useful to include a small test program
33206  (the smaller the better) which reproduces the problem.
33207  If you can isolate the problem by looking at the generated assembly code,
33208  this can be very helpful.
33209  Compiling your program with the -
33210 \begin_inset ERT
33211 status collapsed
33212
33213 \begin_layout Standard
33214
33215
33216 \backslash
33217 /
33218 \end_layout
33219
33220 \end_inset
33221
33222 -dumpall
33223 \begin_inset LatexCommand \index{-\/-dumpall}
33224
33225 \end_inset
33226
33227  option can sometimes be useful in locating optimization problems.
33228  When reporting a bug please make sure you:
33229 \end_layout
33230
33231 \begin_layout Enumerate
33232 Attach the code you are compiling with SDCC.
33233  
33234 \end_layout
33235
33236 \begin_layout Enumerate
33237 Specify the exact command you use to run SDCC, or attach your Makefile.
33238  
33239 \end_layout
33240
33241 \begin_layout Enumerate
33242 Specify the SDCC version (type "
33243 \family sans
33244 \series bold
33245 sdcc -v
33246 \family default
33247 \series default
33248 "), your platform, and operating system.
33249  
33250 \end_layout
33251
33252 \begin_layout Enumerate
33253 Provide an exact copy of any error message or incorrect output.
33254  
33255 \end_layout
33256
33257 \begin_layout Enumerate
33258 Put something meaningful in the subject of your message.
33259 \end_layout
33260
33261 \begin_layout Standard
33262 Please attempt to include these 5 important parts, as applicable, in all
33263  requests for support or when reporting any problems or bugs with SDCC.
33264  Though this will make your message lengthy, it will greatly improve your
33265  chance that SDCC users and developers will be able to help you.
33266  Some SDCC developers are frustrated by bug reports without code provided
33267  that they can use to reproduce and ultimately fix the problem, so please
33268  be sure to provide sample code if you are reporting a bug! 
33269 \end_layout
33270
33271 \begin_layout Standard
33272 Please have a short check that you are using a recent version of SDCC and
33273  the bug is not yet known.
33274  This is the link for reporting bugs: 
33275 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=100599}
33276
33277 \end_inset
33278
33279 .
33280  With SDCC on average having more than 200 downloads
33281 \begin_inset LatexCommand \index{download}
33282
33283 \end_inset
33284
33285  on sourceforge per day
33286 \begin_inset Foot
33287 status open
33288
33289 \begin_layout Standard
33290 220 daily downloads on average Jan-Sept 2006 and about 150 daily downloads
33291  between 2002 and 2005.
33292  This does not include other methods of distribution.
33293 \end_layout
33294
33295 \end_inset
33296
33297  there must be some users.
33298  So it's not exactly easy to find a new bug.
33299  If you find one we need it: 
33300 \emph on
33301 reporting bugs is good
33302 \emph default
33303 .
33304 \end_layout
33305
33306 \begin_layout Section
33307 Requesting Features
33308 \begin_inset LatexCommand \label{sub:Requesting-Features}
33309
33310 \end_inset
33311
33312
33313 \begin_inset LatexCommand \index{Feature request}
33314
33315 \end_inset
33316
33317
33318 \begin_inset LatexCommand \index{Requesting features}
33319
33320 \end_inset
33321
33322
33323 \end_layout
33324
33325 \begin_layout Standard
33326 Like bug reports feature requests are forwarded to the developer mailing
33327  list.
33328  This is the link for requesting features: 
33329 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
33330
33331 \end_inset
33332
33333 .
33334 \end_layout
33335
33336 \begin_layout Section
33337 Submitting patches
33338 \end_layout
33339
33340 \begin_layout Standard
33341 Like bug reports contributed patches are forwarded to the developer mailing
33342  list.
33343  This is the link for submitting patches
33344 \begin_inset LatexCommand \index{Patch submission}
33345
33346 \end_inset
33347
33348
33349 \begin_inset LatexCommand \url{http://sourceforge.net/tracker/?group_id=599&atid=300599}
33350
33351 \end_inset
33352
33353 .
33354 \end_layout
33355
33356 \begin_layout Standard
33357 You need to specify some parameters to the 
33358 \family typewriter
33359 diff
33360 \family default
33361  command for the patches to be useful.
33362  If you modified more than one file a patch created f.e.
33363  with 
33364 \family sans
33365 \series bold
33366
33367 \begin_inset Quotes sld
33368 \end_inset
33369
33370 diff -Naur unmodified_directory modified_directory >my_changes.patch
33371 \begin_inset Quotes srd
33372 \end_inset
33373
33374
33375 \family default
33376 \series default
33377  will be fine, otherwise 
33378 \family sans
33379 \series bold
33380
33381 \begin_inset Quotes sld
33382 \end_inset
33383
33384 diff -u sourcefile.c.orig sourcefile.c >my_changes.patch
33385 \begin_inset Quotes srd
33386 \end_inset
33387
33388
33389 \series default
33390  
33391 \family default
33392 will do.
33393 \end_layout
33394
33395 \begin_layout Section
33396 Getting Help
33397 \end_layout
33398
33399 \begin_layout Standard
33400 These links should take you directly to the 
33401 \begin_inset LatexCommand \url[Mailing lists]{http://sourceforge.net/mail/?group_id=599}
33402
33403 \end_inset
33404
33405
33406 \begin_inset Foot
33407 status open
33408
33409 \begin_layout Standard
33410 Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
33411  automated messages (mid 2003)
33412 \end_layout
33413
33414 \end_inset
33415
33416  and the 
33417 \begin_inset LatexCommand \url[Forums]{http://sourceforge.net/forum/?group_id=599}
33418
33419 \end_inset
33420
33421 , lists
33422 \begin_inset LatexCommand \index{Mailing list(s)}
33423
33424 \end_inset
33425
33426  and forums are archived and searchable so if you are lucky someone already
33427  had a similar problem.
33428  While mails to the lists themselves are delivered promptly their web front
33429  end on sourceforge sometimes shows a severe time lag (up to several weeks),
33430  if you're seriously using SDCC please consider subscribing to the lists.
33431 \end_layout
33432
33433 \begin_layout Section
33434 ChangeLog
33435 \end_layout
33436
33437 \begin_layout Standard
33438 You can follow the status of the Subversion version
33439 \begin_inset LatexCommand \index{version}
33440
33441 \end_inset
33442
33443  of SDCC by watching the Changelog
33444 \begin_inset LatexCommand \index{Changelog}
33445
33446 \end_inset
33447
33448  in the Subversion repository
33449 \size footnotesize
33450  
33451 \begin_inset LatexCommand \htmlurl{http://sdcc.svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/ChangeLog}
33452
33453 \end_inset
33454
33455 .
33456 \end_layout
33457
33458 \begin_layout Section
33459 Subversion Source Code Repository
33460 \end_layout
33461
33462 \begin_layout Standard
33463 The output of 
33464 \family sans
33465 \series bold
33466 sdcc -
33467 \family default
33468
33469 \begin_inset ERT
33470 status open
33471
33472 \begin_layout Standard
33473
33474
33475 \backslash
33476 /
33477 \end_layout
33478
33479 \end_inset
33480
33481
33482 \family sans
33483 -version
33484 \family default
33485 \series default
33486  or the filenames of the snapshot versions of SDCC include date and its
33487  Subversion
33488 \begin_inset LatexCommand \index{Subversion code repository}
33489
33490 \end_inset
33491
33492  number.
33493  Subversion allows to download the source of recent or previous versions
33494  
33495 \begin_inset LatexCommand \url{http://sourceforge.net/svn/?group_id=599}
33496
33497 \end_inset
33498
33499  (by number or by date).
33500  An on-line source code browser and detailled instructions are also available
33501  there.
33502  SDCC versions starting from 1999 up to now are available (currently the
33503  versions prior to the conversion from cvs
33504 \begin_inset LatexCommand \index{cvs|see{Subversion}}
33505
33506 \end_inset
33507
33508  to Subversion (April 2006) are either by accessible by Subversion or by
33509  cvs).
33510 \end_layout
33511
33512 \begin_layout Section
33513 Release policy
33514 \begin_inset LatexCommand \index{Release policy}
33515
33516 \end_inset
33517
33518
33519 \end_layout
33520
33521 \begin_layout Standard
33522 Historically there often were long delays between official releases and
33523  the sourceforge download area tends to get not updated at all.
33524  Excuses in the past might have referred to problems with live range analysis,
33525  but as this was fixed a while ago, the current problem is that another
33526  excuse has to be found.
33527  Kidding aside, we have to get better there! On the other hand there are
33528  daily snapshots available at 
33529 \begin_inset LatexCommand \htmlurl[snap]{http://sdcc.sourceforge.net/snap.php}
33530
33531 \end_inset
33532
33533 , and you can always build the very last version (hopefully with many bugs
33534  fixed, and features added) from the source code available at 
33535 \begin_inset LatexCommand \htmlurl[Source]{http://sdcc.sourceforge.net/snap.php#Source}
33536
33537 \end_inset
33538
33539 .
33540  The SDCC Wiki
33541 \begin_inset LatexCommand \index{wiki}
33542
33543 \end_inset
33544
33545
33546 \begin_inset LatexCommand \index{SDCC Wiki}
33547
33548 \end_inset
33549
33550  at 
33551 \begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/}
33552
33553 \end_inset
33554
33555  also holds some information about past and future releases.
33556 \end_layout
33557
33558 \begin_layout Section
33559 Examples
33560 \begin_inset LatexCommand \index{Examples}
33561
33562 \end_inset
33563
33564
33565 \end_layout
33566
33567 \begin_layout Standard
33568 You'll find some small examples in the directory 
33569 \emph on
33570 sdcc/device/examples/.
33571  
33572 \emph default
33573 More examples and libraries are available at
33574 \emph on
33575  The SDCC Open Knowledge Resource 
33576 \begin_inset LatexCommand \url{http://sdccokr.dl9sec.de/}
33577
33578 \end_inset
33579
33580  
33581 \emph default
33582 web site or at 
33583 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/}
33584
33585 \end_inset
33586
33587 .
33588 \end_layout
33589
33590 \begin_layout Standard
33591 \begin_inset Note Note
33592 status collapsed
33593
33594 \begin_layout Standard
33595 I did insert a reference to Paul's web site here although it seems rather
33596  dedicated to a specific 8032 board (I think it's okay because it f.e.
33597  shows LCD/Harddisc interface and has a free 8051 monitor.
33598  Independent 8032 board vendors face hard competition of heavily subsidized
33599  development boards anyway).
33600 \end_layout
33601
33602 \begin_layout Standard
33603 Maybe we should include some links to real world applications.
33604  Preferably pointer to pointers (one for each architecture) so this stays
33605  manageable here?
33606 \end_layout
33607
33608 \end_inset
33609
33610
33611 \end_layout
33612
33613 \begin_layout Section
33614 Quality control
33615 \begin_inset LatexCommand \label{sec:Quality-control}
33616
33617 \end_inset
33618
33619
33620 \begin_inset LatexCommand \index{Quality control}
33621
33622 \end_inset
33623
33624
33625 \end_layout
33626
33627 \begin_layout Standard
33628 The compiler is passed through snaphot build compile and build checks.
33629  The so called 
33630 \shape italic
33631 regression tests
33632 \shape default
33633
33634 \begin_inset LatexCommand \index{Regression test}
33635
33636 \end_inset
33637
33638  check that SDCC itself compiles flawlessly on several host platforms (i386,
33639  Opteron, 64 bit Alpha, ppc64, Mac OS X on ppc and i386, Solaris on Sparc)
33640  and checks the quality of the code generated by SDCC by running the code
33641  for several target platforms through simulators.
33642  The regression test suite comprises more than 100 files which expand to
33643  more than 500 test cases which include more than 4500 tests.
33644  The results of these tests are published daily on SDCC's snapshot page
33645  (click on the red or green symbols on the right side of 
33646 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
33647
33648 \end_inset
33649
33650 ).
33651 \end_layout
33652
33653 \begin_layout Standard
33654 There is a separate document 
33655 \shape italic
33656 test_suite.pdf 
33657 \begin_inset LatexCommand \index{Test suite}
33658
33659 \end_inset
33660
33661
33662 \shape default
33663  
33664 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
33665
33666 \end_inset
33667
33668  about the regression test suite.
33669 \end_layout
33670
33671 \begin_layout Standard
33672 You'll find the test code in the directory 
33673 \shape italic
33674 sdcc/support/regression
33675 \shape default
33676 .
33677  You can run these tests manually by running 
33678 \family sans
33679 make
33680 \family default
33681  in this directory (or f.e.
33682  
33683 \family sans
33684 \series bold
33685
33686 \begin_inset Quotes sld
33687 \end_inset
33688
33689 make test-mcs51
33690 \begin_inset Quotes srd
33691 \end_inset
33692
33693
33694 \family default
33695 \series default
33696  if you don't want to run the complete tests).
33697  The test code might also be interesting if you want to look for examples
33698 \begin_inset LatexCommand \index{Examples}
33699
33700 \end_inset
33701
33702  checking corner cases of SDCC or if you plan to submit patches
33703 \begin_inset LatexCommand \index{Patch submission}
33704
33705 \end_inset
33706
33707 .
33708 \end_layout
33709
33710 \begin_layout Standard
33711 The PIC14 port uses a different set of regression tests 
33712 \begin_inset LatexCommand \index{Regression test (PIC14)}
33713
33714 \end_inset
33715
33716 , you'll find them in the directory 
33717 \shape italic
33718 sdcc/src/regression
33719 \shape default
33720 .
33721 \end_layout
33722
33723 \begin_layout Section
33724 Use of SDCC in Education
33725 \end_layout
33726
33727 \begin_layout Standard
33728 In short: 
33729 \emph on
33730 highly
33731 \emph default
33732  encouraged
33733 \begin_inset Foot
33734 status open
33735
33736 \begin_layout Standard
33737 the phrase "use in education" might evoke the association "
33738 \emph on
33739 only
33740 \emph default
33741  fit for use in education".
33742  This connotation is not intended but nevertheless risked as the licensing
33743  of SDCC makes it difficult to offer educational discounts
33744 \end_layout
33745
33746 \end_inset
33747
33748 .
33749  If your rationales are to:
33750 \end_layout
33751
33752 \begin_layout Enumerate
33753 give students a chance to understand the 
33754 \emph on
33755 complete
33756 \emph default
33757  steps of code generation
33758 \end_layout
33759
33760 \begin_layout Enumerate
33761 have a curriculum that can be extended for years.
33762  Then you could use an fpga board as target and your curriculum will seamlessly
33763  extend from logic synthesis (
33764 \begin_inset LatexCommand \url[http://www.opencores.org]{opencores.org}
33765
33766 \end_inset
33767
33768
33769 \begin_inset LatexCommand \url[Oregano]{http://www.oregano.at/ip/ip01.htm}
33770
33771 \end_inset
33772
33773 ), over assembly programming, to C to FPGA compilers (
33774 \begin_inset LatexCommand \url[FPGAC]{http://sf.net/projects/fpgac}
33775
33776 \end_inset
33777
33778 ) and to C.
33779 \end_layout
33780
33781 \begin_layout Enumerate
33782 be able to insert excursions about skills like using a revision control
33783  system, submitting/applying patches, using a type-setting (as opposed to
33784  word-processing) engine LyX/LaTeX, using 
33785 \begin_inset LatexCommand \url[SourceForge]{http://www.sf.net}
33786
33787 \end_inset
33788
33789 , following some 
33790 \begin_inset LatexCommand \url[netiquette]{http://en.wikipedia.org/wiki/Netiquette}
33791
33792 \end_inset
33793
33794 , understanding BSD/LGPL/GPL/Proprietary licensing, growth models of Open
33795  Source Software, CPU simulation, compiler regression tests
33796 \begin_inset LatexCommand \index{Regression test}
33797
33798 \end_inset
33799
33800 .
33801  
33802 \newline
33803 And if there should be a shortage of ideas then you can always point students
33804  to the ever-growing feature request list 
33805 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
33806
33807 \end_inset
33808
33809 .
33810 \end_layout
33811
33812 \begin_layout Enumerate
33813 not tie students to a specific host platform and instead allow them to use
33814  a host platform of 
33815 \emph on
33816 their
33817 \emph default
33818  choice (among them Alpha, i386, i386_64, Mac OS X, Mips, Sparc, Windows
33819  and eventually 
33820 \begin_inset LatexCommand \url[OLPC]{http://www.laptop.org}
33821
33822 \end_inset
33823
33824 )
33825 \end_layout
33826
33827 \begin_layout Enumerate
33828 not encourage students to use illegal copies of educational software
33829 \end_layout
33830
33831 \begin_layout Enumerate
33832 be immune to licensing/availability/price changes of the chosen tool chain
33833 \end_layout
33834
33835 \begin_layout Enumerate
33836 be able to change to a new target platform without having to adopt a new
33837  tool chain
33838 \end_layout
33839
33840 \begin_layout Enumerate
33841 have complete control over and insight into the tool chain
33842 \end_layout
33843
33844 \begin_layout Enumerate
33845 make your students aware about the pros and cons of open source software
33846  development
33847 \end_layout
33848
33849 \begin_layout Enumerate
33850 give back to the public as you are probably at least partially publically
33851  funded
33852 \end_layout
33853
33854 \begin_layout Enumerate
33855 give students a chance to publically prove their skills and to possibly
33856  see a world wide impact
33857 \end_layout
33858
33859 \begin_layout Standard
33860 then SDCC is probably among the first choices.
33861  Well, probably SDCC might be the only choice.
33862 \newpage
33863
33864 \end_layout
33865
33866 \begin_layout Chapter
33867 SDCC Technical Data
33868 \end_layout
33869
33870 \begin_layout Section
33871 Optimizations
33872 \begin_inset LatexCommand \index{Optimizations}
33873
33874 \end_inset
33875
33876
33877 \end_layout
33878
33879 \begin_layout Standard
33880 SDCC performs a host of standard optimizations in addition to some MCU specific
33881  optimizations.
33882  
33883 \end_layout
33884
33885 \begin_layout Subsection
33886 Sub-expression Elimination
33887 \begin_inset LatexCommand \index{Subexpression elimination}
33888
33889 \end_inset
33890
33891
33892 \end_layout
33893
33894 \begin_layout Standard
33895 The compiler does local and 
33896 \emph on
33897 g
33898 \emph default
33899 lobal 
33900 \emph on
33901 c
33902 \emph default
33903 ommon 
33904 \emph on
33905 s
33906 \emph default
33907 ubexpression 
33908 \emph on
33909 e
33910 \emph default
33911 limination, e.g.: 
33912 \end_layout
33913
33914 \begin_layout Verse
33915
33916 \family typewriter
33917 i = x + y + 1; 
33918 \newline
33919 j = x + y;
33920 \end_layout
33921
33922 \begin_layout Standard
33923 will be translated to
33924 \end_layout
33925
33926 \begin_layout Verse
33927
33928 \family typewriter
33929 iTemp = x + y; 
33930 \newline
33931 i = iTemp + 1; 
33932 \newline
33933 j = iTemp;
33934 \end_layout
33935
33936 \begin_layout Standard
33937 Some subexpressions are not as obvious as the above example, e.g.:
33938 \end_layout
33939
33940 \begin_layout Verse
33941
33942 \family typewriter
33943 a->b[i].c = 10; 
33944 \newline
33945 a->b[i].d = 11;
33946 \end_layout
33947
33948 \begin_layout Standard
33949 In this case the address arithmetic a->b[i] will be computed only once;
33950  the equivalent code in C would be.
33951 \end_layout
33952
33953 \begin_layout Verse
33954
33955 \family typewriter
33956 iTemp = a->b[i]; 
33957 \newline
33958 iTemp.c = 10; 
33959 \newline
33960 iTemp.d = 11;
33961 \end_layout
33962
33963 \begin_layout Standard
33964 The compiler will try to keep these temporary variables in registers.
33965 \end_layout
33966
33967 \begin_layout Subsection
33968 Dead-Code Elimination
33969 \begin_inset LatexCommand \index{Dead-code elimination}
33970
33971 \end_inset
33972
33973
33974 \end_layout
33975
33976 \begin_layout Verse
33977
33978 \family typewriter
33979 int global;
33980 \newline
33981
33982 \newline
33983 void f () { 
33984 \newline
33985 \InsetSpace ~
33986 \InsetSpace ~
33987 int i; 
33988 \newline
33989 \InsetSpace ~
33990 \InsetSpace ~
33991 i = 1; \InsetSpace ~
33992 \InsetSpace ~
33993 \InsetSpace ~
33994 \InsetSpace ~
33995 \InsetSpace ~
33996 /* dead store */ 
33997 \newline
33998 \InsetSpace ~
33999 \InsetSpace ~
34000 global = 1;\InsetSpace ~
34001 /* dead
34002  store */ 
34003 \newline
34004 \InsetSpace ~
34005 \InsetSpace ~
34006 global = 2; 
34007 \newline
34008 \InsetSpace ~
34009 \InsetSpace ~
34010 return; 
34011 \newline
34012 \InsetSpace ~
34013 \InsetSpace ~
34014 global = 3;\InsetSpace ~
34015 /* unreachable */ 
34016 \newline
34017 }
34018 \end_layout
34019
34020 \begin_layout Standard
34021 will be changed to
34022 \end_layout
34023
34024 \begin_layout Verse
34025
34026 \family typewriter
34027 int global;
34028 \newline
34029
34030 \newline
34031 void f () {
34032 \newline
34033 \InsetSpace ~
34034 \InsetSpace ~
34035 global = 2; 
34036 \newline
34037 }
34038 \end_layout
34039
34040 \begin_layout Subsection
34041 Copy-Propagation
34042 \begin_inset LatexCommand \index{Copy propagation}
34043
34044 \end_inset
34045
34046
34047 \end_layout
34048
34049 \begin_layout Verse
34050
34051 \family typewriter
34052 int f() { 
34053 \newline
34054 \InsetSpace ~
34055 \InsetSpace ~
34056 int i, j; 
34057 \newline
34058 \InsetSpace ~
34059 \InsetSpace ~
34060 i = 10; 
34061 \newline
34062 \InsetSpace ~
34063 \InsetSpace ~
34064 j = i; 
34065 \newline
34066 \InsetSpace ~
34067 \InsetSpace ~
34068 return j; 
34069 \newline
34070 }
34071 \end_layout
34072
34073 \begin_layout Standard
34074 will be changed to 
34075 \end_layout
34076
34077 \begin_layout Verse
34078
34079 \family typewriter
34080 int f() { 
34081 \newline
34082 \InsetSpace ~
34083 \InsetSpace ~
34084 int i, j; 
34085 \newline
34086 \InsetSpace ~
34087 \InsetSpace ~
34088 i = 10; 
34089 \newline
34090 \InsetSpace ~
34091 \InsetSpace ~
34092 j = 10; 
34093 \newline
34094 \InsetSpace ~
34095 \InsetSpace ~
34096 return 10; 
34097 \newline
34098 }
34099 \end_layout
34100
34101 \begin_layout Standard
34102 Note: the dead stores created by this copy propagation will be eliminated
34103  by dead-code elimination.
34104 \end_layout
34105
34106 \begin_layout Subsection
34107 Loop Optimizations
34108 \begin_inset LatexCommand \index{Loop optimization}
34109
34110 \end_inset
34111
34112
34113 \begin_inset LatexCommand \label{sub:Loop-Optimizations}
34114
34115 \end_inset
34116
34117
34118 \end_layout
34119
34120 \begin_layout Standard
34121 Two types of loop optimizations are done by SDCC 
34122 \emph on
34123 loop invariant
34124 \emph default
34125  lifting and
34126 \emph on
34127  strength reduction
34128 \emph default
34129  of loop induction variables.
34130  In addition to the strength reduction the optimizer marks the induction
34131  variables and the register allocator tries to keep the induction variables
34132  in registers for the duration of the loop.
34133  Because of this preference of the register allocator
34134 \begin_inset LatexCommand \index{Register allocation}
34135
34136 \end_inset
34137
34138 , loop induction optimization causes an increase in register pressure, which
34139  may cause unwanted spilling of other temporary variables into the stack
34140 \begin_inset LatexCommand \index{stack}
34141
34142 \end_inset
34143
34144  / data space.
34145  The compiler will generate a warning message when it is forced to allocate
34146  extra space either on the stack or data space.
34147  If this extra space allocation is undesirable then induction optimization
34148  can be eliminated either for the entire source file (with -
34149 \begin_inset ERT
34150 status collapsed
34151
34152 \begin_layout Standard
34153
34154
34155 \backslash
34156 /
34157 \end_layout
34158
34159 \end_inset
34160
34161 -noinduction option) or for a given function only using #pragma\InsetSpace ~
34162 noinduction
34163 \begin_inset LatexCommand \index{\#pragma noinduction}
34164
34165 \end_inset
34166
34167 .
34168 \newline
34169
34170 \newline
34171 Loop Invariant:
34172 \end_layout
34173
34174 \begin_layout Verse
34175
34176 \family typewriter
34177 for (i = 0 ; i < 100 ; i ++) 
34178 \newline
34179 \InsetSpace ~
34180 \InsetSpace ~
34181 \InsetSpace ~
34182 \InsetSpace ~
34183 f += k + l;
34184 \end_layout
34185
34186 \begin_layout Standard
34187 changed to
34188 \end_layout
34189
34190 \begin_layout Verse
34191
34192 \family typewriter
34193 itemp = k + l; 
34194 \newline
34195 for (i = 0; i < 100; i++) 
34196 \newline
34197 \InsetSpace ~
34198 \InsetSpace ~
34199 \InsetSpace ~
34200 \InsetSpace ~
34201 f += itemp;
34202 \end_layout
34203
34204 \begin_layout Standard
34205 As mentioned previously some loop invariants are not as apparent, all static
34206  address computations are also moved out of the loop.
34207 \newline
34208
34209 \newline
34210 Strength Reduction
34211 \begin_inset LatexCommand \index{Strength reduction}
34212
34213 \end_inset
34214
34215 , this optimization substitutes an expression by a cheaper expression:
34216 \end_layout
34217
34218 \begin_layout Verse
34219
34220 \family typewriter
34221 for (i=0;i < 100; i++)
34222 \newline
34223 \InsetSpace ~
34224 \InsetSpace ~
34225 \InsetSpace ~
34226 \InsetSpace ~
34227 ar[i*5] = i*3;
34228 \end_layout
34229
34230 \begin_layout Standard
34231 changed to
34232 \end_layout
34233
34234 \begin_layout Verse
34235
34236 \family typewriter
34237 itemp1 = 0; 
34238 \newline
34239 itemp2 = 0; 
34240 \newline
34241 for (i=0;i< 100;i++) { 
34242 \newline
34243 \InsetSpace ~
34244 \InsetSpace ~
34245 \InsetSpace ~
34246 \InsetSpace ~
34247 ar[itemp1] = itemp2; 
34248 \newline
34249 \InsetSpace ~
34250 \InsetSpace ~
34251 \InsetSpace ~
34252 \InsetSpace ~
34253 itemp1
34254  += 5; 
34255 \newline
34256 \InsetSpace ~
34257 \InsetSpace ~
34258 \InsetSpace ~
34259 \InsetSpace ~
34260 itemp2 += 3; 
34261 \newline
34262 }
34263 \end_layout
34264
34265 \begin_layout Standard
34266 The more expensive multiplication
34267 \begin_inset LatexCommand \index{Multiplication}
34268
34269 \end_inset
34270
34271  is changed to a less expensive addition.
34272 \end_layout
34273
34274 \begin_layout Subsection
34275 Loop Reversing
34276 \begin_inset LatexCommand \index{Loop reversing}
34277
34278 \end_inset
34279
34280
34281 \end_layout
34282
34283 \begin_layout Standard
34284 This optimization is done to reduce the overhead of checking loop boundaries
34285  for every iteration.
34286  Some simple loops can be reversed and implemented using a 
34287 \begin_inset Quotes eld
34288 \end_inset
34289
34290 decrement and jump if not zero
34291 \begin_inset Quotes erd
34292 \end_inset
34293
34294  instruction.
34295  SDCC checks for the following criterion to determine if a loop is reversible
34296  (note: more sophisticated compilers use data-dependency analysis to make
34297  this determination, SDCC uses a more simple minded analysis).
34298 \end_layout
34299
34300 \begin_layout Itemize
34301 The 'for' loop is of the form 
34302 \newline
34303
34304 \newline
34305
34306 \family typewriter
34307 for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
34308  += 1])
34309 \newline
34310 \InsetSpace ~
34311 \InsetSpace ~
34312 \InsetSpace ~
34313 \InsetSpace ~
34314 <for body>
34315 \end_layout
34316
34317 \begin_layout Itemize
34318 The <for body> does not contain 
34319 \begin_inset Quotes eld
34320 \end_inset
34321
34322 continue
34323 \begin_inset Quotes erd
34324 \end_inset
34325
34326  or 'break
34327 \begin_inset Quotes erd
34328 \end_inset
34329
34330 .
34331 \end_layout
34332
34333 \begin_layout Itemize
34334 All goto's are contained within the loop.
34335 \end_layout
34336
34337 \begin_layout Itemize
34338 No function calls within the loop.
34339 \end_layout
34340
34341 \begin_layout Itemize
34342 The loop control variable <sym> is not assigned any value within the loop
34343 \end_layout
34344
34345 \begin_layout Itemize
34346 The loop control variable does NOT participate in any arithmetic operation
34347  within the loop.
34348 \end_layout
34349
34350 \begin_layout Itemize
34351 There are NO switch statements in the loop.
34352 \end_layout
34353
34354 \begin_layout Subsection
34355 Algebraic Simplifications
34356 \end_layout
34357
34358 \begin_layout Standard
34359 SDCC does numerous algebraic simplifications, the following is a small sub-set
34360  of these optimizations.
34361 \end_layout
34362
34363 \begin_layout Verse
34364
34365 \family typewriter
34366 i = j + 0;\InsetSpace ~
34367 \InsetSpace ~
34368 \InsetSpace ~
34369 \InsetSpace ~
34370  /* changed to: */\InsetSpace ~
34371 \InsetSpace ~
34372 \InsetSpace ~
34373 \InsetSpace ~
34374  i = j; 
34375 \newline
34376 i /= 2;\InsetSpace ~
34377 \InsetSpace ~
34378 \InsetSpace ~
34379 \InsetSpace ~
34380 \InsetSpace ~
34381 \InsetSpace ~
34382 \InsetSpace ~
34383  /* changed to: */\InsetSpace ~
34384 \InsetSpace ~
34385 \InsetSpace ~
34386 \InsetSpace ~
34387  i >>= 1; 
34388 \newline
34389 i
34390  = j - j;\InsetSpace ~
34391 \InsetSpace ~
34392 \InsetSpace ~
34393 \InsetSpace ~
34394  /* changed to: */\InsetSpace ~
34395 \InsetSpace ~
34396 \InsetSpace ~
34397 \InsetSpace ~
34398  i = 0; 
34399 \newline
34400 i = j / 1;\InsetSpace ~
34401 \InsetSpace ~
34402 \InsetSpace ~
34403 \InsetSpace ~
34404  /* changed to: */\InsetSpace ~
34405 \InsetSpace ~
34406 \InsetSpace ~
34407 \InsetSpace ~
34408  i = j;
34409 \end_layout
34410
34411 \begin_layout Standard
34412 Note the subexpressions
34413 \begin_inset LatexCommand \index{Subexpression}
34414
34415 \end_inset
34416
34417  given above are generally introduced by macro expansions or as a result
34418  of copy/constant propagation.
34419 \end_layout
34420
34421 \begin_layout Subsection
34422 'switch' Statements
34423 \begin_inset LatexCommand \label{sub:'switch'-Statements}
34424
34425 \end_inset
34426
34427
34428 \begin_inset LatexCommand \index{switch statement}
34429
34430 \end_inset
34431
34432
34433 \end_layout
34434
34435 \begin_layout Standard
34436 SDCC can optimize switch statements to jump tables
34437 \begin_inset LatexCommand \index{jump tables}
34438
34439 \end_inset
34440
34441 .
34442  It makes the decision based on an estimate of the generated code size.
34443  SDCC is quite liberal in the requirements for jump table generation: 
34444 \end_layout
34445
34446 \begin_layout Itemize
34447 The labels need not be in order, and the starting number need not be one
34448  or zero, the case labels are in numerical sequence or not too many case
34449  labels are missing.
34450 \end_layout
34451
34452 \begin_deeper
34453 \begin_layout Verse
34454
34455 \family typewriter
34456 switch(i) {\InsetSpace ~
34457 \InsetSpace ~
34458 \InsetSpace ~
34459 \InsetSpace ~
34460 \InsetSpace ~
34461 \InsetSpace ~
34462 \InsetSpace ~
34463 \InsetSpace ~
34464 \InsetSpace ~
34465 \InsetSpace ~
34466 \InsetSpace ~
34467 \InsetSpace ~
34468 \InsetSpace ~
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 switch (i) { 
34483 \newline
34484 \InsetSpace ~
34485 \InsetSpace ~
34486 \InsetSpace ~
34487 case 4: ...\InsetSpace ~
34488 \InsetSpace ~
34489 \InsetSpace ~
34490 \InsetSpace ~
34491 \InsetSpace ~
34492 \InsetSpace ~
34493 \InsetSpace ~
34494 \InsetSpace ~
34495 \InsetSpace ~
34496 \InsetSpace ~
34497 \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 \InsetSpace ~
34513 case 0: ...
34514  
34515 \newline
34516 \InsetSpace ~
34517 \InsetSpace ~
34518 \InsetSpace ~
34519 case 5: ...\InsetSpace ~
34520 \InsetSpace ~
34521 \InsetSpace ~
34522 \InsetSpace ~
34523 \InsetSpace ~
34524 \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 \InsetSpace ~
34543 \InsetSpace ~
34544 \InsetSpace ~
34545 case 1: ...
34546  
34547 \newline
34548 \InsetSpace ~
34549 \InsetSpace ~
34550 \InsetSpace ~
34551 case 3: ...\InsetSpace ~
34552 \InsetSpace ~
34553 \InsetSpace ~
34554 \InsetSpace ~
34555 \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 \InsetSpace ~
34571 \InsetSpace ~
34572 \InsetSpace ~
34573 \InsetSpace ~
34574 \InsetSpace ~
34575 \InsetSpace ~
34576 \InsetSpace ~
34577
34578 \newline
34579 \InsetSpace ~
34580 \InsetSpace ~
34581 \InsetSpace ~
34582 case 6: ...\InsetSpace ~
34583 \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 \InsetSpace ~
34599 \InsetSpace ~
34600 \InsetSpace ~
34601 \InsetSpace ~
34602 \InsetSpace ~
34603 \InsetSpace ~
34604 \InsetSpace ~
34605 \InsetSpace ~
34606 \InsetSpace ~
34607 \InsetSpace ~
34608 case 3: ...
34609  
34610 \newline
34611 \InsetSpace ~
34612 \InsetSpace ~
34613 \InsetSpace ~
34614 case 7: ...\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 \InsetSpace ~
34636 \InsetSpace ~
34637 \InsetSpace ~
34638 \InsetSpace ~
34639 \InsetSpace ~
34640 case 4: ...
34641  
34642 \newline
34643 \InsetSpace ~
34644 \InsetSpace ~
34645 \InsetSpace ~
34646 case 8: ...\InsetSpace ~
34647 \InsetSpace ~
34648 \InsetSpace ~
34649 \InsetSpace ~
34650 \InsetSpace ~
34651 \InsetSpace ~
34652 \InsetSpace ~
34653 \InsetSpace ~
34654 \InsetSpace ~
34655 \InsetSpace ~
34656 \InsetSpace ~
34657 \InsetSpace ~
34658 \InsetSpace ~
34659 \InsetSpace ~
34660 \InsetSpace ~
34661 \InsetSpace ~
34662 \InsetSpace ~
34663 \InsetSpace ~
34664 \InsetSpace ~
34665 \InsetSpace ~
34666 \InsetSpace ~
34667 \InsetSpace ~
34668 \InsetSpace ~
34669 \InsetSpace ~
34670 \InsetSpace ~
34671 \InsetSpace ~
34672 case 5: ...
34673  
34674 \newline
34675 \InsetSpace ~
34676 \InsetSpace ~
34677 \InsetSpace ~
34678 case 9: ...\InsetSpace ~
34679 \InsetSpace ~
34680 \InsetSpace ~
34681 \InsetSpace ~
34682 \InsetSpace ~
34683 \InsetSpace ~
34684 \InsetSpace ~
34685 \InsetSpace ~
34686 \InsetSpace ~
34687 \InsetSpace ~
34688 \InsetSpace ~
34689 \InsetSpace ~
34690 \InsetSpace ~
34691 \InsetSpace ~
34692 \InsetSpace ~
34693 \InsetSpace ~
34694 \InsetSpace ~
34695 \InsetSpace ~
34696 \InsetSpace ~
34697 \InsetSpace ~
34698 \InsetSpace ~
34699 \InsetSpace ~
34700 \InsetSpace ~
34701 \InsetSpace ~
34702 \InsetSpace ~
34703 \InsetSpace ~
34704 case 6: ...
34705  
34706 \newline
34707 \InsetSpace ~
34708 \InsetSpace ~
34709 \InsetSpace ~
34710 case 10: ...\InsetSpace ~
34711 \InsetSpace ~
34712 \InsetSpace ~
34713 \InsetSpace ~
34714 \InsetSpace ~
34715 \InsetSpace ~
34716 \InsetSpace ~
34717 \InsetSpace ~
34718 \InsetSpace ~
34719 \InsetSpace ~
34720 \InsetSpace ~
34721 \InsetSpace ~
34722 \InsetSpace ~
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 case 7: ...
34736  
34737 \newline
34738 \InsetSpace ~
34739 \InsetSpace ~
34740 \InsetSpace ~
34741 case 11: ...\InsetSpace ~
34742 \InsetSpace ~
34743 \InsetSpace ~
34744 \InsetSpace ~
34745 \InsetSpace ~
34746 \InsetSpace ~
34747 \InsetSpace ~
34748 \InsetSpace ~
34749 \InsetSpace ~
34750 \InsetSpace ~
34751 \InsetSpace ~
34752 \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 case 8: ...
34767  
34768 \newline
34769 }\InsetSpace ~
34770 \InsetSpace ~
34771 \InsetSpace ~
34772 \InsetSpace ~
34773 \InsetSpace ~
34774 \InsetSpace ~
34775 \InsetSpace ~
34776 \InsetSpace ~
34777 \InsetSpace ~
34778 \InsetSpace ~
34779 \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 \InsetSpace ~
34798 \InsetSpace ~
34799 \InsetSpace ~
34800 \InsetSpace ~
34801 \InsetSpace ~
34802 \InsetSpace ~
34803 \InsetSpace ~
34804 \InsetSpace ~
34805 }
34806 \end_layout
34807
34808 \begin_layout Standard
34809 Both the above switch statements will be implemented using a jump-table.
34810  The example to the right side is slightly more efficient as the check for
34811  the lower boundary of the jump-table is not needed.
34812 \end_layout
34813
34814 \end_deeper
34815 \begin_layout Itemize
34816 The number of case labels is not larger than supported by the target architectur
34817 e.
34818 \end_layout
34819
34820 \begin_layout Itemize
34821 If the case labels are not in numerical sequence ('gaps' between cases)
34822  SDCC checks whether a jump table with additionally inserted dummy cases
34823  is still attractive.
34824  
34825 \end_layout
34826
34827 \begin_layout Itemize
34828 If the starting number is not zero and a check for the lower boundary of
34829  the jump-table can thus be eliminated SDCC might insert dummy cases 0,
34830  ...
34831  .
34832 \end_layout
34833
34834 \begin_layout Standard
34835 Switch statements which have large gaps in the numeric sequence or those
34836  that have too many case labels can be split into more than one switch statement
34837  for efficient code generation, e.g.:
34838 \end_layout
34839
34840 \begin_layout Verse
34841
34842 \family typewriter
34843 switch (i) { 
34844 \newline
34845 \InsetSpace ~
34846 \InsetSpace ~
34847 case 1: ...
34848  
34849 \newline
34850 \InsetSpace ~
34851 \InsetSpace ~
34852 case 2: ...
34853  
34854 \newline
34855 \InsetSpace ~
34856 \InsetSpace ~
34857 case 3: ...
34858  
34859 \newline
34860 \InsetSpace ~
34861 \InsetSpace ~
34862 case 4: ...
34863  
34864 \newline
34865 \InsetSpace ~
34866 \InsetSpace ~
34867 case 5: ...
34868  
34869 \newline
34870 \InsetSpace ~
34871 \InsetSpace ~
34872 case 6: ...
34873  
34874 \newline
34875 \InsetSpace ~
34876 \InsetSpace ~
34877 case 7: ...
34878  
34879 \newline
34880 \InsetSpace ~
34881 \InsetSpace ~
34882 case 101: ...
34883  
34884 \newline
34885 \InsetSpace ~
34886 \InsetSpace ~
34887 case 102: ...
34888  
34889 \newline
34890 \InsetSpace ~
34891 \InsetSpace ~
34892 case 103: ...
34893  
34894 \newline
34895 \InsetSpace ~
34896 \InsetSpace ~
34897 case 104: ...
34898  
34899 \newline
34900 \InsetSpace ~
34901 \InsetSpace ~
34902 case 105: ...
34903  
34904 \newline
34905 \InsetSpace ~
34906 \InsetSpace ~
34907 case 106: ...
34908  
34909 \newline
34910 \InsetSpace ~
34911 \InsetSpace ~
34912 case 107: ...
34913  
34914 \newline
34915 }
34916 \end_layout
34917
34918 \begin_layout Standard
34919 If the above switch statement is broken down into two switch statements
34920 \end_layout
34921
34922 \begin_layout Verse
34923
34924 \family typewriter
34925 switch (i) { 
34926 \newline
34927 \InsetSpace ~
34928 \InsetSpace ~
34929 case 1: ...
34930  
34931 \newline
34932 \InsetSpace ~
34933 \InsetSpace ~
34934 case 2: ...
34935  
34936 \newline
34937 \InsetSpace ~
34938 \InsetSpace ~
34939 case 3: ...
34940  
34941 \newline
34942 \InsetSpace ~
34943 \InsetSpace ~
34944 case 4: ...
34945  
34946 \newline
34947 \InsetSpace ~
34948 \InsetSpace ~
34949 case 5: ...
34950  
34951 \newline
34952 \InsetSpace ~
34953 \InsetSpace ~
34954 case 6: ...
34955  
34956 \newline
34957 \InsetSpace ~
34958 \InsetSpace ~
34959 case 7: ...
34960  
34961 \newline
34962 }
34963 \end_layout
34964
34965 \begin_layout Standard
34966 and
34967 \end_layout
34968
34969 \begin_layout Verse
34970
34971 \family typewriter
34972 switch (i) { 
34973 \newline
34974 \InsetSpace ~
34975 \InsetSpace ~
34976 case 101: ...
34977  
34978 \newline
34979 \InsetSpace ~
34980 \InsetSpace ~
34981 case 102: ...
34982  
34983 \newline
34984 \InsetSpace ~
34985 \InsetSpace ~
34986 case 103: ...
34987  
34988 \newline
34989 \InsetSpace ~
34990 \InsetSpace ~
34991 case 104: ...
34992  
34993 \newline
34994 \InsetSpace ~
34995 \InsetSpace ~
34996 case 105: ...
34997  
34998 \newline
34999 \InsetSpace ~
35000 \InsetSpace ~
35001 case 106: ...
35002  
35003 \newline
35004 \InsetSpace ~
35005 \InsetSpace ~
35006 case 107: ...
35007  
35008 \newline
35009 }
35010 \end_layout
35011
35012 \begin_layout Standard
35013 then both the switch statements will be implemented using jump-tables whereas
35014  the unmodified switch statement will not be.
35015 \end_layout
35016
35017 \begin_layout Standard
35018 \begin_inset Note Note
35019 status collapsed
35020
35021 \begin_layout Standard
35022 There might be reasons which SDCC cannot know about to either favour or
35023  not favour jump tables.
35024  If the target system has to be as quick for the last switch case as for
35025  the first (pro jump table), or if the switch argument is known to be zero
35026  in the majority of the cases (contra jump table).
35027 \end_layout
35028
35029 \end_inset
35030
35031
35032 \end_layout
35033
35034 \begin_layout Standard
35035 The pragma nojtbound
35036 \begin_inset LatexCommand \index{\#pragma nojtbound}
35037
35038 \end_inset
35039
35040  can be used to turn off checking the 
35041 \emph on
35042 j
35043 \emph default
35044 ump 
35045 \emph on
35046 t
35047 \emph default
35048 able 
35049 \emph on
35050 bound
35051 \emph default
35052 aries.
35053  It has no effect if a default label is supplied.
35054  Use of this pragma is dangerous: if the switch
35055 \begin_inset LatexCommand \index{switch statement}
35056
35057 \end_inset
35058
35059  argument is not matched by a case statement the processor will happily
35060  jump into Nirvana.
35061 \end_layout
35062
35063 \begin_layout Subsection
35064 Bit-shifting Operations
35065 \begin_inset LatexCommand \index{Bit shifting}
35066
35067 \end_inset
35068
35069 .
35070 \end_layout
35071
35072 \begin_layout Standard
35073 Bit shifting is one of the most frequently used operation in embedded programmin
35074 g.
35075  SDCC tries to implement bit-shift operations in the most efficient way
35076  possible, e.g.:
35077 \end_layout
35078
35079 \begin_layout Verse
35080
35081 \family typewriter
35082 unsigned char i;
35083 \newline
35084 ...
35085  
35086 \newline
35087 i >>= 4; 
35088 \newline
35089 ...
35090 \end_layout
35091
35092 \begin_layout Standard
35093 generates the following code:
35094 \end_layout
35095
35096 \begin_layout Verse
35097
35098 \family typewriter
35099 mov\InsetSpace ~
35100  a,_i 
35101 \newline
35102 swap a 
35103 \newline
35104 anl\InsetSpace ~
35105  a,#0x0f 
35106 \newline
35107 mov\InsetSpace ~
35108  _i,a
35109 \end_layout
35110
35111 \begin_layout Standard
35112 In general SDCC will never setup a loop if the shift count is known.
35113  Another example:
35114 \end_layout
35115
35116 \begin_layout Verse
35117
35118 \family typewriter
35119 unsigned int i; 
35120 \newline
35121 ...
35122  
35123 \newline
35124 i >>= 9; 
35125 \newline
35126 ...
35127 \end_layout
35128
35129 \begin_layout Standard
35130 will generate:
35131 \end_layout
35132
35133 \begin_layout Verse
35134
35135 \family typewriter
35136 mov\InsetSpace ~
35137 \InsetSpace ~
35138 a,(_i + 1) 
35139 \newline
35140 mov\InsetSpace ~
35141 \InsetSpace ~
35142 (_i + 1),#0x00 
35143 \newline
35144 clr\InsetSpace ~
35145 \InsetSpace ~
35146
35147 \newline
35148 rrc\InsetSpace ~
35149 \InsetSpace ~
35150
35151 \newline
35152 mov\InsetSpace ~
35153 \InsetSpace ~
35154 _i,a
35155 \end_layout
35156
35157 \begin_layout Subsection
35158 Bit-rotation
35159 \begin_inset LatexCommand \index{Bit rotation}
35160
35161 \end_inset
35162
35163
35164 \end_layout
35165
35166 \begin_layout Standard
35167 A special case of the bit-shift operation is bit rotation
35168 \begin_inset LatexCommand \index{rotating bits}
35169
35170 \end_inset
35171
35172 , SDCC recognizes the following expression to be a left bit-rotation:
35173 \end_layout
35174
35175 \begin_layout Verse
35176
35177 \family typewriter
35178 \series bold
35179 unsigned
35180 \series default
35181 \InsetSpace ~
35182 \InsetSpace ~
35183 char i;\InsetSpace ~
35184 \InsetSpace ~
35185 \InsetSpace ~
35186 \InsetSpace ~
35187 \InsetSpace ~
35188 \InsetSpace ~
35189 \InsetSpace ~
35190 \InsetSpace ~
35191 \InsetSpace ~
35192 \InsetSpace ~
35193 \InsetSpace ~
35194 /* unsigned is needed for rotation */ 
35195 \newline
35196 ...
35197  
35198 \newline
35199 i = ((i << 1) | (i >> 7)); 
35200 \family default
35201
35202 \newline
35203
35204 \family typewriter
35205 ...
35206 \end_layout
35207
35208 \begin_layout Standard
35209 will generate the following code:
35210 \end_layout
35211
35212 \begin_layout Verse
35213
35214 \family typewriter
35215 mov\InsetSpace ~
35216 \InsetSpace ~
35217 a,_i 
35218 \newline
35219 rl\InsetSpace ~
35220 \InsetSpace ~
35221 \InsetSpace ~
35222
35223 \newline
35224 mov\InsetSpace ~
35225 \InsetSpace ~
35226 _i,a
35227 \end_layout
35228
35229 \begin_layout Standard
35230 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
35231 ns of this case will also be recognized as bit-rotation, i.e.: 
35232 \end_layout
35233
35234 \begin_layout Verse
35235
35236 \family typewriter
35237 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
35238 \end_layout
35239
35240 \begin_layout Subsection
35241 Nibble and Byte Swapping
35242 \end_layout
35243
35244 \begin_layout Standard
35245 Other special cases of the bit-shift operations are nibble or byte swapping
35246 \begin_inset LatexCommand \index{swapping nibbles/bytes}
35247
35248 \end_inset
35249
35250 , SDCC recognizes the following expressions:
35251 \end_layout
35252
35253 \begin_layout Verse
35254
35255 \family typewriter
35256 \series bold
35257 unsigned
35258 \series default
35259 \InsetSpace ~
35260 \InsetSpace ~
35261 char i; 
35262 \newline
35263
35264 \series bold
35265 unsigned
35266 \series default
35267 \InsetSpace ~
35268 \InsetSpace ~
35269 int j; 
35270 \newline
35271 ...
35272  
35273 \newline
35274 i = ((i << 4) | (i >> 4)); 
35275 \family default
35276
35277 \newline
35278
35279 \family typewriter
35280 j = ((j << 8) | (j >> 8)); 
35281 \end_layout
35282
35283 \begin_layout Standard
35284 and generates a swap instruction for the nibble swapping
35285 \begin_inset LatexCommand \index{Nibble swapping}
35286
35287 \end_inset
35288
35289  or move instructions for the byte swapping
35290 \begin_inset LatexCommand \index{Byte swapping}
35291
35292 \end_inset
35293
35294 .
35295  The 
35296 \begin_inset Quotes sld
35297 \end_inset
35298
35299 j
35300 \begin_inset Quotes srd
35301 \end_inset
35302
35303  example can be used to convert from little to big-endian or vice versa.
35304  If you want to change the endianness of a 
35305 \emph on
35306 signed
35307 \emph default
35308  integer you have to cast to 
35309 \family typewriter
35310 (unsigned int)
35311 \family default
35312  first.
35313 \end_layout
35314
35315 \begin_layout Standard
35316 Note that SDCC stores numbers in little-endian
35317 \begin_inset Foot
35318 status open
35319
35320 \begin_layout Standard
35321 Usually 8-bit processors don't care much about endianness.
35322  This is not the case for the standard 8051 which only has an instruction
35323  to increment its 
35324 \emph on
35325 dptr
35326 \emph default
35327
35328 \begin_inset LatexCommand \index{DPTR}
35329
35330 \end_inset
35331
35332 -datapointer
35333 \emph on
35334  
35335 \emph default
35336 so little-endian is the more efficient byte order.
35337 \end_layout
35338
35339 \end_inset
35340
35341
35342 \begin_inset LatexCommand \index{little-endian}
35343
35344 \end_inset
35345
35346
35347 \begin_inset LatexCommand \index{Endianness}
35348
35349 \end_inset
35350
35351  format (i.e.
35352  lowest order first).
35353 \end_layout
35354
35355 \begin_layout Subsection
35356 Highest Order Bit
35357 \begin_inset LatexCommand \index{Highest Order Bit}
35358
35359 \end_inset
35360
35361  / Any Order Bit
35362 \begin_inset LatexCommand \index{Any Order Bit}
35363
35364 \end_inset
35365
35366
35367 \end_layout
35368
35369 \begin_layout Standard
35370 It is frequently required to obtain the highest order bit of an integral
35371  type (long, int, short or char types).
35372  Also obtaining any other order bit is not uncommon.
35373  SDCC recognizes the following expressions to yield the highest order bit
35374  and generates optimized code for it, e.g.:
35375 \end_layout
35376
35377 \begin_layout Verse
35378
35379 \family typewriter
35380 unsigned int gint; 
35381 \newline
35382
35383 \newline
35384 foo () { 
35385 \newline
35386 \InsetSpace ~
35387 \InsetSpace ~
35388 unsigned char hob1, aob1; 
35389 \newline
35390 \InsetSpace ~
35391 \InsetSpace ~
35392 bit hob2, hob3, aob2,
35393  aob3; 
35394 \newline
35395 \InsetSpace ~
35396 \InsetSpace ~
35397 ...
35398  
35399 \newline
35400 \InsetSpace ~
35401 \InsetSpace ~
35402 hob1 = (gint >> 15) & 1; 
35403 \newline
35404 \InsetSpace ~
35405 \InsetSpace ~
35406 hob2 = (gint >> 15) & 1; 
35407 \newline
35408 \InsetSpace ~
35409 \InsetSpace ~
35410 hob3 = gint & 0x8000;
35411  
35412 \newline
35413 \InsetSpace ~
35414 \InsetSpace ~
35415 aob1 = (gint >> 9) & 1; 
35416 \newline
35417 \InsetSpace ~
35418 \InsetSpace ~
35419 aob2 = (gint >> 8) & 1; 
35420 \newline
35421 \InsetSpace ~
35422 \InsetSpace ~
35423 aob3 = gint & 0x0800; 
35424 \newline
35425 \InsetSpace ~
35426 \InsetSpace ~
35427 ..
35428  
35429 \newline
35430 }
35431 \end_layout
35432
35433 \begin_layout Standard
35434 will generate the following code:
35435 \end_layout
35436
35437 \begin_layout Verse
35438
35439 \family typewriter
35440 \InsetSpace ~
35441 \InsetSpace ~
35442 \InsetSpace ~
35443 \InsetSpace ~
35444 \InsetSpace ~
35445 \InsetSpace ~
35446 \InsetSpace ~
35447 \InsetSpace ~
35448 \InsetSpace ~
35449 \InsetSpace ~
35450 \InsetSpace ~
35451 \InsetSpace ~
35452 \InsetSpace ~
35453 \InsetSpace ~
35454 \InsetSpace ~
35455 \InsetSpace ~
35456 \InsetSpace ~
35457 \InsetSpace ~
35458 \InsetSpace ~
35459 \InsetSpace ~
35460 \InsetSpace ~
35461 \InsetSpace ~
35462 \InsetSpace ~
35463 \InsetSpace ~
35464 \InsetSpace ~
35465  61 ;\InsetSpace ~
35466  hob.c 7 
35467 \newline
35468 000A E5*01\InsetSpace ~
35469 \InsetSpace ~
35470 \InsetSpace ~
35471 \InsetSpace ~
35472 \InsetSpace ~
35473 \InsetSpace ~
35474 \InsetSpace ~
35475 \InsetSpace ~
35476 \InsetSpace ~
35477 \InsetSpace ~
35478 \InsetSpace ~
35479 \InsetSpace ~
35480 \InsetSpace ~
35481 \InsetSpace ~
35482 \InsetSpace ~
35483  62\InsetSpace ~
35484 \InsetSpace ~
35485 \InsetSpace ~
35486 \InsetSpace ~
35487 \InsetSpace ~
35488 \InsetSpace ~
35489 \InsetSpace ~
35490 \InsetSpace ~
35491  mov\InsetSpace ~
35492 \InsetSpace ~
35493  a,(_gint + 1) 
35494 \newline
35495 000C 23\InsetSpace ~
35496 \InsetSpace ~
35497 \InsetSpace ~
35498 \InsetSpace ~
35499 \InsetSpace ~
35500 \InsetSpace ~
35501 \InsetSpace ~
35502 \InsetSpace ~
35503 \InsetSpace ~
35504 \InsetSpace ~
35505 \InsetSpace ~
35506 \InsetSpace ~
35507 \InsetSpace ~
35508 \InsetSpace ~
35509 \InsetSpace ~
35510 \InsetSpace ~
35511 \InsetSpace ~
35512 \InsetSpace ~
35513  63\InsetSpace ~
35514 \InsetSpace ~
35515 \InsetSpace ~
35516 \InsetSpace ~
35517 \InsetSpace ~
35518 \InsetSpace ~
35519 \InsetSpace ~
35520 \InsetSpace ~
35521  rl\InsetSpace ~
35522 \InsetSpace ~
35523 \InsetSpace ~
35524  a 
35525 \newline
35526 000D 54 01\InsetSpace ~
35527 \InsetSpace ~
35528 \InsetSpace ~
35529 \InsetSpace ~
35530 \InsetSpace ~
35531 \InsetSpace ~
35532 \InsetSpace ~
35533 \InsetSpace ~
35534 \InsetSpace ~
35535 \InsetSpace ~
35536 \InsetSpace ~
35537 \InsetSpace ~
35538 \InsetSpace ~
35539 \InsetSpace ~
35540 \InsetSpace ~
35541
35542  64\InsetSpace ~
35543 \InsetSpace ~
35544 \InsetSpace ~
35545 \InsetSpace ~
35546 \InsetSpace ~
35547 \InsetSpace ~
35548 \InsetSpace ~
35549 \InsetSpace ~
35550  anl\InsetSpace ~
35551 \InsetSpace ~
35552  a,#0x01 
35553 \newline
35554 000F F5*02\InsetSpace ~
35555 \InsetSpace ~
35556 \InsetSpace ~
35557 \InsetSpace ~
35558 \InsetSpace ~
35559 \InsetSpace ~
35560 \InsetSpace ~
35561 \InsetSpace ~
35562 \InsetSpace ~
35563 \InsetSpace ~
35564 \InsetSpace ~
35565 \InsetSpace ~
35566 \InsetSpace ~
35567 \InsetSpace ~
35568 \InsetSpace ~
35569  65\InsetSpace ~
35570 \InsetSpace ~
35571 \InsetSpace ~
35572 \InsetSpace ~
35573 \InsetSpace ~
35574 \InsetSpace ~
35575 \InsetSpace ~
35576 \InsetSpace ~
35577  mov\InsetSpace ~
35578 \InsetSpace ~
35579  _foo_hob1_1_1,a 
35580 \newline
35581 \InsetSpace ~
35582 \InsetSpace ~
35583 \InsetSpace ~
35584 \InsetSpace ~
35585 \InsetSpace ~
35586 \InsetSpace ~
35587 \InsetSpace ~
35588 \InsetSpace ~
35589 \InsetSpace ~
35590 \InsetSpace ~
35591 \InsetSpace ~
35592 \InsetSpace ~
35593 \InsetSpace ~
35594 \InsetSpace ~
35595 \InsetSpace ~
35596 \InsetSpace ~
35597 \InsetSpace ~
35598 \InsetSpace ~
35599 \InsetSpace ~
35600 \InsetSpace ~
35601 \InsetSpace ~
35602 \InsetSpace ~
35603 \InsetSpace ~
35604 \InsetSpace ~
35605 \InsetSpace ~
35606  66 ;\InsetSpace ~
35607  hob.c 8 
35608 \newline
35609 0011 E5*01\InsetSpace ~
35610 \InsetSpace ~
35611 \InsetSpace ~
35612 \InsetSpace ~
35613 \InsetSpace ~
35614 \InsetSpace ~
35615 \InsetSpace ~
35616 \InsetSpace ~
35617 \InsetSpace ~
35618 \InsetSpace ~
35619 \InsetSpace ~
35620 \InsetSpace ~
35621 \InsetSpace ~
35622 \InsetSpace ~
35623 \InsetSpace ~
35624
35625  67\InsetSpace ~
35626 \InsetSpace ~
35627 \InsetSpace ~
35628 \InsetSpace ~
35629 \InsetSpace ~
35630 \InsetSpace ~
35631 \InsetSpace ~
35632 \InsetSpace ~
35633  mov\InsetSpace ~
35634 \InsetSpace ~
35635  a,(_gint + 1) 
35636 \newline
35637 0013 33\InsetSpace ~
35638 \InsetSpace ~
35639 \InsetSpace ~
35640 \InsetSpace ~
35641 \InsetSpace ~
35642 \InsetSpace ~
35643 \InsetSpace ~
35644 \InsetSpace ~
35645 \InsetSpace ~
35646 \InsetSpace ~
35647 \InsetSpace ~
35648 \InsetSpace ~
35649 \InsetSpace ~
35650 \InsetSpace ~
35651 \InsetSpace ~
35652 \InsetSpace ~
35653 \InsetSpace ~
35654 \InsetSpace ~
35655  68\InsetSpace ~
35656 \InsetSpace ~
35657 \InsetSpace ~
35658 \InsetSpace ~
35659 \InsetSpace ~
35660 \InsetSpace ~
35661 \InsetSpace ~
35662 \InsetSpace ~
35663  rlc\InsetSpace ~
35664 \InsetSpace ~
35665  a 
35666 \newline
35667 0014 92*00\InsetSpace ~
35668 \InsetSpace ~
35669 \InsetSpace ~
35670 \InsetSpace ~
35671 \InsetSpace ~
35672 \InsetSpace ~
35673 \InsetSpace ~
35674 \InsetSpace ~
35675 \InsetSpace ~
35676 \InsetSpace ~
35677 \InsetSpace ~
35678 \InsetSpace ~
35679 \InsetSpace ~
35680 \InsetSpace ~
35681 \InsetSpace ~
35682  69\InsetSpace ~
35683 \InsetSpace ~
35684 \InsetSpace ~
35685 \InsetSpace ~
35686 \InsetSpace ~
35687 \InsetSpace ~
35688 \InsetSpace ~
35689 \InsetSpace ~
35690  mov\InsetSpace ~
35691 \InsetSpace ~
35692  _foo_hob2_1_1,c
35693  
35694 \newline
35695 \InsetSpace ~
35696 \InsetSpace ~
35697 \InsetSpace ~
35698 \InsetSpace ~
35699 \InsetSpace ~
35700 \InsetSpace ~
35701 \InsetSpace ~
35702 \InsetSpace ~
35703 \InsetSpace ~
35704 \InsetSpace ~
35705 \InsetSpace ~
35706 \InsetSpace ~
35707 \InsetSpace ~
35708 \InsetSpace ~
35709 \InsetSpace ~
35710 \InsetSpace ~
35711 \InsetSpace ~
35712 \InsetSpace ~
35713 \InsetSpace ~
35714 \InsetSpace ~
35715 \InsetSpace ~
35716 \InsetSpace ~
35717 \InsetSpace ~
35718 \InsetSpace ~
35719 \InsetSpace ~
35720  66 ;\InsetSpace ~
35721  hob.c 9 
35722 \newline
35723 0016 E5*01\InsetSpace ~
35724 \InsetSpace ~
35725 \InsetSpace ~
35726 \InsetSpace ~
35727 \InsetSpace ~
35728 \InsetSpace ~
35729 \InsetSpace ~
35730 \InsetSpace ~
35731 \InsetSpace ~
35732 \InsetSpace ~
35733 \InsetSpace ~
35734 \InsetSpace ~
35735 \InsetSpace ~
35736 \InsetSpace ~
35737 \InsetSpace ~
35738  67\InsetSpace ~
35739 \InsetSpace ~
35740 \InsetSpace ~
35741 \InsetSpace ~
35742 \InsetSpace ~
35743 \InsetSpace ~
35744 \InsetSpace ~
35745 \InsetSpace ~
35746  mov\InsetSpace ~
35747 \InsetSpace ~
35748  a,(_gint + 1) 
35749 \newline
35750 0018 33\InsetSpace ~
35751 \InsetSpace ~
35752 \InsetSpace ~
35753 \InsetSpace ~
35754 \InsetSpace ~
35755 \InsetSpace ~
35756 \InsetSpace ~
35757 \InsetSpace ~
35758 \InsetSpace ~
35759 \InsetSpace ~
35760 \InsetSpace ~
35761 \InsetSpace ~
35762 \InsetSpace ~
35763 \InsetSpace ~
35764 \InsetSpace ~
35765 \InsetSpace ~
35766 \InsetSpace ~
35767 \InsetSpace ~
35768  68\InsetSpace ~
35769 \InsetSpace ~
35770 \InsetSpace ~
35771 \InsetSpace ~
35772 \InsetSpace ~
35773 \InsetSpace ~
35774 \InsetSpace ~
35775 \InsetSpace ~
35776  rlc\InsetSpace ~
35777 \InsetSpace ~
35778  a 
35779 \newline
35780 0019 92*01\InsetSpace ~
35781 \InsetSpace ~
35782 \InsetSpace ~
35783 \InsetSpace ~
35784 \InsetSpace ~
35785 \InsetSpace ~
35786 \InsetSpace ~
35787 \InsetSpace ~
35788 \InsetSpace ~
35789 \InsetSpace ~
35790 \InsetSpace ~
35791 \InsetSpace ~
35792 \InsetSpace ~
35793 \InsetSpace ~
35794 \InsetSpace ~
35795
35796  69\InsetSpace ~
35797 \InsetSpace ~
35798 \InsetSpace ~
35799 \InsetSpace ~
35800 \InsetSpace ~
35801 \InsetSpace ~
35802 \InsetSpace ~
35803 \InsetSpace ~
35804  mov\InsetSpace ~
35805 \InsetSpace ~
35806  _foo_hob3_1_1,c 
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 \InsetSpace ~
35825 \InsetSpace ~
35826 \InsetSpace ~
35827 \InsetSpace ~
35828 \InsetSpace ~
35829 \InsetSpace ~
35830 \InsetSpace ~
35831 \InsetSpace ~
35832 \InsetSpace ~
35833  70 ;\InsetSpace ~
35834  hob.c 10 
35835 \newline
35836 001B E5*01\InsetSpace ~
35837 \InsetSpace ~
35838 \InsetSpace ~
35839 \InsetSpace ~
35840 \InsetSpace ~
35841 \InsetSpace ~
35842 \InsetSpace ~
35843 \InsetSpace ~
35844 \InsetSpace ~
35845 \InsetSpace ~
35846 \InsetSpace ~
35847 \InsetSpace ~
35848 \InsetSpace ~
35849 \InsetSpace ~
35850 \InsetSpace ~
35851  71\InsetSpace ~
35852 \InsetSpace ~
35853 \InsetSpace ~
35854 \InsetSpace ~
35855 \InsetSpace ~
35856 \InsetSpace ~
35857 \InsetSpace ~
35858 \InsetSpace ~
35859  mov\InsetSpace ~
35860 \InsetSpace ~
35861  a,(_gint + 1) 
35862 \newline
35863 001D
35864  03\InsetSpace ~
35865 \InsetSpace ~
35866 \InsetSpace ~
35867 \InsetSpace ~
35868 \InsetSpace ~
35869 \InsetSpace ~
35870 \InsetSpace ~
35871 \InsetSpace ~
35872 \InsetSpace ~
35873 \InsetSpace ~
35874 \InsetSpace ~
35875 \InsetSpace ~
35876 \InsetSpace ~
35877 \InsetSpace ~
35878 \InsetSpace ~
35879 \InsetSpace ~
35880 \InsetSpace ~
35881 \InsetSpace ~
35882  72\InsetSpace ~
35883 \InsetSpace ~
35884 \InsetSpace ~
35885 \InsetSpace ~
35886 \InsetSpace ~
35887 \InsetSpace ~
35888 \InsetSpace ~
35889 \InsetSpace ~
35890  rr\InsetSpace ~
35891 \InsetSpace ~
35892 \InsetSpace ~
35893  a 
35894 \newline
35895 001E 54 01\InsetSpace ~
35896 \InsetSpace ~
35897 \InsetSpace ~
35898 \InsetSpace ~
35899 \InsetSpace ~
35900 \InsetSpace ~
35901 \InsetSpace ~
35902 \InsetSpace ~
35903 \InsetSpace ~
35904 \InsetSpace ~
35905 \InsetSpace ~
35906 \InsetSpace ~
35907 \InsetSpace ~
35908 \InsetSpace ~
35909 \InsetSpace ~
35910  73\InsetSpace ~
35911 \InsetSpace ~
35912 \InsetSpace ~
35913 \InsetSpace ~
35914 \InsetSpace ~
35915 \InsetSpace ~
35916 \InsetSpace ~
35917 \InsetSpace ~
35918  anl\InsetSpace ~
35919 \InsetSpace ~
35920  a,#0x01 
35921 \newline
35922 0020 F5*03\InsetSpace ~
35923 \InsetSpace ~
35924 \InsetSpace ~
35925 \InsetSpace ~
35926 \InsetSpace ~
35927 \InsetSpace ~
35928 \InsetSpace ~
35929 \InsetSpace ~
35930 \InsetSpace ~
35931 \InsetSpace ~
35932 \InsetSpace ~
35933 \InsetSpace ~
35934 \InsetSpace ~
35935 \InsetSpace ~
35936 \InsetSpace ~
35937  74\InsetSpace ~
35938 \InsetSpace ~
35939 \InsetSpace ~
35940 \InsetSpace ~
35941 \InsetSpace ~
35942 \InsetSpace ~
35943 \InsetSpace ~
35944 \InsetSpace ~
35945  mov\InsetSpace ~
35946 \InsetSpace ~
35947  _foo_aob1_1_1,a
35948  
35949 \newline
35950 \InsetSpace ~
35951 \InsetSpace ~
35952 \InsetSpace ~
35953 \InsetSpace ~
35954 \InsetSpace ~
35955 \InsetSpace ~
35956 \InsetSpace ~
35957 \InsetSpace ~
35958 \InsetSpace ~
35959 \InsetSpace ~
35960 \InsetSpace ~
35961 \InsetSpace ~
35962 \InsetSpace ~
35963 \InsetSpace ~
35964 \InsetSpace ~
35965 \InsetSpace ~
35966 \InsetSpace ~
35967 \InsetSpace ~
35968 \InsetSpace ~
35969 \InsetSpace ~
35970 \InsetSpace ~
35971 \InsetSpace ~
35972 \InsetSpace ~
35973 \InsetSpace ~
35974 \InsetSpace ~
35975  75 ;\InsetSpace ~
35976  hob.c 11 
35977 \newline
35978 0022 E5*01\InsetSpace ~
35979 \InsetSpace ~
35980 \InsetSpace ~
35981 \InsetSpace ~
35982 \InsetSpace ~
35983 \InsetSpace ~
35984 \InsetSpace ~
35985 \InsetSpace ~
35986 \InsetSpace ~
35987 \InsetSpace ~
35988 \InsetSpace ~
35989 \InsetSpace ~
35990 \InsetSpace ~
35991 \InsetSpace ~
35992 \InsetSpace ~
35993  76\InsetSpace ~
35994 \InsetSpace ~
35995 \InsetSpace ~
35996 \InsetSpace ~
35997 \InsetSpace ~
35998 \InsetSpace ~
35999 \InsetSpace ~
36000 \InsetSpace ~
36001  mov\InsetSpace ~
36002 \InsetSpace ~
36003  a,(_gint + 1) 
36004 \newline
36005 0024 13\InsetSpace ~
36006 \InsetSpace ~
36007 \InsetSpace ~
36008 \InsetSpace ~
36009 \InsetSpace ~
36010 \InsetSpace ~
36011 \InsetSpace ~
36012 \InsetSpace ~
36013 \InsetSpace ~
36014 \InsetSpace ~
36015 \InsetSpace ~
36016 \InsetSpace ~
36017 \InsetSpace ~
36018 \InsetSpace ~
36019 \InsetSpace ~
36020 \InsetSpace ~
36021 \InsetSpace ~
36022 \InsetSpace ~
36023  77\InsetSpace ~
36024 \InsetSpace ~
36025 \InsetSpace ~
36026 \InsetSpace ~
36027 \InsetSpace ~
36028 \InsetSpace ~
36029 \InsetSpace ~
36030 \InsetSpace ~
36031  rrc\InsetSpace ~
36032 \InsetSpace ~
36033  a 
36034 \newline
36035 0025 92*02\InsetSpace ~
36036 \InsetSpace ~
36037 \InsetSpace ~
36038 \InsetSpace ~
36039 \InsetSpace ~
36040 \InsetSpace ~
36041 \InsetSpace ~
36042 \InsetSpace ~
36043 \InsetSpace ~
36044 \InsetSpace ~
36045 \InsetSpace ~
36046 \InsetSpace ~
36047 \InsetSpace ~
36048 \InsetSpace ~
36049 \InsetSpace ~
36050
36051  78\InsetSpace ~
36052 \InsetSpace ~
36053 \InsetSpace ~
36054 \InsetSpace ~
36055 \InsetSpace ~
36056 \InsetSpace ~
36057 \InsetSpace ~
36058 \InsetSpace ~
36059  mov\InsetSpace ~
36060 \InsetSpace ~
36061  _foo_aob2_1_1,c 
36062 \newline
36063 \InsetSpace ~
36064 \InsetSpace ~
36065 \InsetSpace ~
36066 \InsetSpace ~
36067 \InsetSpace ~
36068 \InsetSpace ~
36069 \InsetSpace ~
36070 \InsetSpace ~
36071 \InsetSpace ~
36072 \InsetSpace ~
36073 \InsetSpace ~
36074 \InsetSpace ~
36075 \InsetSpace ~
36076 \InsetSpace ~
36077 \InsetSpace ~
36078 \InsetSpace ~
36079 \InsetSpace ~
36080 \InsetSpace ~
36081 \InsetSpace ~
36082 \InsetSpace ~
36083 \InsetSpace ~
36084 \InsetSpace ~
36085 \InsetSpace ~
36086 \InsetSpace ~
36087 \InsetSpace ~
36088  79 ;\InsetSpace ~
36089  hob.c 12 
36090 \newline
36091 0027 E5*01\InsetSpace ~
36092 \InsetSpace ~
36093 \InsetSpace ~
36094 \InsetSpace ~
36095 \InsetSpace ~
36096 \InsetSpace ~
36097 \InsetSpace ~
36098 \InsetSpace ~
36099 \InsetSpace ~
36100 \InsetSpace ~
36101 \InsetSpace ~
36102 \InsetSpace ~
36103 \InsetSpace ~
36104 \InsetSpace ~
36105 \InsetSpace ~
36106  80\InsetSpace ~
36107 \InsetSpace ~
36108 \InsetSpace ~
36109 \InsetSpace ~
36110 \InsetSpace ~
36111 \InsetSpace ~
36112 \InsetSpace ~
36113 \InsetSpace ~
36114  mov\InsetSpace ~
36115 \InsetSpace ~
36116  a,(_gint + 1) 
36117 \newline
36118 0029
36119  A2 E3\InsetSpace ~
36120 \InsetSpace ~
36121 \InsetSpace ~
36122 \InsetSpace ~
36123 \InsetSpace ~
36124 \InsetSpace ~
36125 \InsetSpace ~
36126 \InsetSpace ~
36127 \InsetSpace ~
36128 \InsetSpace ~
36129 \InsetSpace ~
36130 \InsetSpace ~
36131 \InsetSpace ~
36132 \InsetSpace ~
36133 \InsetSpace ~
36134  81\InsetSpace ~
36135 \InsetSpace ~
36136 \InsetSpace ~
36137 \InsetSpace ~
36138 \InsetSpace ~
36139 \InsetSpace ~
36140 \InsetSpace ~
36141 \InsetSpace ~
36142  mov\InsetSpace ~
36143 \InsetSpace ~
36144  c,acc[3] 
36145 \newline
36146 002B 92*03\InsetSpace ~
36147 \InsetSpace ~
36148 \InsetSpace ~
36149 \InsetSpace ~
36150 \InsetSpace ~
36151 \InsetSpace ~
36152 \InsetSpace ~
36153 \InsetSpace ~
36154 \InsetSpace ~
36155 \InsetSpace ~
36156 \InsetSpace ~
36157 \InsetSpace ~
36158 \InsetSpace ~
36159 \InsetSpace ~
36160 \InsetSpace ~
36161  82\InsetSpace ~
36162 \InsetSpace ~
36163 \InsetSpace ~
36164 \InsetSpace ~
36165 \InsetSpace ~
36166 \InsetSpace ~
36167 \InsetSpace ~
36168 \InsetSpace ~
36169  mov\InsetSpace ~
36170 \InsetSpace ~
36171  _foo_aob3_1_1,c 
36172 \end_layout
36173
36174 \begin_layout Standard
36175 Other variations of these cases however will 
36176 \emph on
36177 not
36178 \emph default
36179  be recognized.
36180  They are standard C expressions, so I heartily recommend these be the only
36181  way to get the highest order bit, (it is portable).
36182  Of course it will be recognized even if it is embedded in other expressions,
36183  e.g.:
36184 \end_layout
36185
36186 \begin_layout Verse
36187
36188 \family typewriter
36189 xyz = gint + ((gint >> 15) & 1);
36190 \end_layout
36191
36192 \begin_layout Standard
36193 will still be recognized.
36194 \end_layout
36195
36196 \begin_layout Subsection
36197 Higher Order Byte
36198 \begin_inset LatexCommand \index{Higher Order Byte}
36199
36200 \end_inset
36201
36202  / Higher Order Word
36203 \begin_inset LatexCommand \index{Higher Order Word}
36204
36205 \end_inset
36206
36207
36208 \end_layout
36209
36210 \begin_layout Standard
36211 It is also frequently required to obtain a higher order byte or word of
36212  a larger integral type (long, int or short types).
36213  SDCC recognizes the following expressions to yield the higher order byte
36214  or word and generates optimized code for it, e.g.:
36215 \end_layout
36216
36217 \begin_layout Verse
36218
36219 \family typewriter
36220 unsigned int gint; 
36221 \newline
36222 unsigned long int glong; 
36223 \newline
36224
36225 \newline
36226 foo () { 
36227 \newline
36228 \InsetSpace ~
36229 \InsetSpace ~
36230 unsigned char hob1,
36231  hob2; 
36232 \newline
36233 \InsetSpace ~
36234 \InsetSpace ~
36235 unsigned int how1, how2; 
36236 \newline
36237 \InsetSpace ~
36238 \InsetSpace ~
36239 ...
36240  
36241 \newline
36242 \InsetSpace ~
36243 \InsetSpace ~
36244 hob1 = (gint >> 8) & 0xFF; 
36245 \newline
36246 \InsetSpace ~
36247 \InsetSpace ~
36248 hob2 = glong >> 24; 
36249 \newline
36250 \InsetSpace ~
36251 \InsetSpace ~
36252 how1 = (glong >> 16) & 0xFFFF;
36253  
36254 \newline
36255 \InsetSpace ~
36256 \InsetSpace ~
36257 how2 = glong >> 8; 
36258 \newline
36259 \InsetSpace ~
36260 \InsetSpace ~
36261 ..
36262  
36263 \newline
36264 }
36265 \end_layout
36266
36267 \begin_layout Standard
36268 will generate the following code:
36269 \end_layout
36270
36271 \begin_layout Verse
36272
36273 \family typewriter
36274 \InsetSpace ~
36275 \InsetSpace ~
36276 \InsetSpace ~
36277 \InsetSpace ~
36278 \InsetSpace ~
36279 \InsetSpace ~
36280 \InsetSpace ~
36281 \InsetSpace ~
36282 \InsetSpace ~
36283 \InsetSpace ~
36284 \InsetSpace ~
36285 \InsetSpace ~
36286 \InsetSpace ~
36287 \InsetSpace ~
36288 \InsetSpace ~
36289 \InsetSpace ~
36290 \InsetSpace ~
36291 \InsetSpace ~
36292 \InsetSpace ~
36293 \InsetSpace ~
36294 \InsetSpace ~
36295 \InsetSpace ~
36296 \InsetSpace ~
36297 \InsetSpace ~
36298 \InsetSpace ~
36299  91 ;\InsetSpace ~
36300  hob.c 15 
36301 \newline
36302 0037 85*01*06\InsetSpace ~
36303 \InsetSpace ~
36304 \InsetSpace ~
36305 \InsetSpace ~
36306 \InsetSpace ~
36307 \InsetSpace ~
36308 \InsetSpace ~
36309 \InsetSpace ~
36310 \InsetSpace ~
36311 \InsetSpace ~
36312 \InsetSpace ~
36313 \InsetSpace ~
36314  92\InsetSpace ~
36315 \InsetSpace ~
36316 \InsetSpace ~
36317 \InsetSpace ~
36318 \InsetSpace ~
36319 \InsetSpace ~
36320 \InsetSpace ~
36321 \InsetSpace ~
36322  mov\InsetSpace ~
36323 \InsetSpace ~
36324  _foo_hob1_1_1,(_gint + 1) 
36325 \newline
36326 \InsetSpace ~
36327 \InsetSpace ~
36328 \InsetSpace ~
36329 \InsetSpace ~
36330 \InsetSpace ~
36331 \InsetSpace ~
36332 \InsetSpace ~
36333 \InsetSpace ~
36334 \InsetSpace ~
36335 \InsetSpace ~
36336 \InsetSpace ~
36337 \InsetSpace ~
36338 \InsetSpace ~
36339 \InsetSpace ~
36340 \InsetSpace ~
36341 \InsetSpace ~
36342 \InsetSpace ~
36343 \InsetSpace ~
36344 \InsetSpace ~
36345 \InsetSpace ~
36346 \InsetSpace ~
36347 \InsetSpace ~
36348 \InsetSpace ~
36349 \InsetSpace ~
36350 \InsetSpace ~
36351  93 ;\InsetSpace ~
36352  hob.c
36353  16 
36354 \newline
36355 003A 85*05*07\InsetSpace ~
36356 \InsetSpace ~
36357 \InsetSpace ~
36358 \InsetSpace ~
36359 \InsetSpace ~
36360 \InsetSpace ~
36361 \InsetSpace ~
36362 \InsetSpace ~
36363 \InsetSpace ~
36364 \InsetSpace ~
36365 \InsetSpace ~
36366 \InsetSpace ~
36367  94\InsetSpace ~
36368 \InsetSpace ~
36369 \InsetSpace ~
36370 \InsetSpace ~
36371 \InsetSpace ~
36372 \InsetSpace ~
36373 \InsetSpace ~
36374 \InsetSpace ~
36375  mov\InsetSpace ~
36376 \InsetSpace ~
36377  _foo_hob2_1_1,(_glong + 3) 
36378 \newline
36379 \InsetSpace ~
36380 \InsetSpace ~
36381 \InsetSpace ~
36382 \InsetSpace ~
36383 \InsetSpace ~
36384 \InsetSpace ~
36385 \InsetSpace ~
36386 \InsetSpace ~
36387 \InsetSpace ~
36388 \InsetSpace ~
36389 \InsetSpace ~
36390 \InsetSpace ~
36391 \InsetSpace ~
36392 \InsetSpace ~
36393 \InsetSpace ~
36394 \InsetSpace ~
36395 \InsetSpace ~
36396 \InsetSpace ~
36397 \InsetSpace ~
36398 \InsetSpace ~
36399 \InsetSpace ~
36400 \InsetSpace ~
36401 \InsetSpace ~
36402 \InsetSpace ~
36403 \InsetSpace ~
36404  95 ;\InsetSpace ~
36405  hob.c 17 
36406 \newline
36407 003D 85*04*08\InsetSpace ~
36408 \InsetSpace ~
36409 \InsetSpace ~
36410 \InsetSpace ~
36411 \InsetSpace ~
36412 \InsetSpace ~
36413 \InsetSpace ~
36414 \InsetSpace ~
36415 \InsetSpace ~
36416 \InsetSpace ~
36417 \InsetSpace ~
36418 \InsetSpace ~
36419
36420  96\InsetSpace ~
36421 \InsetSpace ~
36422 \InsetSpace ~
36423 \InsetSpace ~
36424 \InsetSpace ~
36425 \InsetSpace ~
36426 \InsetSpace ~
36427 \InsetSpace ~
36428  mov\InsetSpace ~
36429 \InsetSpace ~
36430  _foo_how1_1_1,(_glong + 2) 
36431 \newline
36432 0040 85*05*09\InsetSpace ~
36433 \InsetSpace ~
36434 \InsetSpace ~
36435 \InsetSpace ~
36436 \InsetSpace ~
36437 \InsetSpace ~
36438 \InsetSpace ~
36439 \InsetSpace ~
36440 \InsetSpace ~
36441 \InsetSpace ~
36442 \InsetSpace ~
36443 \InsetSpace ~
36444  97\InsetSpace ~
36445 \InsetSpace ~
36446 \InsetSpace ~
36447 \InsetSpace ~
36448 \InsetSpace ~
36449 \InsetSpace ~
36450 \InsetSpace ~
36451 \InsetSpace ~
36452  mov\InsetSpace ~
36453 \InsetSpace ~
36454  (_foo_how1_1_1 +
36455  1),(_glong + 3) 
36456 \newline
36457 0043 85*03*0A\InsetSpace ~
36458 \InsetSpace ~
36459 \InsetSpace ~
36460 \InsetSpace ~
36461 \InsetSpace ~
36462 \InsetSpace ~
36463 \InsetSpace ~
36464 \InsetSpace ~
36465 \InsetSpace ~
36466 \InsetSpace ~
36467 \InsetSpace ~
36468 \InsetSpace ~
36469  98\InsetSpace ~
36470 \InsetSpace ~
36471 \InsetSpace ~
36472 \InsetSpace ~
36473 \InsetSpace ~
36474 \InsetSpace ~
36475 \InsetSpace ~
36476 \InsetSpace ~
36477  mov\InsetSpace ~
36478 \InsetSpace ~
36479  _foo_how2_1_1,(_glong + 1) 
36480 \newline
36481 0046 85*04*0B\InsetSpace ~
36482 \InsetSpace ~
36483 \InsetSpace ~
36484 \InsetSpace ~
36485 \InsetSpace ~
36486 \InsetSpace ~
36487 \InsetSpace ~
36488 \InsetSpace ~
36489 \InsetSpace ~
36490 \InsetSpace ~
36491 \InsetSpace ~
36492 \InsetSpace ~
36493
36494  99\InsetSpace ~
36495 \InsetSpace ~
36496 \InsetSpace ~
36497 \InsetSpace ~
36498 \InsetSpace ~
36499 \InsetSpace ~
36500 \InsetSpace ~
36501 \InsetSpace ~
36502  mov\InsetSpace ~
36503 \InsetSpace ~
36504  (_foo_how2_1_1 + 1),(_glong + 2) 
36505 \end_layout
36506
36507 \begin_layout Standard
36508 Again, variations of these cases may 
36509 \emph on
36510 not
36511 \emph default
36512  be recognized.
36513  They are standard C expressions, so I heartily recommend these be the only
36514  way to get the higher order byte/word, (it is portable).
36515  Of course it will be recognized even if it is embedded in other expressions,
36516  e.g.:
36517 \end_layout
36518
36519 \begin_layout Verse
36520
36521 \family typewriter
36522 xyz = gint + ((gint >> 8) & 0xFF);
36523 \end_layout
36524
36525 \begin_layout Standard
36526 will still be recognized.
36527 \end_layout
36528
36529 \begin_layout Subsection
36530 Peephole Optimizer
36531 \begin_inset LatexCommand \label{sub:Peephole-Optimizer}
36532
36533 \end_inset
36534
36535
36536 \begin_inset LatexCommand \index{Peephole optimizer}
36537
36538 \end_inset
36539
36540
36541 \end_layout
36542
36543 \begin_layout Standard
36544 The compiler uses a rule based, pattern matching and re-writing mechanism
36545  for peep-hole optimization.
36546  It is inspired by 
36547 \emph on
36548 copt
36549 \emph default
36550  a peep-hole optimizer by Christopher W.
36551  Fraser (cwfraser\InsetSpace ~
36552 @\InsetSpace ~
36553 microsoft.com).
36554  A default set of rules are compiled into the compiler, additional rules
36555  may be added with the 
36556 \emph on
36557 -
36558 \begin_inset ERT
36559 status collapsed
36560
36561 \begin_layout Standard
36562
36563
36564 \backslash
36565 /
36566 \end_layout
36567
36568 \end_inset
36569
36570 -peep-file
36571 \begin_inset LatexCommand \index{-\/-peep-file}
36572
36573 \end_inset
36574
36575  <filename>
36576 \emph default
36577  option.
36578  The rule language is best illustrated with examples.
36579 \end_layout
36580
36581 \begin_layout Verse
36582
36583 \family typewriter
36584 replace { 
36585 \newline
36586 \InsetSpace ~
36587 \InsetSpace ~
36588 mov %1,a 
36589 \newline
36590 \InsetSpace ~
36591 \InsetSpace ~
36592 mov a,%1
36593 \newline
36594 } by {
36595 \newline
36596 \InsetSpace ~
36597 \InsetSpace ~
36598 mov %1,a
36599 \newline
36600 }
36601 \end_layout
36602
36603 \begin_layout Standard
36604 The above rule will change the following assembly
36605 \begin_inset LatexCommand \index{Assembler routines}
36606
36607 \end_inset
36608
36609  sequence:
36610 \end_layout
36611
36612 \begin_layout Verse
36613
36614 \family typewriter
36615 mov r1,a 
36616 \newline
36617 mov a,r1
36618 \end_layout
36619
36620 \begin_layout Standard
36621 to
36622 \end_layout
36623
36624 \begin_layout Verse
36625
36626 \family typewriter
36627 mov r1,a
36628 \end_layout
36629
36630 \begin_layout Standard
36631 Note: All occurrences of a 
36632 \emph on
36633 %n
36634 \emph default
36635  (pattern variable) must denote the same string.
36636  With the above rule, the assembly sequence:
36637 \end_layout
36638
36639 \begin_layout Verse
36640
36641 \family typewriter
36642 mov r1,a 
36643 \newline
36644 mov a,r2
36645 \end_layout
36646
36647 \begin_layout Standard
36648 will remain unmodified.
36649 \newline
36650
36651 \newline
36652 Other special case optimizations may be added by the
36653  user (via 
36654 \emph on
36655 -
36656 \begin_inset ERT
36657 status collapsed
36658
36659 \begin_layout Standard
36660
36661
36662 \backslash
36663 /
36664 \end_layout
36665
36666 \end_inset
36667
36668 -peep-file option
36669 \emph default
36670 ).
36671  E.g.
36672  some variants of the 8051 MCU
36673 \begin_inset LatexCommand \index{MCS51 variants}
36674
36675 \end_inset
36676
36677  allow only 
36678 \family typewriter
36679 ajmp
36680 \family default
36681  and 
36682 \family typewriter
36683 acall
36684 \family default
36685 .
36686  The following two rules will change all 
36687 \family typewriter
36688 ljmp
36689 \family default
36690  and 
36691 \family typewriter
36692 lcall
36693 \family default
36694  to 
36695 \family typewriter
36696 ajmp
36697 \family default
36698  and 
36699 \family typewriter
36700 acall
36701 \end_layout
36702
36703 \begin_layout Verse
36704
36705 \family typewriter
36706 replace { lcall %1 } by { acall %1 } 
36707 \newline
36708 replace { ljmp %1 } by { ajmp %1 }
36709 \end_layout
36710
36711 \begin_layout Standard
36712 (NOTE: from version 2.7.3 on, you can use option -
36713 \emph on
36714
36715 \begin_inset ERT
36716 status collapsed
36717
36718 \begin_layout Standard
36719
36720
36721 \backslash
36722 /
36723 \end_layout
36724
36725 \end_inset
36726
36727
36728 \emph default
36729 -acall-ajmp
36730 \begin_inset LatexCommand \index{-\/-acall-ajmp}
36731
36732 \end_inset
36733
36734 , which also takes care of aligning the interrupt vectors properly.)
36735 \newline
36736
36737 \end_layout
36738
36739 \begin_layout Standard
36740 The 
36741 \emph on
36742 inline-assembler code
36743 \emph default
36744  is also passed through the peep hole optimizer, thus the peephole optimizer
36745  can also be used as an assembly level macro expander.
36746  The rules themselves are MCU dependent whereas the rule language infra-structur
36747 e is MCU independent.
36748  Peephole optimization rules for other MCU can be easily programmed using
36749  the rule language.
36750 \newline
36751
36752 \newline
36753 The syntax for a rule is as follows:
36754 \end_layout
36755
36756 \begin_layout Verse
36757
36758 \family typewriter
36759 rule := replace [ restart ] '{' <assembly sequence> '
36760 \backslash
36761 n' 
36762 \newline
36763 \InsetSpace ~
36764  \InsetSpace ~
36765  \InsetSpace ~
36766  \InsetSpace ~
36767  \InsetSpace ~
36768  \InsetSpace ~
36769  \InsetSpace ~
36770  \InsetSpace ~
36771  \InsetSpace ~
36772  \InsetSpace ~
36773  \InsetSpace ~
36774  \InsetSpace ~
36775  \InsetSpace ~
36776  \InsetSpace ~
36777  '}' by '{' '
36778 \backslash
36779 n' 
36780 \newline
36781 \InsetSpace ~
36782  \InsetSpace ~
36783  \InsetSpace ~
36784  \InsetSpace ~
36785  \InsetSpace ~
36786  \InsetSpace ~
36787  \InsetSpace ~
36788  \InsetSpace ~
36789  \InsetSpace ~
36790  \InsetSpace ~
36791  \InsetSpace ~
36792  \InsetSpace ~
36793  \InsetSpace ~
36794  \InsetSpace ~
36795  \InsetSpace ~
36796  \InsetSpace ~
36797  <assembly sequence> '
36798 \backslash
36799 n' 
36800 \newline
36801 \InsetSpace ~
36802  \InsetSpace ~
36803  \InsetSpace ~
36804  \InsetSpace ~
36805  \InsetSpace ~
36806  \InsetSpace ~
36807  \InsetSpace ~
36808  \InsetSpace ~
36809  \InsetSpace ~
36810  \InsetSpace ~
36811  \InsetSpace ~
36812  \InsetSpace ~
36813  \InsetSpace ~
36814  \InsetSpace ~
36815  '}' [if <functionName> ] '
36816 \backslash
36817 n' 
36818 \end_layout
36819
36820 \begin_layout Standard
36821 <assembly sequence> := assembly instruction (each instruction including
36822  labels must be on a separate line).
36823 \newline
36824
36825 \newline
36826 The optimizer will apply to the rules
36827  one by one from the top in the sequence of their appearance, it will terminate
36828  when all rules are exhausted.
36829  If the 'restart' option is specified, then the optimizer will start matching
36830  the rules again from the top, this option for a rule is expensive (performance)
36831 , it is intended to be used in situations where a transformation will trigger
36832  the same rule again.
36833  An example of this (not a good one, it has side effects) is the following
36834  rule:
36835 \end_layout
36836
36837 \begin_layout Verse
36838
36839 \family typewriter
36840 replace restart { 
36841 \newline
36842 \InsetSpace ~
36843 \InsetSpace ~
36844 pop %1 
36845 \newline
36846 \InsetSpace ~
36847 \InsetSpace ~
36848 push %1 } by { 
36849 \newline
36850 \InsetSpace ~
36851 \InsetSpace ~
36852 ; nop 
36853 \newline
36854 }
36855 \end_layout
36856
36857 \begin_layout Standard
36858 Note that the replace pattern cannot be a blank, but can be a comment line.
36859  Without the 'restart' option only the innermost 'pop' 'push' pair would
36860  be eliminated, i.e.:
36861 \end_layout
36862
36863 \begin_layout Verse
36864
36865 \family typewriter
36866 pop ar1 
36867 \newline
36868 pop ar2 
36869 \newline
36870 push ar2 
36871 \newline
36872 push ar1
36873 \end_layout
36874
36875 \begin_layout Standard
36876 would result in:
36877 \end_layout
36878
36879 \begin_layout Verse
36880
36881 \family typewriter
36882 pop ar1 
36883 \newline
36884 ; nop 
36885 \newline
36886 push ar1
36887 \end_layout
36888
36889 \begin_layout Standard
36890
36891 \emph on
36892 with
36893 \emph default
36894  the restart option the rule will be applied again to the resulting code
36895  and then all the pop-push pairs will be eliminated to yield:
36896 \end_layout
36897
36898 \begin_layout Verse
36899
36900 \family typewriter
36901 ; nop 
36902 \newline
36903 ; nop
36904 \end_layout
36905
36906 \begin_layout Standard
36907 A conditional function can be attached to a rule.
36908  Attaching rules are somewhat more involved, let me illustrate this with
36909  an example.
36910 \end_layout
36911
36912 \begin_layout Verse
36913
36914 \family typewriter
36915 replace { 
36916 \newline
36917 \InsetSpace ~
36918  \InsetSpace ~
36919  \InsetSpace ~
36920 ljmp %5 
36921 \newline
36922 %2:
36923 \newline
36924 } by { 
36925 \newline
36926 \InsetSpace ~
36927  \InsetSpace ~
36928  \InsetSpace ~
36929 sjmp %5 
36930 \newline
36931 %2:
36932 \newline
36933 } if labelInRange
36934 \end_layout
36935
36936 \begin_layout Standard
36937 The optimizer does a look-up of a function name table defined in function
36938  
36939 \emph on
36940 callFuncByName
36941 \emph default
36942  in the source file SDCCpeeph.c, with the name 
36943 \emph on
36944 labelInRange
36945 \emph default
36946 .
36947  If it finds a corresponding entry the function is called.
36948  Note there can be no parameters specified for these functions, in this
36949  case the use of 
36950 \emph on
36951 %5
36952 \emph default
36953  is crucial, since the function 
36954 \emph on
36955 labelInRange
36956 \emph default
36957  expects to find the label in that particular variable (the hash table containin
36958 g the variable bindings is passed as a parameter).
36959  If you want to code more such functions, take a close look at the function
36960  labelInRange and the calling mechanism in source file SDCCpeeph.c.
36961  Currently implemented are 
36962 \emph on
36963 labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
36964  24bitMode, portIsDS390, 24bitModeAndPortDS390 
36965 \emph default
36966 and
36967 \emph on
36968  notVolatile
36969 \emph default
36970 .
36971 \end_layout
36972
36973 \begin_layout Standard
36974 I know this whole thing is a little kludgey, but maybe some day we will
36975  have some better means.
36976  If you are looking at this file, you will see the default rules that are
36977  compiled into the compiler, you can add your own rules in the default set
36978  there if you get tired of specifying the -
36979 \begin_inset ERT
36980 status collapsed
36981
36982 \begin_layout Standard
36983
36984
36985 \backslash
36986 /
36987 \end_layout
36988
36989 \end_inset
36990
36991 -peep-file option.
36992 \end_layout
36993
36994 \begin_layout Section
36995 ANSI-Compliance
36996 \begin_inset LatexCommand \index{ANSI-compliance}
36997
36998 \end_inset
36999
37000
37001 \begin_inset LatexCommand \label{sub:ANSI-Compliance}
37002
37003 \end_inset
37004
37005
37006 \end_layout
37007
37008 \begin_layout Standard
37009 The latest publically available version of the standard 
37010 \emph on
37011 ISO/IEC 9899 - Programming languages - C
37012 \emph default
37013  should be available at: 
37014 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
37015
37016 \end_inset
37017
37018 .
37019 \newline
37020
37021 \end_layout
37022
37023 \begin_layout Standard
37024 Deviations from the compliance:
37025 \end_layout
37026
37027 \begin_layout Itemize
37028 functions are not reentrant
37029 \begin_inset LatexCommand \index{reentrant}
37030
37031 \end_inset
37032
37033  unless explicitly declared as such or the 
37034 \series bold
37035 -
37036 \begin_inset ERT
37037 status collapsed
37038
37039 \begin_layout Standard
37040
37041
37042 \backslash
37043 /
37044 \end_layout
37045
37046 \end_inset
37047
37048 -stack-auto
37049 \begin_inset LatexCommand \index{-\/-stack-auto}
37050
37051 \end_inset
37052
37053
37054 \series default
37055  command line option is specified.
37056 \end_layout
37057
37058 \begin_layout Itemize
37059 structures
37060 \begin_inset LatexCommand \index{struct}
37061
37062 \end_inset
37063
37064  and unions
37065 \begin_inset LatexCommand \index{union}
37066
37067 \end_inset
37068
37069  cannot be assigned values directly, cannot be passed as function parameters
37070  or assigned to each other and cannot be a return value
37071 \begin_inset LatexCommand \index{return value}
37072
37073 \end_inset
37074
37075  from a function, e.g.:
37076 \end_layout
37077
37078 \begin_deeper
37079 \begin_layout Verse
37080
37081 \family typewriter
37082 struct s { ...
37083  }; 
37084 \newline
37085 struct s s1, s2; 
37086 \newline
37087 foo() 
37088 \newline
37089
37090 \newline
37091 \InsetSpace ~
37092 \InsetSpace ~
37093 \InsetSpace ~
37094 \InsetSpace ~
37095 ...
37096  
37097 \newline
37098 \InsetSpace ~
37099 \InsetSpace ~
37100 \InsetSpace ~
37101 \InsetSpace ~
37102 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
37103 \newline
37104 \InsetSpace ~
37105 \InsetSpace ~
37106 \InsetSpace ~
37107 \InsetSpace ~
37108 ...
37109  
37110 \newline
37111 }
37112 \newline
37113
37114 \series bold
37115 struct
37116 \series default
37117  s foo1 (
37118 \series bold
37119 struct
37120 \series default
37121  s parms) /* invalid in SDCC although allowed in ANSI */
37122 \newline
37123
37124 \newline
37125 \InsetSpace ~
37126 \InsetSpace ~
37127 \InsetSpace ~
37128 \InsetSpace ~
37129 struct s rets;
37130  
37131 \newline
37132 \InsetSpace ~
37133 \InsetSpace ~
37134 \InsetSpace ~
37135 \InsetSpace ~
37136 ...
37137  
37138 \newline
37139 \InsetSpace ~
37140 \InsetSpace ~
37141 \InsetSpace ~
37142 \InsetSpace ~
37143 return rets; /* is invalid in SDCC although allowed in ANSI */ 
37144 \newline
37145 }
37146 \end_layout
37147
37148 \end_deeper
37149 \begin_layout Itemize
37150 initialization of structure arrays must be fully braced.
37151 \end_layout
37152
37153 \begin_deeper
37154 \begin_layout Verse
37155
37156 \family typewriter
37157 struct s { char x } a[] = {1, 2};\InsetSpace ~
37158 \InsetSpace ~
37159 \InsetSpace ~
37160 \InsetSpace ~
37161 \InsetSpace ~
37162 /* invalid in SDCC */
37163 \newline
37164 struct s { char x
37165  } a[] = {{1}, {2}}; /* OK */
37166 \end_layout
37167
37168 \end_deeper
37169 \begin_layout Itemize
37170 'long long
37171 \begin_inset LatexCommand \index{long long (not supported)}
37172
37173 \end_inset
37174
37175 ' (64 bit integers
37176 \begin_inset LatexCommand \index{int (64 bit) (not supported)}
37177
37178 \end_inset
37179
37180 ) not supported.
37181 \end_layout
37182
37183 \begin_layout Itemize
37184 'double
37185 \begin_inset LatexCommand \index{double (not supported)}
37186
37187 \end_inset
37188
37189 ' precision floating point 
37190 \begin_inset LatexCommand \index{Floating point support}
37191
37192 \end_inset
37193
37194 not supported.
37195 \end_layout
37196
37197 \begin_layout Itemize
37198 Old K&R style
37199 \begin_inset LatexCommand \index{K\&R style}
37200
37201 \end_inset
37202
37203  function declarations are NOT allowed.
37204 \end_layout
37205
37206 \begin_deeper
37207 \begin_layout Verse
37208
37209 \family typewriter
37210 foo(i,j) /* this old style of function declarations */ 
37211 \newline
37212 int i,j; /* is valid
37213  in ANSI but not valid in SDCC */ 
37214 \newline
37215
37216 \newline
37217 \InsetSpace ~
37218 \InsetSpace ~
37219 \InsetSpace ~
37220 \InsetSpace ~
37221 ...
37222  
37223 \newline
37224 }
37225 \end_layout
37226
37227 \end_deeper
37228 \begin_layout Itemize
37229 Most enhancements in C99 are not supported, e.g.:
37230 \end_layout
37231
37232 \begin_deeper
37233 \begin_layout Verse
37234
37235 \family typewriter
37236 for (
37237 \series bold
37238 int
37239 \series default
37240  i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
37241 \end_layout
37242
37243 \end_deeper
37244 \begin_layout Itemize
37245 But some have been added recently in SDCC 2.7.0.
37246  They must be considered alpha quality however.
37247 \end_layout
37248
37249 \begin_deeper
37250 \begin_layout Verse
37251
37252 \family typewriter
37253 \series bold
37254 inline
37255 \begin_inset LatexCommand \index{inline (not supported)}
37256
37257 \end_inset
37258
37259
37260 \series default
37261  int increment (int a) { return a+1; } /* inlines the increment without
37262  function call overhead */
37263 \newline
37264 int * 
37265 \series bold
37266 restrict
37267 \begin_inset LatexCommand \index{inline (not supported)}
37268
37269 \end_inset
37270
37271
37272 \series default
37273  p; /* accepted but ignored */
37274 \end_layout
37275
37276 \end_deeper
37277 \begin_layout Itemize
37278 Certain words that are valid identifiers in the standard may be reserved
37279  words in SDCC unless the 
37280 \series bold
37281 -
37282 \begin_inset ERT
37283 status collapsed
37284
37285 \begin_layout Standard
37286
37287
37288 \backslash
37289 /
37290 \end_layout
37291
37292 \end_inset
37293
37294 -std-c89
37295 \begin_inset LatexCommand \index{-\/-std-c89}
37296
37297 \end_inset
37298
37299  
37300 \series default
37301 or
37302 \series bold
37303  -
37304 \begin_inset ERT
37305 status collapsed
37306
37307 \begin_layout Standard
37308
37309
37310 \backslash
37311 /
37312 \end_layout
37313
37314 \end_inset
37315
37316 -std-c99
37317 \begin_inset LatexCommand \index{-\/-std-c99}
37318
37319 \end_inset
37320
37321
37322 \series default
37323  command line options are used.
37324  These may include (depending on the selected processor): 'at', 'banked',
37325  'bit', 'code', 'critical', 'data', 'eeprom', 'far', 'flash', 'idata', 'interrup
37326 t', 'near', 'nonbanked', 'pdata', 'reentrant', 'sbit', 'sfr', 'shadowregs',
37327  'sram', 'using', 'wparam', 'xdata', '_overlay', '_asm', '_endasm', and
37328  '_naked'.
37329  Compliant equivalents of these keywords are always available in a form
37330  that begin with two underscores
37331 \begin_inset LatexCommand \index{\_\_ (prefix for extended keywords)}
37332
37333 \end_inset
37334
37335 , f.e.
37336  '__data' instead of 'data'.
37337 \end_layout
37338
37339 \begin_layout Itemize
37340 Integer promotion of variable arguments is not performed if the argument
37341  is explicitly taypecasted unless the
37342 \series bold
37343  -
37344 \begin_inset ERT
37345 status collapsed
37346
37347 \begin_layout Standard
37348
37349
37350 \backslash
37351 /
37352 \end_layout
37353
37354 \end_inset
37355
37356 -std-c89
37357 \begin_inset LatexCommand \index{-\/-std-c89}
37358
37359 \end_inset
37360
37361  
37362 \series default
37363 or
37364 \series bold
37365  -
37366 \begin_inset ERT
37367 status collapsed
37368
37369 \begin_layout Standard
37370
37371
37372 \backslash
37373 /
37374 \end_layout
37375
37376 \end_inset
37377
37378 -std-c99
37379 \begin_inset LatexCommand \index{-\/-std-c99}
37380
37381 \end_inset
37382
37383
37384 \series default
37385  command line options are used.
37386 \end_layout
37387
37388 \begin_deeper
37389 \begin_layout Verse
37390
37391 \family typewriter
37392 void vararg_func (char *str, ...) { str; }
37393 \newline
37394
37395 \newline
37396 void main (void)
37397 \newline
37398 {
37399 \newline
37400 \InsetSpace ~
37401 \InsetSpace ~
37402 char c = 10;
37403 \newline
37404
37405 \newline
37406 \InsetSpace ~
37407 \InsetSpace ~
37408 /* argument
37409  u is promoted to int before
37410 \newline
37411 \InsetSpace ~
37412 \InsetSpace ~
37413 \InsetSpace ~
37414 * passing to function */
37415 \newline
37416 \InsetSpace ~
37417 \InsetSpace ~
37418 vararg_func ("%c", c);
37419 \newline
37420
37421 \newline
37422 \InsetSpace ~
37423 \InsetSpace ~
37424 /*
37425  argument u is not promoted to int,
37426 \newline
37427 \InsetSpace ~
37428 \InsetSpace ~
37429 \InsetSpace ~
37430 * it is passed as char to function
37431 \newline
37432 \InsetSpace ~
37433 \InsetSpace ~
37434 \InsetSpace ~
37435 * if
37436  --std-cXX is not defined;
37437 \newline
37438 \InsetSpace ~
37439 \InsetSpace ~
37440 \InsetSpace ~
37441 * is promoted to int before passing
37442 \newline
37443 \InsetSpace ~
37444 \InsetSpace ~
37445 \InsetSpace ~
37446 * to function
37447  if --std-cXX is defined */
37448 \newline
37449 \InsetSpace ~
37450 \InsetSpace ~
37451 vararg_func ("%bc", (char)u);
37452 \newline
37453 }
37454 \end_layout
37455
37456 \end_deeper
37457 \begin_layout Section
37458 Cyclomatic Complexity
37459 \begin_inset LatexCommand \index{Cyclomatic complexity}
37460
37461 \end_inset
37462
37463
37464 \end_layout
37465
37466 \begin_layout Standard
37467 Cyclomatic complexity of a function is defined as the number of independent
37468  paths the program can take during execution of the function.
37469  This is an important number since it defines the number test cases you
37470  have to generate to validate the function.
37471  The accepted industry standard for complexity number is 10, if the cyclomatic
37472  complexity reported by SDCC exceeds 10 you should think about simplification
37473  of the function logic.
37474  Note that the complexity level is not related to the number of lines of
37475  code in a function.
37476  Large functions can have low complexity, and small functions can have large
37477  complexity levels.
37478  
37479 \newline
37480
37481 \newline
37482 SDCC uses the following formula to compute the complexity:
37483 \newline
37484
37485 \end_layout
37486
37487 \begin_layout Standard
37488 complexity = (number of edges in control flow graph) - (number of nodes
37489  in control flow graph) + 2;
37490 \newline
37491
37492 \newline
37493 Having said that the industry standard is 10,
37494  you should be aware that in some cases it be may unavoidable to have a
37495  complexity level of less than 10.
37496  For example if you have switch statement with more than 10 case labels,
37497  each case label adds one to the complexity level.
37498  The complexity level is by no means an absolute measure of the algorithmic
37499  complexity of the function, it does however provide a good starting point
37500  for which functions you might look at for further optimization.
37501 \end_layout
37502
37503 \begin_layout Section
37504 Retargetting for other Processors
37505 \end_layout
37506
37507 \begin_layout Standard
37508 The issues for retargetting the compiler are far too numerous to be covered
37509  by this document.
37510  What follows is a brief description of each of the seven phases of the
37511  compiler and its MCU dependency.
37512 \end_layout
37513
37514 \begin_layout Itemize
37515 Parsing the source and building the annotated parse tree.
37516  This phase is largely MCU independent (except for the language extensions).
37517  Syntax & semantic checks are also done in this phase, along with some initial
37518  optimizations like back patching labels and the pattern matching optimizations
37519  like bit-rotation etc.
37520 \end_layout
37521
37522 \begin_layout Itemize
37523 The second phase involves generating an intermediate code which can be easy
37524  manipulated during the later phases.
37525  This phase is entirely MCU independent.
37526  The intermediate code generation assumes the target machine has unlimited
37527  number of registers, and designates them with the name iTemp.
37528  The compiler can be made to dump a human readable form of the code generated
37529  by using the -
37530 \begin_inset ERT
37531 status collapsed
37532
37533 \begin_layout Standard
37534
37535
37536 \backslash
37537 /
37538 \end_layout
37539
37540 \end_inset
37541
37542 -dumpraw option.
37543 \end_layout
37544
37545 \begin_layout Itemize
37546 This phase does the bulk of the standard optimizations and is also MCU independe
37547 nt.
37548  This phase can be broken down into several sub-phases:
37549 \newline
37550
37551 \newline
37552 Break down intermediate
37553  code (iCode) into basic blocks.
37554 \newline
37555 Do control flow & data flow analysis on the
37556  basic blocks.
37557 \newline
37558 Do local common subexpression elimination, then global subexpressio
37559 n elimination
37560 \newline
37561 Dead code elimination
37562 \newline
37563 Loop optimizations
37564 \newline
37565 If loop optimizations
37566  caused any changes then do 'global subexpression elimination' and 'dead
37567  code elimination' again.
37568 \end_layout
37569
37570 \begin_layout Itemize
37571 This phase determines the live-ranges; by live range I mean those iTemp
37572  variables defined by the compiler that still survive after all the optimization
37573 s.
37574  Live range analysis
37575 \begin_inset LatexCommand \index{Live range analysis}
37576
37577 \end_inset
37578
37579  is essential for register allocation, since these computation determines
37580  which of these iTemps will be assigned to registers, and for how long.
37581 \end_layout
37582
37583 \begin_layout Itemize
37584 Phase five is register allocation.
37585  There are two parts to this process.
37586 \newline
37587
37588 \newline
37589 The first part I call 'register packing'
37590  (for lack of a better term).
37591  In this case several MCU specific expression folding is done to reduce
37592  register pressure.
37593 \newline
37594
37595 \newline
37596 The second part is more MCU independent and deals with
37597  allocating registers to the remaining live ranges.
37598  A lot of MCU specific code does creep into this phase because of the limited
37599  number of index registers available in the 8051.
37600 \end_layout
37601
37602 \begin_layout Itemize
37603 The Code generation phase is (unhappily), entirely MCU dependent and very
37604  little (if any at all) of this code can be reused for other MCU.
37605  However the scheme for allocating a homogenized assembler operand for each
37606  iCode operand may be reused.
37607 \end_layout
37608
37609 \begin_layout Itemize
37610 As mentioned in the optimization section the peep-hole optimizer is rule
37611  based system, which can reprogrammed for other MCUs.
37612 \end_layout
37613
37614 \begin_layout Standard
37615 More information is available on SDCC Wiki
37616 \begin_inset LatexCommand \index{wiki}
37617
37618 \end_inset
37619
37620  (preliminary link 
37621 \begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/SDCC+internals+and+porting}
37622
37623 \end_inset
37624
37625 ) and in the thread 
37626 \begin_inset LatexCommand \url{http://sf.net/mailarchive/message.php?msg_id=13954144}
37627
37628 \end_inset
37629
37630  .
37631 \end_layout
37632
37633 \begin_layout Chapter
37634 Compiler internals
37635 \begin_inset LatexCommand \index{Compiler internals}
37636
37637 \end_inset
37638
37639
37640 \end_layout
37641
37642 \begin_layout Section
37643 The anatomy of the compiler
37644 \begin_inset LatexCommand \label{sub:The-anatomy-of}
37645
37646 \end_inset
37647
37648
37649 \end_layout
37650
37651 \begin_layout Standard
37652
37653 \shape italic
37654 This is an excerpt from an article published in Circuit Cellar Magazine
37655  in 
37656 \series bold
37657 August 2000
37658 \series default
37659 .
37660  It's a little outdated (the compiler is much more efficient now and user/develo
37661 per friendly), but pretty well exposes the guts of it all.
37662 \shape default
37663
37664 \newline
37665
37666 \newline
37667 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
37668  It is fairly easy to retarget for other 8-bit MCU.
37669  Here we take a look at some of the internals of the compiler.
37670  
37671 \end_layout
37672
37673 \begin_layout Paragraph*
37674 Parsing
37675 \begin_inset LatexCommand \index{Parsing}
37676
37677 \end_inset
37678
37679  
37680 \end_layout
37681
37682 \begin_layout Standard
37683 Parsing the input source file and creating an AST (Annotated Syntax Tree
37684 \begin_inset LatexCommand \index{Annotated syntax tree}
37685
37686 \end_inset
37687
37688 ).
37689  This phase also involves propagating types (annotating each node of the
37690  parse tree with type information) and semantic analysis.
37691  There are some MCU specific parsing rules.
37692  For example the storage classes, the extended storage classes are MCU specific
37693  while there may be a xdata storage class for 8051 there is no such storage
37694  class for z80 or Atmel AVR.
37695  SDCC allows MCU specific storage class extensions, i.e.
37696  xdata will be treated as a storage class specifier when parsing 8051 C
37697  code but will be treated as a C identifier when parsing z80 or ATMEL AVR
37698  C code.
37699 \end_layout
37700
37701 \begin_layout Paragraph*
37702 Generating iCode
37703 \begin_inset LatexCommand \index{iCode}
37704
37705 \end_inset
37706
37707
37708 \end_layout
37709
37710 \begin_layout Standard
37711 Intermediate code generation.
37712  In this phase the AST is broken down into three-operand form (iCode).
37713  These three operand forms are represented as doubly linked lists.
37714  ICode is the term given to the intermediate form generated by the compiler.
37715  ICode example section shows some examples of iCode generated for some simple
37716  C source functions.
37717 \end_layout
37718
37719 \begin_layout Paragraph*
37720 Optimizations
37721 \begin_inset LatexCommand \index{Optimizations}
37722
37723 \end_inset
37724
37725 .
37726 \end_layout
37727
37728 \begin_layout Standard
37729 Bulk of the target independent optimizations is performed in this phase.
37730  The optimizations include constant propagation, common sub-expression eliminati
37731 on, loop invariant code movement, strength reduction of loop induction variables
37732  and dead-code elimination.
37733 \end_layout
37734
37735 \begin_layout Paragraph*
37736 Live range analysis
37737 \begin_inset LatexCommand \index{Live range analysis}
37738
37739 \end_inset
37740
37741
37742 \end_layout
37743
37744 \begin_layout Standard
37745 During intermediate code generation phase, the compiler assumes the target
37746  machine has infinite number of registers and generates a lot of temporary
37747  variables.
37748  The live range computation determines the lifetime of each of these compiler-ge
37749 nerated temporaries.
37750  A picture speaks a thousand words.
37751  ICode example sections show the live range annotations for each of the
37752  operand.
37753  It is important to note here, each iCode is assigned a number in the order
37754  of its execution in the function.
37755  The live ranges are computed in terms of these numbers.
37756  The from number is the number of the iCode which first defines the operand
37757  and the to number signifies the iCode which uses this operand last.
37758 \end_layout
37759
37760 \begin_layout Paragraph*
37761 Register Allocation
37762 \begin_inset LatexCommand \index{Register allocation}
37763
37764 \end_inset
37765
37766
37767 \end_layout
37768
37769 \begin_layout Standard
37770 The register allocation determines the type and number of registers needed
37771  by each operand.
37772  In most MCUs only a few registers can be used for indirect addressing.
37773  In case of 8051 for example the registers R0 & R1 can be used to indirectly
37774  address the internal ram and DPTR to indirectly address the external ram.
37775  The compiler will try to allocate the appropriate register to pointer variables
37776  if it can.
37777  ICode example section shows the operands annotated with the registers assigned
37778  to them.
37779  The compiler will try to keep operands in registers as much as possible;
37780  there are several schemes the compiler uses to do achieve this.
37781  When the compiler runs out of registers the compiler will check to see
37782  if there are any live operands which is not used or defined in the current
37783  basic block being processed, if there are any found then it will push that
37784  operand and use the registers in this block, the operand will then be popped
37785  at the end of the basic block.
37786  
37787 \end_layout
37788
37789 \begin_layout Standard
37790 There are other MCU specific considerations in this phase.
37791  Some MCUs have an accumulator; very short-lived operands could be assigned
37792  to the accumulator instead of a general-purpose register.
37793 \end_layout
37794
37795 \begin_layout Paragraph*
37796 Code generation
37797 \end_layout
37798
37799 \begin_layout Standard
37800 Figure II gives a table of iCode
37801 \begin_inset LatexCommand \index{iCode}
37802
37803 \end_inset
37804
37805  operations supported by the compiler.
37806  The code generation involves translating these operations into corresponding
37807  assembly code for the processor.
37808  This sounds overly simple but that is the essence of code generation.
37809  Some of the iCode operations are generated on a MCU specific manner for
37810  example, the z80 port does not use registers to pass parameters so the
37811  SEND and RECV iCode operations will not be generated, and it also does
37812  not support JUMPTABLES.
37813  
37814 \newline
37815
37816 \end_layout
37817
37818 \begin_layout Standard
37819
37820 \size footnotesize
37821 Figure II 
37822 \begin_inset Tabular
37823 <lyxtabular version="3" rows="39" columns="4">
37824 <features islongtable="true" headBottomDL="true">
37825 <column alignment="block" valignment="top" leftline="true" width="13col%">
37826 <column alignment="left" valignment="top" leftline="true" width="13col%">
37827 <column alignment="block" valignment="top" leftline="true" width="22col%">
37828 <column alignment="block" valignment="top" leftline="true" rightline="true" width="40col%">
37829 <row topline="true" bottomline="true" endhead="true">
37830 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37831 \begin_inset Text
37832
37833 \begin_layout Standard
37834
37835 \series bold
37836 iCode
37837 \series default
37838
37839 \begin_inset LatexCommand \index{iCode}
37840
37841 \end_inset
37842
37843
37844 \end_layout
37845
37846 \end_inset
37847 </cell>
37848 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37849 \begin_inset Text
37850
37851 \begin_layout Standard
37852
37853 \series bold
37854 Operands
37855 \end_layout
37856
37857 \end_inset
37858 </cell>
37859 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37860 \begin_inset Text
37861
37862 \begin_layout Standard
37863
37864 \series bold
37865 Description
37866 \end_layout
37867
37868 \end_inset
37869 </cell>
37870 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37871 \begin_inset Text
37872
37873 \begin_layout Standard
37874
37875 \series bold
37876 C Equivalent
37877 \end_layout
37878
37879 \end_inset
37880 </cell>
37881 </row>
37882 <row topline="true">
37883 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37884 \begin_inset Text
37885
37886 \begin_layout Standard
37887
37888 \size footnotesize
37889 '!'
37890 \end_layout
37891
37892 \end_inset
37893 </cell>
37894 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37895 \begin_inset Text
37896
37897 \begin_layout Standard
37898
37899 \size footnotesize
37900 IC_LEFT() IC_RESULT()
37901 \end_layout
37902
37903 \end_inset
37904 </cell>
37905 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37906 \begin_inset Text
37907
37908 \begin_layout Standard
37909
37910 \size footnotesize
37911 NOT operation 
37912 \end_layout
37913
37914 \end_inset
37915 </cell>
37916 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37917 \begin_inset Text
37918
37919 \begin_layout Standard
37920
37921 \size footnotesize
37922 IC_RESULT = ! IC_LEFT;
37923 \end_layout
37924
37925 \end_inset
37926 </cell>
37927 </row>
37928 <row topline="true">
37929 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37930 \begin_inset Text
37931
37932 \begin_layout Standard
37933
37934 \size footnotesize
37935 '~'
37936 \end_layout
37937
37938 \end_inset
37939 </cell>
37940 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37941 \begin_inset Text
37942
37943 \begin_layout Standard
37944
37945 \size footnotesize
37946 IC_LEFT() IC_RESULT()
37947 \end_layout
37948
37949 \end_inset
37950 </cell>
37951 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37952 \begin_inset Text
37953
37954 \begin_layout Standard
37955
37956 \size footnotesize
37957 Bitwise complement of 
37958 \end_layout
37959
37960 \end_inset
37961 </cell>
37962 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37963 \begin_inset Text
37964
37965 \begin_layout Standard
37966
37967 \size footnotesize
37968 IC_RESULT = ~IC_LEFT;
37969 \end_layout
37970
37971 \end_inset
37972 </cell>
37973 </row>
37974 <row topline="true">
37975 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37976 \begin_inset Text
37977
37978 \begin_layout Standard
37979
37980 \size footnotesize
37981 RRC
37982 \end_layout
37983
37984 \end_inset
37985 </cell>
37986 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37987 \begin_inset Text
37988
37989 \begin_layout Standard
37990
37991 \size footnotesize
37992 IC_LEFT() IC_RESULT()
37993 \end_layout
37994
37995 \end_inset
37996 </cell>
37997 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37998 \begin_inset Text
37999
38000 \begin_layout Standard
38001
38002 \size footnotesize
38003 Rotate right with carry
38004 \end_layout
38005
38006 \end_inset
38007 </cell>
38008 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38009 \begin_inset Text
38010
38011 \begin_layout Standard
38012
38013 \size footnotesize
38014 IC_RESULT = (IC_LEFT << 1) | (IC_LEFT >> (sizeof(IC_LEFT)*8-1));
38015 \end_layout
38016
38017 \end_inset
38018 </cell>
38019 </row>
38020 <row topline="true">
38021 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38022 \begin_inset Text
38023
38024 \begin_layout Standard
38025
38026 \size footnotesize
38027 RLC
38028 \end_layout
38029
38030 \end_inset
38031 </cell>
38032 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38033 \begin_inset Text
38034
38035 \begin_layout Standard
38036
38037 \size footnotesize
38038 IC_LEFT() IC_RESULT()
38039 \end_layout
38040
38041 \end_inset
38042 </cell>
38043 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38044 \begin_inset Text
38045
38046 \begin_layout Standard
38047
38048 \size footnotesize
38049 Rotate left with carry
38050 \end_layout
38051
38052 \end_inset
38053 </cell>
38054 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38055 \begin_inset Text
38056
38057 \begin_layout Standard
38058
38059 \size footnotesize
38060 IC_RESULT = (IC_LEFT << (sizeof(LC_LEFT)*8-1) ) | (IC_LEFT >> 1);
38061 \end_layout
38062
38063 \end_inset
38064 </cell>
38065 </row>
38066 <row topline="true">
38067 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38068 \begin_inset Text
38069
38070 \begin_layout Standard
38071
38072 \size footnotesize
38073 GETHBIT
38074 \end_layout
38075
38076 \end_inset
38077 </cell>
38078 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38079 \begin_inset Text
38080
38081 \begin_layout Standard
38082
38083 \size footnotesize
38084 IC_LEFT() IC_RESULT()
38085 \end_layout
38086
38087 \end_inset
38088 </cell>
38089 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38090 \begin_inset Text
38091
38092 \begin_layout Standard
38093
38094 \size footnotesize
38095 Get the highest order bit of IC_LEFT
38096 \end_layout
38097
38098 \end_inset
38099 </cell>
38100 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38101 \begin_inset Text
38102
38103 \begin_layout Standard
38104
38105 \size footnotesize
38106 IC_RESULT = (IC_LEFT >> (sizeof(IC_LEFT)*8 -1));
38107 \end_layout
38108
38109 \end_inset
38110 </cell>
38111 </row>
38112 <row topline="true">
38113 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38114 \begin_inset Text
38115
38116 \begin_layout Standard
38117
38118 \size footnotesize
38119 UNARYMINUS
38120 \end_layout
38121
38122 \end_inset
38123 </cell>
38124 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38125 \begin_inset Text
38126
38127 \begin_layout Standard
38128
38129 \size footnotesize
38130 IC_LEFT() IC_RESULT()
38131 \end_layout
38132
38133 \end_inset
38134 </cell>
38135 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38136 \begin_inset Text
38137
38138 \begin_layout Standard
38139
38140 \size footnotesize
38141 Unary minus
38142 \end_layout
38143
38144 \end_inset
38145 </cell>
38146 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38147 \begin_inset Text
38148
38149 \begin_layout Standard
38150
38151 \size footnotesize
38152 IC_RESULT = - IC_LEFT;
38153 \end_layout
38154
38155 \end_inset
38156 </cell>
38157 </row>
38158 <row topline="true">
38159 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38160 \begin_inset Text
38161
38162 \begin_layout Standard
38163
38164 \size footnotesize
38165 IPUSH
38166 \end_layout
38167
38168 \end_inset
38169 </cell>
38170 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38171 \begin_inset Text
38172
38173 \begin_layout Standard
38174
38175 \size footnotesize
38176 IC_LEFT()
38177 \end_layout
38178
38179 \end_inset
38180 </cell>
38181 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38182 \begin_inset Text
38183
38184 \begin_layout Standard
38185
38186 \size footnotesize
38187 Push the operand into stack
38188 \end_layout
38189
38190 \end_inset
38191 </cell>
38192 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38193 \begin_inset Text
38194
38195 \begin_layout Standard
38196
38197 \size footnotesize
38198 NONE
38199 \end_layout
38200
38201 \end_inset
38202 </cell>
38203 </row>
38204 <row topline="true">
38205 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38206 \begin_inset Text
38207
38208 \begin_layout Standard
38209
38210 \size footnotesize
38211 IPOP
38212 \end_layout
38213
38214 \end_inset
38215 </cell>
38216 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38217 \begin_inset Text
38218
38219 \begin_layout Standard
38220
38221 \size footnotesize
38222 IC_LEFT()
38223 \end_layout
38224
38225 \end_inset
38226 </cell>
38227 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38228 \begin_inset Text
38229
38230 \begin_layout Standard
38231
38232 \size footnotesize
38233 Pop the operand from the stack 
38234 \end_layout
38235
38236 \end_inset
38237 </cell>
38238 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38239 \begin_inset Text
38240
38241 \begin_layout Standard
38242
38243 \size footnotesize
38244 NONE
38245 \end_layout
38246
38247 \end_inset
38248 </cell>
38249 </row>
38250 <row topline="true">
38251 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38252 \begin_inset Text
38253
38254 \begin_layout Standard
38255
38256 \size footnotesize
38257 CALL
38258 \end_layout
38259
38260 \end_inset
38261 </cell>
38262 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38263 \begin_inset Text
38264
38265 \begin_layout Standard
38266
38267 \size footnotesize
38268 IC_LEFT() IC_RESULT()
38269 \end_layout
38270
38271 \end_inset
38272 </cell>
38273 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38274 \begin_inset Text
38275
38276 \begin_layout Standard
38277
38278 \size footnotesize
38279 Call the function represented by IC_LEFT 
38280 \end_layout
38281
38282 \end_inset
38283 </cell>
38284 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38285 \begin_inset Text
38286
38287 \begin_layout Standard
38288
38289 \size footnotesize
38290 IC_RESULT = IC_LEFT();
38291 \end_layout
38292
38293 \end_inset
38294 </cell>
38295 </row>
38296 <row topline="true">
38297 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38298 \begin_inset Text
38299
38300 \begin_layout Standard
38301
38302 \size footnotesize
38303 PCALL
38304 \end_layout
38305
38306 \end_inset
38307 </cell>
38308 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38309 \begin_inset Text
38310
38311 \begin_layout Standard
38312
38313 \size footnotesize
38314 IC_LEFT() IC_RESULT()
38315 \end_layout
38316
38317 \end_inset
38318 </cell>
38319 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38320 \begin_inset Text
38321
38322 \begin_layout Standard
38323
38324 \size footnotesize
38325 Call via function pointer
38326 \end_layout
38327
38328 \end_inset
38329 </cell>
38330 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38331 \begin_inset Text
38332
38333 \begin_layout Standard
38334
38335 \size footnotesize
38336 IC_RESULT = (*IC_LEFT)();
38337 \end_layout
38338
38339 \end_inset
38340 </cell>
38341 </row>
38342 <row topline="true">
38343 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38344 \begin_inset Text
38345
38346 \begin_layout Standard
38347
38348 \size footnotesize
38349 RETURN
38350 \end_layout
38351
38352 \end_inset
38353 </cell>
38354 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38355 \begin_inset Text
38356
38357 \begin_layout Standard
38358
38359 \size footnotesize
38360 IC_LEFT()
38361 \end_layout
38362
38363 \end_inset
38364 </cell>
38365 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38366 \begin_inset Text
38367
38368 \begin_layout Standard
38369
38370 \size footnotesize
38371 Return the value in operand IC_LEFT 
38372 \end_layout
38373
38374 \end_inset
38375 </cell>
38376 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38377 \begin_inset Text
38378
38379 \begin_layout Standard
38380
38381 \size footnotesize
38382 return IC_LEFT;
38383 \end_layout
38384
38385 \end_inset
38386 </cell>
38387 </row>
38388 <row topline="true">
38389 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38390 \begin_inset Text
38391
38392 \begin_layout Standard
38393
38394 \size footnotesize
38395 LABEL
38396 \end_layout
38397
38398 \end_inset
38399 </cell>
38400 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38401 \begin_inset Text
38402
38403 \begin_layout Standard
38404
38405 \size footnotesize
38406 IC_LABEL() 
38407 \end_layout
38408
38409 \end_inset
38410 </cell>
38411 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38412 \begin_inset Text
38413
38414 \begin_layout Standard
38415
38416 \size footnotesize
38417 Label
38418 \end_layout
38419
38420 \end_inset
38421 </cell>
38422 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38423 \begin_inset Text
38424
38425 \begin_layout Standard
38426
38427 \size footnotesize
38428 IC_LABEL:
38429 \end_layout
38430
38431 \end_inset
38432 </cell>
38433 </row>
38434 <row topline="true">
38435 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38436 \begin_inset Text
38437
38438 \begin_layout Standard
38439
38440 \size footnotesize
38441 GOTO
38442 \end_layout
38443
38444 \end_inset
38445 </cell>
38446 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38447 \begin_inset Text
38448
38449 \begin_layout Standard
38450
38451 \size footnotesize
38452 IC_LABEL() 
38453 \end_layout
38454
38455 \end_inset
38456 </cell>
38457 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38458 \begin_inset Text
38459
38460 \begin_layout Standard
38461
38462 \size footnotesize
38463 Goto label
38464 \end_layout
38465
38466 \end_inset
38467 </cell>
38468 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38469 \begin_inset Text
38470
38471 \begin_layout Standard
38472
38473 \size footnotesize
38474 goto IC_LABEL();
38475 \end_layout
38476
38477 \end_inset
38478 </cell>
38479 </row>
38480 <row topline="true">
38481 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38482 \begin_inset Text
38483
38484 \begin_layout Standard
38485
38486 \size footnotesize
38487 '+'
38488 \end_layout
38489
38490 \end_inset
38491 </cell>
38492 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38493 \begin_inset Text
38494
38495 \begin_layout Standard
38496
38497 \size footnotesize
38498 IC_LEFT() IC_RIGHT() IC_RESULT()
38499 \end_layout
38500
38501 \end_inset
38502 </cell>
38503 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38504 \begin_inset Text
38505
38506 \begin_layout Standard
38507
38508 \size footnotesize
38509 Addition
38510 \end_layout
38511
38512 \end_inset
38513 </cell>
38514 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38515 \begin_inset Text
38516
38517 \begin_layout Standard
38518
38519 \size footnotesize
38520 IC_RESULT = IC_LEFT + IC_RIGHT
38521 \end_layout
38522
38523 \end_inset
38524 </cell>
38525 </row>
38526 <row topline="true">
38527 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38528 \begin_inset Text
38529
38530 \begin_layout Standard
38531
38532 \size footnotesize
38533 '-'
38534 \end_layout
38535
38536 \end_inset
38537 </cell>
38538 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38539 \begin_inset Text
38540
38541 \begin_layout Standard
38542
38543 \size footnotesize
38544 IC_LEFT() IC_RIGHT() IC_RESULT()
38545 \end_layout
38546
38547 \end_inset
38548 </cell>
38549 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38550 \begin_inset Text
38551
38552 \begin_layout Standard
38553
38554 \size footnotesize
38555 Subtraction
38556 \end_layout
38557
38558 \end_inset
38559 </cell>
38560 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38561 \begin_inset Text
38562
38563 \begin_layout Standard
38564
38565 \size footnotesize
38566 IC_RESULT = IC_LEFT - IC_RIGHT 
38567 \end_layout
38568
38569 \end_inset
38570 </cell>
38571 </row>
38572 <row topline="true">
38573 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38574 \begin_inset Text
38575
38576 \begin_layout Standard
38577
38578 \size footnotesize
38579 '*'
38580 \end_layout
38581
38582 \end_inset
38583 </cell>
38584 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38585 \begin_inset Text
38586
38587 \begin_layout Standard
38588
38589 \size footnotesize
38590 IC_LEFT() IC_RIGHT() IC_RESULT()
38591 \end_layout
38592
38593 \end_inset
38594 </cell>
38595 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38596 \begin_inset Text
38597
38598 \begin_layout Standard
38599
38600 \size footnotesize
38601 Multiplication 
38602 \end_layout
38603
38604 \end_inset
38605 </cell>
38606 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38607 \begin_inset Text
38608
38609 \begin_layout Standard
38610
38611 \size footnotesize
38612 IC_RESULT = IC_LEFT * IC_RIGHT;
38613 \end_layout
38614
38615 \end_inset
38616 </cell>
38617 </row>
38618 <row topline="true">
38619 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38620 \begin_inset Text
38621
38622 \begin_layout Standard
38623
38624 \size footnotesize
38625 '/'
38626 \end_layout
38627
38628 \end_inset
38629 </cell>
38630 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38631 \begin_inset Text
38632
38633 \begin_layout Standard
38634
38635 \size footnotesize
38636 IC_LEFT() IC_RIGHT() IC_RESULT()
38637 \end_layout
38638
38639 \end_inset
38640 </cell>
38641 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38642 \begin_inset Text
38643
38644 \begin_layout Standard
38645
38646 \size footnotesize
38647 Division
38648 \end_layout
38649
38650 \end_inset
38651 </cell>
38652 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38653 \begin_inset Text
38654
38655 \begin_layout Standard
38656
38657 \size footnotesize
38658 IC_RESULT = IC_LEFT / IC_RIGHT;
38659 \end_layout
38660
38661 \end_inset
38662 </cell>
38663 </row>
38664 <row topline="true">
38665 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38666 \begin_inset Text
38667
38668 \begin_layout Standard
38669
38670 \size footnotesize
38671 '%'
38672 \end_layout
38673
38674 \end_inset
38675 </cell>
38676 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38677 \begin_inset Text
38678
38679 \begin_layout Standard
38680
38681 \size footnotesize
38682 IC_LEFT() IC_RIGHT() IC_RESULT()
38683 \end_layout
38684
38685 \end_inset
38686 </cell>
38687 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38688 \begin_inset Text
38689
38690 \begin_layout Standard
38691
38692 \size footnotesize
38693 Modulus
38694 \end_layout
38695
38696 \end_inset
38697 </cell>
38698 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38699 \begin_inset Text
38700
38701 \begin_layout Standard
38702
38703 \size footnotesize
38704 IC_RESULT = IC_LEFT % IC_RIGHT;
38705 \end_layout
38706
38707 \end_inset
38708 </cell>
38709 </row>
38710 <row topline="true">
38711 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38712 \begin_inset Text
38713
38714 \begin_layout Standard
38715
38716 \size footnotesize
38717 '<'
38718 \end_layout
38719
38720 \end_inset
38721 </cell>
38722 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38723 \begin_inset Text
38724
38725 \begin_layout Standard
38726
38727 \size footnotesize
38728 IC_LEFT() IC_RIGHT() IC_RESULT()
38729 \end_layout
38730
38731 \end_inset
38732 </cell>
38733 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38734 \begin_inset Text
38735
38736 \begin_layout Standard
38737
38738 \size footnotesize
38739 Less than
38740 \end_layout
38741
38742 \end_inset
38743 </cell>
38744 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38745 \begin_inset Text
38746
38747 \begin_layout Standard
38748
38749 \size footnotesize
38750 IC_RESULT = IC_LEFT < IC_RIGHT;
38751 \end_layout
38752
38753 \end_inset
38754 </cell>
38755 </row>
38756 <row topline="true">
38757 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38758 \begin_inset Text
38759
38760 \begin_layout Standard
38761
38762 \size footnotesize
38763 '>'
38764 \end_layout
38765
38766 \end_inset
38767 </cell>
38768 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38769 \begin_inset Text
38770
38771 \begin_layout Standard
38772
38773 \size footnotesize
38774 IC_LEFT() IC_RIGHT() IC_RESULT()
38775 \end_layout
38776
38777 \end_inset
38778 </cell>
38779 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38780 \begin_inset Text
38781
38782 \begin_layout Standard
38783
38784 \size footnotesize
38785 Greater than 
38786 \end_layout
38787
38788 \end_inset
38789 </cell>
38790 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38791 \begin_inset Text
38792
38793 \begin_layout Standard
38794
38795 \size footnotesize
38796 IC_RESULT = IC_LEFT > IC_RIGHT;
38797 \end_layout
38798
38799 \end_inset
38800 </cell>
38801 </row>
38802 <row topline="true">
38803 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38804 \begin_inset Text
38805
38806 \begin_layout Standard
38807
38808 \size footnotesize
38809 EQ_OP
38810 \end_layout
38811
38812 \end_inset
38813 </cell>
38814 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38815 \begin_inset Text
38816
38817 \begin_layout Standard
38818
38819 \size footnotesize
38820 IC_LEFT() IC_RIGHT() IC_RESULT()
38821 \end_layout
38822
38823 \end_inset
38824 </cell>
38825 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38826 \begin_inset Text
38827
38828 \begin_layout Standard
38829
38830 \size footnotesize
38831 Equal to 
38832 \end_layout
38833
38834 \end_inset
38835 </cell>
38836 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38837 \begin_inset Text
38838
38839 \begin_layout Standard
38840
38841 \size footnotesize
38842 IC_RESULT = IC_LEFT == IC_RIGHT;
38843 \end_layout
38844
38845 \end_inset
38846 </cell>
38847 </row>
38848 <row topline="true">
38849 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38850 \begin_inset Text
38851
38852 \begin_layout Standard
38853
38854 \size footnotesize
38855 AND_OP
38856 \end_layout
38857
38858 \end_inset
38859 </cell>
38860 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38861 \begin_inset Text
38862
38863 \begin_layout Standard
38864
38865 \size footnotesize
38866 IC_LEFT() IC_RIGHT() IC_RESULT() 
38867 \end_layout
38868
38869 \end_inset
38870 </cell>
38871 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38872 \begin_inset Text
38873
38874 \begin_layout Standard
38875
38876 \size footnotesize
38877 Logical and operation
38878 \end_layout
38879
38880 \end_inset
38881 </cell>
38882 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38883 \begin_inset Text
38884
38885 \begin_layout Standard
38886
38887 \size footnotesize
38888 IC_RESULT = IC_LEFT && IC_RIGHT; 
38889 \end_layout
38890
38891 \end_inset
38892 </cell>
38893 </row>
38894 <row topline="true">
38895 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38896 \begin_inset Text
38897
38898 \begin_layout Standard
38899
38900 \size footnotesize
38901 OR_OP
38902 \end_layout
38903
38904 \end_inset
38905 </cell>
38906 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38907 \begin_inset Text
38908
38909 \begin_layout Standard
38910
38911 \size footnotesize
38912 IC_LEFT() IC_RIGHT() IC_RESULT() 
38913 \end_layout
38914
38915 \end_inset
38916 </cell>
38917 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38918 \begin_inset Text
38919
38920 \begin_layout Standard
38921
38922 \size footnotesize
38923 Logical or operation 
38924 \end_layout
38925
38926 \end_inset
38927 </cell>
38928 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38929 \begin_inset Text
38930
38931 \begin_layout Standard
38932
38933 \size footnotesize
38934 IC_RESULT = IC_LEFT || IC_RIGHT; 
38935 \end_layout
38936
38937 \end_inset
38938 </cell>
38939 </row>
38940 <row topline="true">
38941 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38942 \begin_inset Text
38943
38944 \begin_layout Standard
38945
38946 \size footnotesize
38947 '^'
38948 \end_layout
38949
38950 \end_inset
38951 </cell>
38952 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38953 \begin_inset Text
38954
38955 \begin_layout Standard
38956
38957 \size footnotesize
38958 IC_LEFT() IC_RIGHT() IC_RESULT() 
38959 \end_layout
38960
38961 \end_inset
38962 </cell>
38963 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38964 \begin_inset Text
38965
38966 \begin_layout Standard
38967
38968 \size footnotesize
38969 Exclusive OR
38970 \end_layout
38971
38972 \end_inset
38973 </cell>
38974 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38975 \begin_inset Text
38976
38977 \begin_layout Standard
38978
38979 \size footnotesize
38980 IC_RESULT = IC_LEFT ^ IC_RIGHT;
38981 \end_layout
38982
38983 \end_inset
38984 </cell>
38985 </row>
38986 <row topline="true">
38987 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38988 \begin_inset Text
38989
38990 \begin_layout Standard
38991
38992 \size footnotesize
38993 '|'
38994 \end_layout
38995
38996 \end_inset
38997 </cell>
38998 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38999 \begin_inset Text
39000
39001 \begin_layout Standard
39002
39003 \size footnotesize
39004 IC_LEFT() IC_RIGHT() IC_RESULT() 
39005 \end_layout
39006
39007 \end_inset
39008 </cell>
39009 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39010 \begin_inset Text
39011
39012 \begin_layout Standard
39013
39014 \size footnotesize
39015 Bitwise OR 
39016 \end_layout
39017
39018 \end_inset
39019 </cell>
39020 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39021 \begin_inset Text
39022
39023 \begin_layout Standard
39024
39025 \size footnotesize
39026 IC_RESULT = IC_LEFT | IC_RIGHT;
39027 \end_layout
39028
39029 \end_inset
39030 </cell>
39031 </row>
39032 <row topline="true">
39033 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39034 \begin_inset Text
39035
39036 \begin_layout Standard
39037
39038 \size footnotesize
39039 BITWISEAND
39040 \end_layout
39041
39042 \end_inset
39043 </cell>
39044 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39045 \begin_inset Text
39046
39047 \begin_layout Standard
39048
39049 \size footnotesize
39050 IC_LEFT() IC_RIGHT() IC_RESULT()
39051 \end_layout
39052
39053 \end_inset
39054 </cell>
39055 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39056 \begin_inset Text
39057
39058 \begin_layout Standard
39059
39060 \size footnotesize
39061 Bitwise AND 
39062 \end_layout
39063
39064 \end_inset
39065 </cell>
39066 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39067 \begin_inset Text
39068
39069 \begin_layout Standard
39070
39071 \size footnotesize
39072 IC_RESULT = IC_LEFT & IC_RIGHT;
39073 \end_layout
39074
39075 \end_inset
39076 </cell>
39077 </row>
39078 <row topline="true">
39079 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39080 \begin_inset Text
39081
39082 \begin_layout Standard
39083
39084 \size footnotesize
39085 LEFT_OP
39086 \end_layout
39087
39088 \end_inset
39089 </cell>
39090 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39091 \begin_inset Text
39092
39093 \begin_layout Standard
39094
39095 \size footnotesize
39096 IC_LEFT() IC_RIGHT() IC_RESULT()
39097 \end_layout
39098
39099 \end_inset
39100 </cell>
39101 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39102 \begin_inset Text
39103
39104 \begin_layout Standard
39105
39106 \size footnotesize
39107 Left shift 
39108 \end_layout
39109
39110 \end_inset
39111 </cell>
39112 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39113 \begin_inset Text
39114
39115 \begin_layout Standard
39116
39117 \size footnotesize
39118 IC_RESULT = IC_LEFT << IC_RIGHT 
39119 \end_layout
39120
39121 \end_inset
39122 </cell>
39123 </row>
39124 <row topline="true">
39125 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39126 \begin_inset Text
39127
39128 \begin_layout Standard
39129
39130 \size footnotesize
39131 RIGHT_OP
39132 \end_layout
39133
39134 \end_inset
39135 </cell>
39136 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39137 \begin_inset Text
39138
39139 \begin_layout Standard
39140
39141 \size footnotesize
39142 IC_LEFT() IC_RIGHT() IC_RESULT()
39143 \end_layout
39144
39145 \end_inset
39146 </cell>
39147 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39148 \begin_inset Text
39149
39150 \begin_layout Standard
39151
39152 \size footnotesize
39153 Right shift
39154 \end_layout
39155
39156 \end_inset
39157 </cell>
39158 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39159 \begin_inset Text
39160
39161 \begin_layout Standard
39162
39163 \size footnotesize
39164 IC_RESULT = IC_LEFT >> IC_RIGHT 
39165 \end_layout
39166
39167 \end_inset
39168 </cell>
39169 </row>
39170 <row topline="true">
39171 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39172 \begin_inset Text
39173
39174 \begin_layout Standard
39175
39176 \size footnotesize
39177 GET_VALUE_
39178 \newline
39179 AT_ ADDRESS
39180 \end_layout
39181
39182 \end_inset
39183 </cell>
39184 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39185 \begin_inset Text
39186
39187 \begin_layout Standard
39188
39189 \size footnotesize
39190 IC_LEFT() IC_RESULT()
39191 \end_layout
39192
39193 \end_inset
39194 </cell>
39195 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39196 \begin_inset Text
39197
39198 \begin_layout Standard
39199
39200 \size footnotesize
39201 Indirect fetch 
39202 \end_layout
39203
39204 \end_inset
39205 </cell>
39206 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39207 \begin_inset Text
39208
39209 \begin_layout Standard
39210
39211 \size footnotesize
39212 IC_RESULT = (*IC_LEFT);
39213 \end_layout
39214
39215 \end_inset
39216 </cell>
39217 </row>
39218 <row topline="true">
39219 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39220 \begin_inset Text
39221
39222 \begin_layout Standard
39223
39224 \size footnotesize
39225 POINTER_SET
39226 \end_layout
39227
39228 \end_inset
39229 </cell>
39230 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39231 \begin_inset Text
39232
39233 \begin_layout Standard
39234
39235 \size footnotesize
39236 IC_RIGHT() IC_RESULT() 
39237 \end_layout
39238
39239 \end_inset
39240 </cell>
39241 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39242 \begin_inset Text
39243
39244 \begin_layout Standard
39245
39246 \size footnotesize
39247 Indirect set
39248 \end_layout
39249
39250 \end_inset
39251 </cell>
39252 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39253 \begin_inset Text
39254
39255 \begin_layout Standard
39256
39257 \size footnotesize
39258 (*IC_RESULT) = IC_RIGHT;
39259 \end_layout
39260
39261 \end_inset
39262 </cell>
39263 </row>
39264 <row topline="true">
39265 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39266 \begin_inset Text
39267
39268 \begin_layout Standard
39269
39270 \size footnotesize
39271 '='
39272 \end_layout
39273
39274 \end_inset
39275 </cell>
39276 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39277 \begin_inset Text
39278
39279 \begin_layout Standard
39280
39281 \size footnotesize
39282 IC_RIGHT() IC_RESULT()
39283 \end_layout
39284
39285 \end_inset
39286 </cell>
39287 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39288 \begin_inset Text
39289
39290 \begin_layout Standard
39291
39292 \size footnotesize
39293 Assignment
39294 \end_layout
39295
39296 \end_inset
39297 </cell>
39298 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39299 \begin_inset Text
39300
39301 \begin_layout Standard
39302
39303 \size footnotesize
39304 IC_RESULT = IC_RIGHT;
39305 \end_layout
39306
39307 \end_inset
39308 </cell>
39309 </row>
39310 <row topline="true">
39311 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39312 \begin_inset Text
39313
39314 \begin_layout Standard
39315
39316 \size footnotesize
39317 IFX
39318 \end_layout
39319
39320 \end_inset
39321 </cell>
39322 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39323 \begin_inset Text
39324
39325 \begin_layout Standard
39326
39327 \size footnotesize
39328 IC_COND IC_TRUE IC_LABEL
39329 \end_layout
39330
39331 \end_inset
39332 </cell>
39333 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39334 \begin_inset Text
39335
39336 \begin_layout Standard
39337
39338 \size footnotesize
39339 Conditional jump.
39340  If true label is present then jump to true label if condition is true else
39341  jump to false label if condition is false 
39342 \end_layout
39343
39344 \end_inset
39345 </cell>
39346 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39347 \begin_inset Text
39348
39349 \begin_layout Standard
39350
39351 \size footnotesize
39352 if (IC_COND) goto IC_TRUE; 
39353 \newline
39354 \InsetSpace ~
39355 \InsetSpace ~
39356 Or 
39357 \newline
39358 If (!IC_COND) goto IC_FALSE;
39359 \end_layout
39360
39361 \end_inset
39362 </cell>
39363 </row>
39364 <row topline="true">
39365 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39366 \begin_inset Text
39367
39368 \begin_layout Standard
39369
39370 \size footnotesize
39371 ADDRESS_OF
39372 \end_layout
39373
39374 \end_inset
39375 </cell>
39376 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39377 \begin_inset Text
39378
39379 \begin_layout Standard
39380
39381 \size footnotesize
39382 IC_LEFT() IC_RESULT()
39383 \end_layout
39384
39385 \end_inset
39386 </cell>
39387 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39388 \begin_inset Text
39389
39390 \begin_layout Standard
39391
39392 \size footnotesize
39393 Address of 
39394 \end_layout
39395
39396 \end_inset
39397 </cell>
39398 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39399 \begin_inset Text
39400
39401 \begin_layout Standard
39402
39403 \size footnotesize
39404 IC_RESULT = &IC_LEFT();
39405 \end_layout
39406
39407 \end_inset
39408 </cell>
39409 </row>
39410 <row topline="true">
39411 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39412 \begin_inset Text
39413
39414 \begin_layout Standard
39415
39416 \size footnotesize
39417 JUMPTABLE
39418 \end_layout
39419
39420 \end_inset
39421 </cell>
39422 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39423 \begin_inset Text
39424
39425 \begin_layout Standard
39426
39427 \size footnotesize
39428 IC_JTCOND IC_JTLABELS
39429 \end_layout
39430
39431 \end_inset
39432 </cell>
39433 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39434 \begin_inset Text
39435
39436 \begin_layout Standard
39437
39438 \size footnotesize
39439 Jump to list of labels depending on the value of JTCOND
39440 \end_layout
39441
39442 \end_inset
39443 </cell>
39444 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39445 \begin_inset Text
39446
39447 \begin_layout Standard
39448
39449 \size footnotesize
39450 Switch statement
39451 \end_layout
39452
39453 \end_inset
39454 </cell>
39455 </row>
39456 <row topline="true">
39457 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39458 \begin_inset Text
39459
39460 \begin_layout Standard
39461
39462 \size footnotesize
39463 CAST
39464 \end_layout
39465
39466 \end_inset
39467 </cell>
39468 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39469 \begin_inset Text
39470
39471 \begin_layout Standard
39472
39473 \size footnotesize
39474 IC_RIGHT() IC_LEFT() IC_RESULT()
39475 \end_layout
39476
39477 \end_inset
39478 </cell>
39479 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39480 \begin_inset Text
39481
39482 \begin_layout Standard
39483
39484 \size footnotesize
39485 Cast types 
39486 \end_layout
39487
39488 \end_inset
39489 </cell>
39490 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39491 \begin_inset Text
39492
39493 \begin_layout Standard
39494
39495 \size footnotesize
39496 IC_RESULT = (typeof IC_LEFT) IC_RIGHT;
39497 \end_layout
39498
39499 \end_inset
39500 </cell>
39501 </row>
39502 <row topline="true">
39503 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39504 \begin_inset Text
39505
39506 \begin_layout Standard
39507
39508 \size footnotesize
39509 SEND
39510 \end_layout
39511
39512 \end_inset
39513 </cell>
39514 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39515 \begin_inset Text
39516
39517 \begin_layout Standard
39518
39519 \size footnotesize
39520 IC_LEFT()
39521 \end_layout
39522
39523 \end_inset
39524 </cell>
39525 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39526 \begin_inset Text
39527
39528 \begin_layout Standard
39529
39530 \size footnotesize
39531 This is used for passing parameters in registers; 
39532 \newline
39533 move IC_LEFT to the next
39534  available parameter register.
39535 \end_layout
39536
39537 \end_inset
39538 </cell>
39539 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39540 \begin_inset Text
39541
39542 \begin_layout Standard
39543
39544 \size footnotesize
39545 None
39546 \end_layout
39547
39548 \end_inset
39549 </cell>
39550 </row>
39551 <row topline="true">
39552 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39553 \begin_inset Text
39554
39555 \begin_layout Standard
39556
39557 \size footnotesize
39558 RECV
39559 \end_layout
39560
39561 \end_inset
39562 </cell>
39563 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39564 \begin_inset Text
39565
39566 \begin_layout Standard
39567
39568 \size footnotesize
39569 IC_RESULT()
39570 \end_layout
39571
39572 \end_inset
39573 </cell>
39574 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39575 \begin_inset Text
39576
39577 \begin_layout Standard
39578
39579 \size footnotesize
39580 This is used for receiving parameters passed in registers;
39581 \newline
39582 Move the values
39583  in the next parameter register to IC_RESULT 
39584 \end_layout
39585
39586 \end_inset
39587 </cell>
39588 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39589 \begin_inset Text
39590
39591 \begin_layout Standard
39592
39593 \size footnotesize
39594 None
39595 \end_layout
39596
39597 \end_inset
39598 </cell>
39599 </row>
39600 <row topline="true" bottomline="true">
39601 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39602 \begin_inset Text
39603
39604 \begin_layout Standard
39605
39606 \shape slanted
39607 \size footnotesize
39608 (some more have been added)
39609 \end_layout
39610
39611 \end_inset
39612 </cell>
39613 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39614 \begin_inset Text
39615
39616 \begin_layout Standard
39617
39618 \end_layout
39619
39620 \end_inset
39621 </cell>
39622 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39623 \begin_inset Text
39624
39625 \begin_layout Standard
39626
39627 \end_layout
39628
39629 \end_inset
39630 </cell>
39631 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39632 \begin_inset Text
39633
39634 \begin_layout Standard
39635
39636 \shape slanted
39637 \size footnotesize
39638 see f.e.
39639  
39640 \family typewriter
39641 gen51Code()
39642 \family default
39643  in 
39644 \family typewriter
39645 src/mcs51/gen.c
39646 \end_layout
39647
39648 \end_inset
39649 </cell>
39650 </row>
39651 </lyxtabular>
39652
39653 \end_inset
39654
39655
39656 \end_layout
39657
39658 \begin_layout Standard
39659 \begin_inset Note Note
39660 status collapsed
39661
39662 \begin_layout Standard
39663 In the original article Figure II was announced to be downloadable on 
39664 \shape italic
39665 Circuit Cellar
39666 \shape default
39667 's web site.
39668  ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2000/121/dutta.ZIP
39669 \end_layout
39670
39671 \end_inset
39672
39673
39674 \end_layout
39675
39676 \begin_layout Paragraph*
39677 ICode Example
39678 \begin_inset LatexCommand \index{iCode}
39679
39680 \end_inset
39681
39682
39683 \end_layout
39684
39685 \begin_layout Standard
39686 This section shows some details of iCode.
39687  The example C code does not do anything useful; it is used as an example
39688  to illustrate the intermediate code generated by the compiler.
39689 \end_layout
39690
39691 \begin_layout Verse
39692
39693 \family typewriter
39694 1.\InsetSpace ~
39695 xdata int * p;
39696 \newline
39697 2.\InsetSpace ~
39698 int gint;
39699 \newline
39700 3.\InsetSpace ~
39701 /* This function does nothing useful.
39702  It is used
39703 \newline
39704 4.\InsetSpace ~
39705 \InsetSpace ~
39706 \InsetSpace ~
39707 \InsetSpace ~
39708 for the purpose of explaining iCode */
39709 \newline
39710 5.\InsetSpace ~
39711 short function (data
39712  int *x)
39713 \newline
39714 6.\InsetSpace ~
39715 {
39716 \newline
39717 7.\InsetSpace ~
39718 \InsetSpace ~
39719 \InsetSpace ~
39720 short i=10; \InsetSpace ~
39721 \InsetSpace ~
39722 /* dead initialization eliminated */
39723 \newline
39724 8.\InsetSpace ~
39725 \InsetSpace ~
39726 \InsetSpace ~
39727 short sum=10;
39728  /* dead initialization eliminated */
39729 \newline
39730 9.\InsetSpace ~
39731 \InsetSpace ~
39732 \InsetSpace ~
39733 short mul;
39734 \newline
39735 10.\InsetSpace ~
39736 \InsetSpace ~
39737 int j ;
39738 \newline
39739 11.\InsetSpace ~
39740 \InsetSpace ~
39741 while (*x) *x++
39742  = *p++; 
39743 \newline
39744 12.\InsetSpace ~
39745 \InsetSpace ~
39746 \InsetSpace ~
39747 \InsetSpace ~
39748 sum = 0 ; 
39749 \newline
39750 13.\InsetSpace ~
39751 \InsetSpace ~
39752 mul = 0;
39753 \newline
39754 14.\InsetSpace ~
39755 \InsetSpace ~
39756 /* compiler detects i,j to be induction
39757  variables */
39758 \newline
39759 15.\InsetSpace ~
39760 \InsetSpace ~
39761 for (i = 0, j = 10 ; i < 10 ; i++, j
39762 \family default
39763 -
39764 \begin_inset ERT
39765 status collapsed
39766
39767 \begin_layout Standard
39768
39769
39770 \backslash
39771 /
39772 \end_layout
39773
39774 \end_inset
39775
39776 -
39777 \family typewriter
39778 ) {
39779 \newline
39780 16.\InsetSpace ~
39781 \InsetSpace ~
39782 \InsetSpace ~
39783 \InsetSpace ~
39784 sum += i;
39785 \newline
39786 17.\InsetSpace ~
39787 \InsetSpace ~
39788 \InsetSpace ~
39789 \InsetSpace ~
39790 mul += i * 3; \InsetSpace ~
39791 \InsetSpace ~
39792 /* this multiplication remains */
39793 \newline
39794 18.\InsetSpace ~
39795 \InsetSpace ~
39796 \InsetSpace ~
39797 \InsetSpace ~
39798 gint +=
39799  j * 3;\InsetSpace ~
39800 \InsetSpace ~
39801 /* this multiplication changed to addition */
39802 \newline
39803 19.\InsetSpace ~
39804 \InsetSpace ~
39805 }
39806 \newline
39807 20.\InsetSpace ~
39808 \InsetSpace ~
39809 return sum+mul;
39810 \newline
39811 21.\InsetSpace ~
39812 }
39813 \end_layout
39814
39815 \begin_layout Standard
39816 In addition to the operands each iCode contains information about the filename
39817  and line it corresponds to in the source file.
39818  The first field in the listing should be interpreted as follows:
39819 \newline
39820
39821 \shape italic
39822 \size footnotesize
39823 Filename(linenumber: iCode Execution sequence number : ICode hash table
39824  key : loop depth of the iCode).
39825 \shape default
39826 \size default
39827
39828 \newline
39829 Then follows the human readable form of the ICode operation.
39830  Each operand of this triplet form can be of three basic types a) compiler
39831  generated temporary b) user defined variable c) a constant value.
39832  Note that local variables and parameters are replaced by compiler generated
39833  temporaries.
39834  Live ranges
39835 \begin_inset LatexCommand \index{Live range analysis}
39836
39837 \end_inset
39838
39839  are computed only for temporaries (i.e.
39840  live ranges are not computed for global variables).
39841  Registers
39842 \begin_inset LatexCommand \index{Register allocation}
39843
39844 \end_inset
39845
39846  are allocated for temporaries only.
39847  Operands are formatted in the following manner:
39848 \newline
39849
39850 \shape italic
39851 \size footnotesize
39852 Operand Name [lr live-from : live-to ] { type information } [ registers
39853  allocated ].
39854 \shape default
39855 \size default
39856
39857 \newline
39858 As mentioned earlier the live ranges are computed in terms of the execution
39859  sequence number of the iCodes, for example 
39860 \newline
39861 the iTemp0 is live from (i.e.
39862  first defined in iCode with execution sequence number 3, and is last used
39863  in the iCode with sequence number 5).
39864  For induction variables such as iTemp21 the live range computation extends
39865  the lifetime from the start to the end of the loop.
39866 \newline
39867 The register allocator
39868  used the live range information to allocate registers, the same registers
39869  may be used for different temporaries if their live ranges do not overlap,
39870  for example r0 is allocated to both iTemp6 and to iTemp17 since their live
39871  ranges do not overlap.
39872  In addition the allocator also takes into consideration the type and usage
39873  of a temporary, for example itemp6 is a pointer to near space and is used
39874  as to fetch data from (i.e.
39875  used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer register (r0).
39876  Some short lived temporaries are allocated to special registers which have
39877  meaning to the code generator e.g.
39878  iTemp13 is allocated to a pseudo register CC which tells the back end that
39879  the temporary is used only for a conditional jump the code generation makes
39880  use of this information to optimize a compare and jump ICode.
39881 \newline
39882 There are several
39883  loop optimizations
39884 \begin_inset LatexCommand \index{Loop optimization}
39885
39886 \end_inset
39887
39888  performed by the compiler.
39889  It can detect induction variables iTemp21(i) and iTemp23(j).
39890  Also note the compiler does selective strength reduction
39891 \begin_inset LatexCommand \index{Strength reduction}
39892
39893 \end_inset
39894
39895 , i.e.
39896  the multiplication of an induction variable in line 18 (gint = j * 3) is
39897  changed to addition, a new temporary iTemp17 is allocated and assigned
39898  a initial value, a constant 3 is then added for each iteration of the loop.
39899  The compiler does not change the multiplication
39900 \begin_inset LatexCommand \index{Multiplication}
39901
39902 \end_inset
39903
39904  in line 17 however since the processor does support an 8 * 8 bit multiplication.
39905 \newline
39906
39907 Note the dead code elimination
39908 \begin_inset LatexCommand \index{Dead-code elimination}
39909
39910 \end_inset
39911
39912  optimization eliminated the dead assignments in line 7 & 8 to I and sum
39913  respectively.
39914 \newline
39915
39916 \end_layout
39917
39918 \begin_layout Standard
39919
39920 \size footnotesize
39921 Sample.c (5:1:0:0) _entry($9) :
39922 \end_layout
39923
39924 \begin_layout Standard
39925
39926 \size footnotesize
39927 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
39928 \end_layout
39929
39930 \begin_layout Standard
39931
39932 \size footnotesize
39933 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv 
39934 \end_layout
39935
39936 \begin_layout Standard
39937
39938 \size footnotesize
39939 Sample.c(11:4:53:0) preHeaderLbl0($11) :
39940 \end_layout
39941
39942 \begin_layout Standard
39943
39944 \size footnotesize
39945 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
39946  * int}[r2]
39947 \end_layout
39948
39949 \begin_layout Standard
39950
39951 \size footnotesize
39952 Sample.c(11:6:5:1) _whilecontinue_0($1) :
39953 \end_layout
39954
39955 \begin_layout Standard
39956
39957 \size footnotesize
39958 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
39959  int}[r0]]
39960 \end_layout
39961
39962 \begin_layout Standard
39963
39964 \size footnotesize
39965 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
39966 \end_layout
39967
39968 \begin_layout Standard
39969
39970 \size footnotesize
39971 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
39972  * int}
39973 \end_layout
39974
39975 \begin_layout Standard
39976
39977 \size footnotesize
39978 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
39979  {short}
39980 \end_layout
39981
39982 \begin_layout Standard
39983
39984 \size footnotesize
39985 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
39986  * int}[DPTR]]
39987 \end_layout
39988
39989 \begin_layout Standard
39990
39991 \size footnotesize
39992 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
39993 }[r2 r3]
39994 \end_layout
39995
39996 \begin_layout Standard
39997
39998 \size footnotesize
39999 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
40000  * int}[r0] + 0x2 {short}
40001 \end_layout
40002
40003 \begin_layout Standard
40004
40005 \size footnotesize
40006 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
40007 \end_layout
40008
40009 \begin_layout Standard
40010
40011 \size footnotesize
40012 Sample.c(11:17:21:0)_whilebreak_0($3) :
40013 \end_layout
40014
40015 \begin_layout Standard
40016
40017 \size footnotesize
40018 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
40019 \end_layout
40020
40021 \begin_layout Standard
40022
40023 \size footnotesize
40024 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
40025 \end_layout
40026
40027 \begin_layout Standard
40028
40029 \size footnotesize
40030 Sample.c(15:20:54:0)preHeaderLbl1($13) :
40031 \end_layout
40032
40033 \begin_layout Standard
40034
40035 \size footnotesize
40036 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
40037 \end_layout
40038
40039 \begin_layout Standard
40040
40041 \size footnotesize
40042 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
40043 \end_layout
40044
40045 \begin_layout Standard
40046
40047 \size footnotesize
40048 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
40049 \end_layout
40050
40051 \begin_layout Standard
40052
40053 \size footnotesize
40054 Sample.c(15:24:26:1)_forcond_0($4) :
40055 \end_layout
40056
40057 \begin_layout Standard
40058
40059 \size footnotesize
40060 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
40061  < 0xa {short}
40062 \end_layout
40063
40064 \begin_layout Standard
40065
40066 \size footnotesize
40067 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
40068 \end_layout
40069
40070 \begin_layout Standard
40071
40072 \size footnotesize
40073 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
40074  + ITemp21 [lr21:38]{short}[r4]
40075 \end_layout
40076
40077 \begin_layout Standard
40078
40079 \size footnotesize
40080 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
40081  * 0x3 {short}
40082 \end_layout
40083
40084 \begin_layout Standard
40085
40086 \size footnotesize
40087 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
40088  + iTemp15 [lr29:30]{short}[r1]
40089 \end_layout
40090
40091 \begin_layout Standard
40092
40093 \size footnotesize
40094 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
40095  r0]- 0x3 {short}
40096 \end_layout
40097
40098 \begin_layout Standard
40099
40100 \size footnotesize
40101 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
40102 int}[r7 r0]
40103 \end_layout
40104
40105 \begin_layout Standard
40106
40107 \size footnotesize
40108 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
40109  + 0x1 {short}
40110 \end_layout
40111
40112 \begin_layout Standard
40113
40114 \size footnotesize
40115 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
40116  r6]- 0x1 {short}
40117 \end_layout
40118
40119 \begin_layout Standard
40120
40121 \size footnotesize
40122 Sample.c(19:38:47:1) goto _forcond_0($4)
40123 \end_layout
40124
40125 \begin_layout Standard
40126
40127 \size footnotesize
40128 Sample.c(19:39:48:0)_forbreak_0($7) :
40129 \end_layout
40130
40131 \begin_layout Standard
40132
40133 \size footnotesize
40134 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
40135  + ITemp11 [lr19:40]{short}[r3]
40136 \end_layout
40137
40138 \begin_layout Standard
40139
40140 \size footnotesize
40141 Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
40142 \end_layout
40143
40144 \begin_layout Standard
40145
40146 \size footnotesize
40147 Sample.c(20:42:51:0)_return($8) :
40148 \end_layout
40149
40150 \begin_layout Standard
40151
40152 \size footnotesize
40153 Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
40154 \size default
40155
40156 \newline
40157
40158 \newline
40159 Finally the code generated for this function:
40160 \newline
40161
40162 \end_layout
40163
40164 \begin_layout Standard
40165
40166 \size footnotesize
40167 .area DSEG (DATA)
40168 \end_layout
40169
40170 \begin_layout Standard
40171
40172 \size footnotesize
40173 _p::
40174 \end_layout
40175
40176 \begin_layout Standard
40177
40178 \size footnotesize
40179 \InsetSpace ~
40180 \InsetSpace ~
40181 .ds 2
40182 \end_layout
40183
40184 \begin_layout Standard
40185
40186 \size footnotesize
40187 _gint::
40188 \end_layout
40189
40190 \begin_layout Standard
40191
40192 \size footnotesize
40193 \InsetSpace ~
40194 \InsetSpace ~
40195 .ds 2
40196 \end_layout
40197
40198 \begin_layout Standard
40199
40200 \size footnotesize
40201 ; sample.c 5
40202 \end_layout
40203
40204 \begin_layout Standard
40205
40206 \size footnotesize
40207 ; ----------------------------------------------
40208 \end_layout
40209
40210 \begin_layout Standard
40211
40212 \size footnotesize
40213 ; function function
40214 \end_layout
40215
40216 \begin_layout Standard
40217
40218 \size footnotesize
40219 ; ----------------------------------------------
40220 \end_layout
40221
40222 \begin_layout Standard
40223
40224 \size footnotesize
40225 _function:
40226 \end_layout
40227
40228 \begin_layout Standard
40229
40230 \size footnotesize
40231 ; iTemp0 [lr3:5]{_near * int}[r2] = recv 
40232 \end_layout
40233
40234 \begin_layout Standard
40235
40236 \size footnotesize
40237 \InsetSpace ~
40238 \InsetSpace ~
40239 mov r2,dpl
40240 \end_layout
40241
40242 \begin_layout Standard
40243
40244 \size footnotesize
40245 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
40246 \end_layout
40247
40248 \begin_layout Standard
40249
40250 \size footnotesize
40251 \InsetSpace ~
40252 \InsetSpace ~
40253 mov ar0,r2
40254 \end_layout
40255
40256 \begin_layout Standard
40257
40258 \size footnotesize
40259 ;_whilecontinue_0($1) :
40260 \end_layout
40261
40262 \begin_layout Standard
40263
40264 \size footnotesize
40265 00101$:
40266 \end_layout
40267
40268 \begin_layout Standard
40269
40270 \size footnotesize
40271 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
40272 \end_layout
40273
40274 \begin_layout Standard
40275
40276 \size footnotesize
40277 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
40278 \end_layout
40279
40280 \begin_layout Standard
40281
40282 \size footnotesize
40283 \InsetSpace ~
40284 \InsetSpace ~
40285 mov ar2,@r0
40286 \end_layout
40287
40288 \begin_layout Standard
40289
40290 \size footnotesize
40291 \InsetSpace ~
40292 \InsetSpace ~
40293 inc r0
40294 \end_layout
40295
40296 \begin_layout Standard
40297
40298 \size footnotesize
40299 \InsetSpace ~
40300 \InsetSpace ~
40301 mov ar3,@r0
40302 \end_layout
40303
40304 \begin_layout Standard
40305
40306 \size footnotesize
40307 \InsetSpace ~
40308 \InsetSpace ~
40309 dec r0
40310 \end_layout
40311
40312 \begin_layout Standard
40313
40314 \size footnotesize
40315 \InsetSpace ~
40316 \InsetSpace ~
40317 mov a,r2
40318 \end_layout
40319
40320 \begin_layout Standard
40321
40322 \size footnotesize
40323 \InsetSpace ~
40324 \InsetSpace ~
40325 orl a,r3
40326 \end_layout
40327
40328 \begin_layout Standard
40329
40330 \size footnotesize
40331 \InsetSpace ~
40332 \InsetSpace ~
40333 jz 00103$
40334 \end_layout
40335
40336 \begin_layout Standard
40337
40338 \size footnotesize
40339 00114$:
40340 \end_layout
40341
40342 \begin_layout Standard
40343
40344 \size footnotesize
40345 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
40346 \end_layout
40347
40348 \begin_layout Standard
40349
40350 \size footnotesize
40351 \InsetSpace ~
40352 \InsetSpace ~
40353 mov dpl,_p
40354 \end_layout
40355
40356 \begin_layout Standard
40357
40358 \size footnotesize
40359 \InsetSpace ~
40360 \InsetSpace ~
40361 mov dph,(_p + 1)
40362 \end_layout
40363
40364 \begin_layout Standard
40365
40366 \size footnotesize
40367 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
40368 \end_layout
40369
40370 \begin_layout Standard
40371
40372 \size footnotesize
40373 \InsetSpace ~
40374 \InsetSpace ~
40375 mov a,#0x02
40376 \end_layout
40377
40378 \begin_layout Standard
40379
40380 \size footnotesize
40381 \InsetSpace ~
40382 \InsetSpace ~
40383 add a,_p
40384 \end_layout
40385
40386 \begin_layout Standard
40387
40388 \size footnotesize
40389 \InsetSpace ~
40390 \InsetSpace ~
40391 mov _p,a
40392 \end_layout
40393
40394 \begin_layout Standard
40395
40396 \size footnotesize
40397 \InsetSpace ~
40398 \InsetSpace ~
40399 clr a
40400 \end_layout
40401
40402 \begin_layout Standard
40403
40404 \size footnotesize
40405 \InsetSpace ~
40406 \InsetSpace ~
40407 addc a,(_p + 1)
40408 \end_layout
40409
40410 \begin_layout Standard
40411
40412 \size footnotesize
40413 \InsetSpace ~
40414 \InsetSpace ~
40415 mov (_p + 1),a
40416 \end_layout
40417
40418 \begin_layout Standard
40419
40420 \size footnotesize
40421 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
40422 \end_layout
40423
40424 \begin_layout Standard
40425
40426 \size footnotesize
40427 \InsetSpace ~
40428 \InsetSpace ~
40429 movx a,@dptr
40430 \end_layout
40431
40432 \begin_layout Standard
40433
40434 \size footnotesize
40435 \InsetSpace ~
40436 \InsetSpace ~
40437 mov r2,a
40438 \end_layout
40439
40440 \begin_layout Standard
40441
40442 \size footnotesize
40443 \InsetSpace ~
40444 \InsetSpace ~
40445 inc dptr
40446 \end_layout
40447
40448 \begin_layout Standard
40449
40450 \size footnotesize
40451 \InsetSpace ~
40452 \InsetSpace ~
40453 movx a,@dptr
40454 \end_layout
40455
40456 \begin_layout Standard
40457
40458 \size footnotesize
40459 \InsetSpace ~
40460 \InsetSpace ~
40461 mov r3,a
40462 \end_layout
40463
40464 \begin_layout Standard
40465
40466 \size footnotesize
40467 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
40468 \end_layout
40469
40470 \begin_layout Standard
40471
40472 \size footnotesize
40473 \InsetSpace ~
40474 \InsetSpace ~
40475 mov @r0,ar2
40476 \end_layout
40477
40478 \begin_layout Standard
40479
40480 \size footnotesize
40481 \InsetSpace ~
40482 \InsetSpace ~
40483 inc r0
40484 \end_layout
40485
40486 \begin_layout Standard
40487
40488 \size footnotesize
40489 \InsetSpace ~
40490 \InsetSpace ~
40491 mov @r0,ar3
40492 \end_layout
40493
40494 \begin_layout Standard
40495
40496 \size footnotesize
40497 ; iTemp6 [lr5:16]{_near * int}[r0] = 
40498 \end_layout
40499
40500 \begin_layout Standard
40501
40502 \size footnotesize
40503 ; iTemp6 [lr5:16]{_near * int}[r0] + 
40504 \end_layout
40505
40506 \begin_layout Standard
40507
40508 \size footnotesize
40509 ; 0x2 {short}
40510 \end_layout
40511
40512 \begin_layout Standard
40513
40514 \size footnotesize
40515 \InsetSpace ~
40516 \InsetSpace ~
40517 inc r0
40518 \end_layout
40519
40520 \begin_layout Standard
40521
40522 \size footnotesize
40523 ; goto _whilecontinue_0($1)
40524 \end_layout
40525
40526 \begin_layout Standard
40527
40528 \size footnotesize
40529 \InsetSpace ~
40530 \InsetSpace ~
40531 sjmp 00101$
40532 \end_layout
40533
40534 \begin_layout Standard
40535
40536 \size footnotesize
40537 ; _whilebreak_0($3) :
40538 \end_layout
40539
40540 \begin_layout Standard
40541
40542 \size footnotesize
40543 00103$:
40544 \end_layout
40545
40546 \begin_layout Standard
40547
40548 \size footnotesize
40549 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
40550 \end_layout
40551
40552 \begin_layout Standard
40553
40554 \size footnotesize
40555 \InsetSpace ~
40556 \InsetSpace ~
40557 mov r2,#0x00
40558 \end_layout
40559
40560 \begin_layout Standard
40561
40562 \size footnotesize
40563 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
40564 \end_layout
40565
40566 \begin_layout Standard
40567
40568 \size footnotesize
40569 \InsetSpace ~
40570 \InsetSpace ~
40571 mov r3,#0x00
40572 \end_layout
40573
40574 \begin_layout Standard
40575
40576 \size footnotesize
40577 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
40578 \end_layout
40579
40580 \begin_layout Standard
40581
40582 \size footnotesize
40583 \InsetSpace ~
40584 \InsetSpace ~
40585 mov r4,#0x00
40586 \end_layout
40587
40588 \begin_layout Standard
40589
40590 \size footnotesize
40591 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
40592 \end_layout
40593
40594 \begin_layout Standard
40595
40596 \size footnotesize
40597 \InsetSpace ~
40598 \InsetSpace ~
40599 mov r5,#0x0A
40600 \end_layout
40601
40602 \begin_layout Standard
40603
40604 \size footnotesize
40605 \InsetSpace ~
40606 \InsetSpace ~
40607 mov r6,#0x00
40608 \end_layout
40609
40610 \begin_layout Standard
40611
40612 \size footnotesize
40613 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
40614 \end_layout
40615
40616 \begin_layout Standard
40617
40618 \size footnotesize
40619 \InsetSpace ~
40620 \InsetSpace ~
40621 mov r7,#0x1E
40622 \end_layout
40623
40624 \begin_layout Standard
40625
40626 \size footnotesize
40627 \InsetSpace ~
40628 \InsetSpace ~
40629 mov r0,#0x00
40630 \end_layout
40631
40632 \begin_layout Standard
40633
40634 \size footnotesize
40635 ; _forcond_0($4) :
40636 \end_layout
40637
40638 \begin_layout Standard
40639
40640 \size footnotesize
40641 00104$:
40642 \end_layout
40643
40644 \begin_layout Standard
40645
40646 \size footnotesize
40647 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
40648 \end_layout
40649
40650 \begin_layout Standard
40651
40652 \size footnotesize
40653 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
40654 \end_layout
40655
40656 \begin_layout Standard
40657
40658 \size footnotesize
40659 \InsetSpace ~
40660 \InsetSpace ~
40661 clr c
40662 \end_layout
40663
40664 \begin_layout Standard
40665
40666 \size footnotesize
40667 \InsetSpace ~
40668 \InsetSpace ~
40669 mov a,r4
40670 \end_layout
40671
40672 \begin_layout Standard
40673
40674 \size footnotesize
40675 \InsetSpace ~
40676 \InsetSpace ~
40677 xrl a,#0x80
40678 \end_layout
40679
40680 \begin_layout Standard
40681
40682 \size footnotesize
40683 \InsetSpace ~
40684 \InsetSpace ~
40685 subb a,#0x8a
40686 \end_layout
40687
40688 \begin_layout Standard
40689
40690 \size footnotesize
40691 \InsetSpace ~
40692 \InsetSpace ~
40693 jnc 00107$
40694 \end_layout
40695
40696 \begin_layout Standard
40697
40698 \size footnotesize
40699 00115$:
40700 \end_layout
40701
40702 \begin_layout Standard
40703
40704 \size footnotesize
40705 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + 
40706 \end_layout
40707
40708 \begin_layout Standard
40709
40710 \size footnotesize
40711 ; iTemp21 [lr21:38]{short}[r4]
40712 \end_layout
40713
40714 \begin_layout Standard
40715
40716 \size footnotesize
40717 \InsetSpace ~
40718 \InsetSpace ~
40719 mov a,r4
40720 \end_layout
40721
40722 \begin_layout Standard
40723
40724 \size footnotesize
40725 \InsetSpace ~
40726 \InsetSpace ~
40727 add a,r2
40728 \end_layout
40729
40730 \begin_layout Standard
40731
40732 \size footnotesize
40733 \InsetSpace ~
40734 \InsetSpace ~
40735 mov r2,a
40736 \end_layout
40737
40738 \begin_layout Standard
40739
40740 \size footnotesize
40741 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
40742 \end_layout
40743
40744 \begin_layout Standard
40745
40746 \size footnotesize
40747 \InsetSpace ~
40748 \InsetSpace ~
40749 mov b,#0x03
40750 \end_layout
40751
40752 \begin_layout Standard
40753
40754 \size footnotesize
40755 \InsetSpace ~
40756 \InsetSpace ~
40757 mov a,r4
40758 \end_layout
40759
40760 \begin_layout Standard
40761
40762 \size footnotesize
40763 \InsetSpace ~
40764 \InsetSpace ~
40765 mul ab
40766 \end_layout
40767
40768 \begin_layout Standard
40769
40770 \size footnotesize
40771 \InsetSpace ~
40772 \InsetSpace ~
40773 mov r1,a
40774 \end_layout
40775
40776 \begin_layout Standard
40777
40778 \size footnotesize
40779 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + 
40780 \end_layout
40781
40782 \begin_layout Standard
40783
40784 \size footnotesize
40785 ; iTemp15 [lr29:30]{short}[r1]
40786 \end_layout
40787
40788 \begin_layout Standard
40789
40790 \size footnotesize
40791 \InsetSpace ~
40792 \InsetSpace ~
40793 add a,r3
40794 \end_layout
40795
40796 \begin_layout Standard
40797
40798 \size footnotesize
40799 \InsetSpace ~
40800 \InsetSpace ~
40801 mov r3,a
40802 \end_layout
40803
40804 \begin_layout Standard
40805
40806 \size footnotesize
40807 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
40808 \end_layout
40809
40810 \begin_layout Standard
40811
40812 \size footnotesize
40813 \InsetSpace ~
40814 \InsetSpace ~
40815 mov a,r7
40816 \end_layout
40817
40818 \begin_layout Standard
40819
40820 \size footnotesize
40821 \InsetSpace ~
40822 \InsetSpace ~
40823 add a,#0xfd
40824 \end_layout
40825
40826 \begin_layout Standard
40827
40828 \size footnotesize
40829 \InsetSpace ~
40830 \InsetSpace ~
40831 mov r7,a
40832 \end_layout
40833
40834 \begin_layout Standard
40835
40836 \size footnotesize
40837 \InsetSpace ~
40838 \InsetSpace ~
40839 mov a,r0
40840 \end_layout
40841
40842 \begin_layout Standard
40843
40844 \size footnotesize
40845 \InsetSpace ~
40846 \InsetSpace ~
40847 addc a,#0xff
40848 \end_layout
40849
40850 \begin_layout Standard
40851
40852 \size footnotesize
40853 \InsetSpace ~
40854 \InsetSpace ~
40855 mov r0,a
40856 \end_layout
40857
40858 \begin_layout Standard
40859
40860 \size footnotesize
40861 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
40862 \end_layout
40863
40864 \begin_layout Standard
40865
40866 \size footnotesize
40867 \InsetSpace ~
40868 \InsetSpace ~
40869 mov a,r7
40870 \end_layout
40871
40872 \begin_layout Standard
40873
40874 \size footnotesize
40875 \InsetSpace ~
40876 \InsetSpace ~
40877 add a,_gint
40878 \end_layout
40879
40880 \begin_layout Standard
40881
40882 \size footnotesize
40883 \InsetSpace ~
40884 \InsetSpace ~
40885 mov _gint,a
40886 \end_layout
40887
40888 \begin_layout Standard
40889
40890 \size footnotesize
40891 \InsetSpace ~
40892 \InsetSpace ~
40893 mov a,r0
40894 \end_layout
40895
40896 \begin_layout Standard
40897
40898 \size footnotesize
40899 \InsetSpace ~
40900 \InsetSpace ~
40901 addc a,(_gint + 1)
40902 \end_layout
40903
40904 \begin_layout Standard
40905
40906 \size footnotesize
40907 \InsetSpace ~
40908 \InsetSpace ~
40909 mov (_gint + 1),a
40910 \end_layout
40911
40912 \begin_layout Standard
40913
40914 \size footnotesize
40915 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
40916 \end_layout
40917
40918 \begin_layout Standard
40919
40920 \size footnotesize
40921 \InsetSpace ~
40922 \InsetSpace ~
40923 inc r4
40924 \end_layout
40925
40926 \begin_layout Standard
40927
40928 \size footnotesize
40929 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
40930 \end_layout
40931
40932 \begin_layout Standard
40933
40934 \size footnotesize
40935 \InsetSpace ~
40936 \InsetSpace ~
40937 dec r5
40938 \end_layout
40939
40940 \begin_layout Standard
40941
40942 \size footnotesize
40943 \InsetSpace ~
40944 \InsetSpace ~
40945 cjne r5,#0xff,00104$
40946 \end_layout
40947
40948 \begin_layout Standard
40949
40950 \size footnotesize
40951 \InsetSpace ~
40952 \InsetSpace ~
40953 dec r6
40954 \end_layout
40955
40956 \begin_layout Standard
40957
40958 \size footnotesize
40959 ; goto _forcond_0($4)
40960 \end_layout
40961
40962 \begin_layout Standard
40963
40964 \size footnotesize
40965 \InsetSpace ~
40966 \InsetSpace ~
40967 sjmp 00104$
40968 \end_layout
40969
40970 \begin_layout Standard
40971
40972 \size footnotesize
40973 ; _forbreak_0($7) :
40974 \end_layout
40975
40976 \begin_layout Standard
40977
40978 \size footnotesize
40979 00107$:
40980 \end_layout
40981
40982 \begin_layout Standard
40983
40984 \size footnotesize
40985 ; ret iTemp24 [lr40:41]{short}
40986 \end_layout
40987
40988 \begin_layout Standard
40989
40990 \size footnotesize
40991 \InsetSpace ~
40992 \InsetSpace ~
40993 mov a,r3
40994 \end_layout
40995
40996 \begin_layout Standard
40997
40998 \size footnotesize
40999 \InsetSpace ~
41000 \InsetSpace ~
41001 add a,r2
41002 \end_layout
41003
41004 \begin_layout Standard
41005
41006 \size footnotesize
41007 \InsetSpace ~
41008 \InsetSpace ~
41009 mov dpl,a
41010 \end_layout
41011
41012 \begin_layout Standard
41013
41014 \size footnotesize
41015 ; _return($8) :
41016 \end_layout
41017
41018 \begin_layout Standard
41019
41020 \size footnotesize
41021 00108$:
41022 \end_layout
41023
41024 \begin_layout Standard
41025
41026 \size footnotesize
41027 \InsetSpace ~
41028 \InsetSpace ~
41029 ret
41030 \newline
41031
41032 \end_layout
41033
41034 \begin_layout Section
41035 A few words about basic block successors, predecessors and dominators
41036 \end_layout
41037
41038 \begin_layout Standard
41039 Successors are basic blocks
41040 \begin_inset LatexCommand \index{Basic blocks}
41041
41042 \end_inset
41043
41044  that might execute after this basic block.
41045 \newline
41046 Predecessors are basic blocks
41047  that might execute before reaching this basic block.
41048 \newline
41049 Dominators are basic
41050  blocks that WILL execute before reaching this basic block.
41051 \newline
41052
41053 \end_layout
41054
41055 \begin_layout Standard
41056 [basic block 1]
41057 \end_layout
41058
41059 \begin_layout Standard
41060 if (something)
41061 \end_layout
41062
41063 \begin_layout Standard
41064 \InsetSpace ~
41065 \InsetSpace ~
41066 \InsetSpace ~
41067 \InsetSpace ~
41068 [basic block 2]
41069 \end_layout
41070
41071 \begin_layout Standard
41072 else
41073 \end_layout
41074
41075 \begin_layout Standard
41076 \InsetSpace ~
41077 \InsetSpace ~
41078 \InsetSpace ~
41079 \InsetSpace ~
41080 [basic block 3]
41081 \end_layout
41082
41083 \begin_layout Standard
41084 [basic block 4]
41085 \newline
41086
41087 \end_layout
41088
41089 \begin_layout Standard
41090 a) succList of [BB2] = [BB4], of [BB3] = [BB4], of [BB1] = [BB2,BB3]
41091 \end_layout
41092
41093 \begin_layout Standard
41094 b) predList of [BB2] = [BB1], of [BB3] = [BB1], of [BB4] = [BB2,BB3]
41095 \end_layout
41096
41097 \begin_layout Standard
41098 c) domVect of [BB4] = BB1 ...
41099  here we are not sure if BB2 or BB3 was executed but we are SURE that BB1
41100  was executed.
41101 \end_layout
41102
41103 \begin_layout Chapter
41104 Acknowledgments
41105 \end_layout
41106
41107 \begin_layout Standard
41108 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/#Who}
41109
41110 \end_inset
41111
41112
41113 \newline
41114
41115 \newline
41116
41117 \emph on
41118 Thanks to all the other volunteer developers who have helped with coding,
41119  testing, web-page creation, distribution sets, etc.
41120  You know who you are :-)
41121 \emph default
41122
41123 \newline
41124
41125 \newline
41126
41127 \emph on
41128 Thanks to Sourceforge 
41129 \begin_inset LatexCommand \url{http://www.sf.net}
41130
41131 \end_inset
41132
41133  which has hosted the project since 1999 and donates significant download
41134  bandwidth.
41135 \emph default
41136
41137 \newline
41138
41139 \newline
41140
41141 \emph on
41142 Also thanks to all SDCC Distributed Compile Farm members for donating CPU
41143  cycles and bandwidth for snapshot builds.
41144 \newline
41145
41146 \end_layout
41147
41148 \begin_layout Standard
41149 This document was initially written by Sandeep Dutta
41150 \end_layout
41151
41152 \begin_layout Standard
41153 All product names mentioned herein may be trademarks
41154 \begin_inset LatexCommand \index{Trademarks}
41155
41156 \end_inset
41157
41158  of their respective companies.
41159  
41160 \end_layout
41161
41162 \begin_layout Section*
41163 Alphabetical index
41164 \end_layout
41165
41166 \begin_layout Standard
41167 To avoid confusion, the installation and building options for SDCC itself
41168  (chapter 2) are not part of the index.
41169 \end_layout
41170
41171 \begin_layout Standard
41172 \begin_inset LatexCommand \printindex{}
41173
41174 \end_inset
41175
41176
41177 \end_layout
41178
41179 \end_body
41180 \end_document