* support/regression/tests/bug1057979.c:
[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.4
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 Itemize
1170 in versions older then 2.8.4 the pic16 *printf() and printf_tiny() library
1171  functions supported undocumented and not standard compliant 'b' binary
1172  format specifier ("%b", "%hb" and "%lb").
1173  The 'b' specifier is now disabled by default.
1174  It can be enabled by defining BINARY_SPECIFIER macro in files device/lib/pic16/
1175 libc/stdio/vfprintf.c and device/lib/pic16/libc/stdio/printf_tiny.c and recompilin
1176 g the library.
1177 \end_layout
1178
1179 \begin_layout Section
1180 System Requirements
1181 \end_layout
1182
1183 \begin_layout Standard
1184 What do you need before you start installation of SDCC? A computer, and
1185  a desire to compute.
1186  The preferred method of installation is to compile SDCC from source using
1187  GNU gcc and make.
1188  For Windows some pre-compiled binary distributions are available for your
1189  convenience.
1190  You should have some experience with command line tools and compiler use.
1191 \end_layout
1192
1193 \begin_layout Section
1194 Other Resources
1195 \end_layout
1196
1197 \begin_layout Standard
1198 The SDCC home page at 
1199 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/}
1200
1201 \end_inset
1202
1203  is a great place to find distribution sets.
1204  You can also find links to the user mailing lists that offer help or discuss
1205  SDCC with other SDCC users.
1206  Web links to other SDCC related sites can also be found here.
1207  This document can be found in the DOC directory of the source package as
1208  a text or HTML file.
1209  A pdf version of this document is available at 
1210 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
1211
1212 \end_inset
1213
1214 .
1215  Some of the other tools (simulator and assembler) included with SDCC contain
1216  their own documentation and can be found in the source distribution.
1217  If you want the latest unreleased software, the complete source package
1218  is available directly from Subversion on https://sdcc.svn.sourceforge.net/svnroot/
1219 sdcc/trunk/sdcc.
1220 \end_layout
1221
1222 \begin_layout Section
1223 Wishes for the future
1224 \end_layout
1225
1226 \begin_layout Standard
1227 There are (and always will be) some things that could be done.
1228  Here are some I can think of:
1229 \newline
1230
1231 \end_layout
1232
1233 \begin_layout Standard
1234
1235 \family typewriter
1236 char KernelFunction3(char p) at 0x340;
1237 \newline
1238
1239 \end_layout
1240
1241 \begin_layout Standard
1242
1243 \family typewriter
1244 better code banking
1245 \begin_inset LatexCommand \index{code banking (limited support)}
1246
1247 \end_inset
1248
1249  support for mcs51
1250 \newline
1251
1252 \newline
1253
1254 \family default
1255 If you can think of some more, please see the section 
1256 \begin_inset LatexCommand \ref{sub:Requesting-Features}
1257
1258 \end_inset
1259
1260  about filing feature requests
1261 \begin_inset LatexCommand \index{Requesting features}
1262
1263 \end_inset
1264
1265
1266 \begin_inset LatexCommand \index{Feature request}
1267
1268 \end_inset
1269
1270 .
1271 \newline
1272
1273 \end_layout
1274
1275 \begin_layout Chapter
1276 Installing SDCC
1277 \begin_inset LatexCommand \index{Installation}
1278
1279 \end_inset
1280
1281
1282 \end_layout
1283
1284 \begin_layout Standard
1285 For most users it is sufficient to skip to either section 
1286 \begin_inset LatexCommand \ref{sub:Building-SDCC-on-Linux}
1287
1288 \end_inset
1289
1290  (Unix) or section 
1291 \begin_inset LatexCommand \ref{sub:Windows-Install}
1292
1293 \end_inset
1294
1295  (Windows).
1296  More detailed instructions follow below.
1297 \end_layout
1298
1299 \begin_layout Section
1300 Configure Options
1301 \begin_inset LatexCommand \index{Options SDCC configuration}
1302
1303 \end_inset
1304
1305
1306 \end_layout
1307
1308 \begin_layout Standard
1309 The install paths, search paths and other options are defined when running
1310  'configure'.
1311  The defaults can be overridden by:
1312 \end_layout
1313
1314 \begin_layout List
1315 \labelwidthstring 00.00.0000
1316 -
1317 \begin_inset ERT
1318 status collapsed
1319
1320 \begin_layout Standard
1321
1322
1323 \backslash
1324 /
1325 \end_layout
1326
1327 \end_inset
1328
1329 -prefix see table below
1330 \end_layout
1331
1332 \begin_layout List
1333 \labelwidthstring 00.00.0000
1334 -
1335 \begin_inset ERT
1336 status collapsed
1337
1338 \begin_layout Standard
1339
1340
1341 \backslash
1342 /
1343 \end_layout
1344
1345 \end_inset
1346
1347 -exec_prefix see table below
1348 \end_layout
1349
1350 \begin_layout List
1351 \labelwidthstring 00.00.0000
1352 -
1353 \begin_inset ERT
1354 status collapsed
1355
1356 \begin_layout Standard
1357
1358
1359 \backslash
1360 /
1361 \end_layout
1362
1363 \end_inset
1364
1365 -bindir see table below
1366 \end_layout
1367
1368 \begin_layout List
1369 \labelwidthstring 00.00.0000
1370 -
1371 \begin_inset ERT
1372 status collapsed
1373
1374 \begin_layout Standard
1375
1376
1377 \backslash
1378 /
1379 \end_layout
1380
1381 \end_inset
1382
1383 -datadir see table below
1384 \end_layout
1385
1386 \begin_layout List
1387 \labelwidthstring 00.00.0000
1388 -
1389 \begin_inset ERT
1390 status collapsed
1391
1392 \begin_layout Standard
1393
1394
1395 \backslash
1396 /
1397 \end_layout
1398
1399 \end_inset
1400
1401 -datarootdir see table below
1402 \newline
1403
1404 \end_layout
1405
1406 \begin_layout List
1407 \labelwidthstring 00.00.0000
1408 \InsetSpace ~
1409 \InsetSpace ~
1410 docdir environment variable, see table below
1411 \end_layout
1412
1413 \begin_layout List
1414 \labelwidthstring 00.00.0000
1415 \InsetSpace ~
1416 \InsetSpace ~
1417 include_dir_suffix environment variable, see table below
1418 \end_layout
1419
1420 \begin_layout List
1421 \labelwidthstring 00.00.0000
1422 \InsetSpace ~
1423 \InsetSpace ~
1424 lib_dir_suffix environment variable, see table below
1425 \end_layout
1426
1427 \begin_layout List
1428 \labelwidthstring 00.00.0000
1429 \InsetSpace ~
1430 \InsetSpace ~
1431 sdccconf_h_dir_separator environment variable, either / or 
1432 \backslash
1433
1434 \backslash
1435  makes sense here.
1436  This character will only be used in sdccconf.h; don't forget it's a C-header,
1437  therefore a double-backslash is needed there.
1438 \newline
1439
1440 \end_layout
1441
1442 \begin_layout List
1443 \labelwidthstring 00.00.0000
1444 -
1445 \begin_inset ERT
1446 status collapsed
1447
1448 \begin_layout Standard
1449
1450
1451 \backslash
1452 /
1453 \end_layout
1454
1455 \end_inset
1456
1457 -disable-mcs51-port Excludes the Intel mcs51 port
1458 \end_layout
1459
1460 \begin_layout List
1461 \labelwidthstring 00.00.0000
1462 -
1463 \begin_inset ERT
1464 status collapsed
1465
1466 \begin_layout Standard
1467
1468
1469 \backslash
1470 /
1471 \end_layout
1472
1473 \end_inset
1474
1475 -disable-gbz80-port Excludes the Gameboy gbz80 port
1476 \end_layout
1477
1478 \begin_layout List
1479 \labelwidthstring 00.00.0000
1480 -
1481 \begin_inset ERT
1482 status collapsed
1483
1484 \begin_layout Standard
1485
1486
1487 \backslash
1488 /
1489 \end_layout
1490
1491 \end_inset
1492
1493 -disable-z80-port Excludes the z80 port
1494 \end_layout
1495
1496 \begin_layout List
1497 \labelwidthstring 00.00.0000
1498 -
1499 \begin_inset ERT
1500 status collapsed
1501
1502 \begin_layout Standard
1503
1504
1505 \backslash
1506 /
1507 \end_layout
1508
1509 \end_inset
1510
1511 -disable-avr-port Excludes the AVR port
1512 \end_layout
1513
1514 \begin_layout List
1515 \labelwidthstring 00.00.0000
1516 -
1517 \begin_inset ERT
1518 status collapsed
1519
1520 \begin_layout Standard
1521
1522
1523 \backslash
1524 /
1525 \end_layout
1526
1527 \end_inset
1528
1529 -disable-ds390-port Excludes the DS390 port
1530 \end_layout
1531
1532 \begin_layout List
1533 \labelwidthstring 00.00.0000
1534 -
1535 \begin_inset ERT
1536 status collapsed
1537
1538 \begin_layout Standard
1539
1540
1541 \backslash
1542 /
1543 \end_layout
1544
1545 \end_inset
1546
1547 -disable-hc08-port Excludes the HC08 port
1548 \end_layout
1549
1550 \begin_layout List
1551 \labelwidthstring 00.00.0000
1552 -
1553 \begin_inset ERT
1554 status collapsed
1555
1556 \begin_layout Standard
1557
1558
1559 \backslash
1560 /
1561 \end_layout
1562
1563 \end_inset
1564
1565 -disable-pic-port Excludes the PIC14 port
1566 \end_layout
1567
1568 \begin_layout List
1569 \labelwidthstring 00.00.0000
1570 -
1571 \begin_inset ERT
1572 status collapsed
1573
1574 \begin_layout Standard
1575
1576
1577 \backslash
1578 /
1579 \end_layout
1580
1581 \end_inset
1582
1583 -disable-pic16-port Excludes the PIC16 port
1584 \end_layout
1585
1586 \begin_layout List
1587 \labelwidthstring 00.00.0000
1588 -
1589 \begin_inset ERT
1590 status collapsed
1591
1592 \begin_layout Standard
1593
1594
1595 \backslash
1596 /
1597 \end_layout
1598
1599 \end_inset
1600
1601 -disable-xa51-port Excludes the XA51 port
1602 \end_layout
1603
1604 \begin_layout List
1605 \labelwidthstring 00.00.0000
1606 -
1607 \begin_inset ERT
1608 status collapsed
1609
1610 \begin_layout Standard
1611
1612
1613 \backslash
1614 /
1615 \end_layout
1616
1617 \end_inset
1618
1619 -disable-ucsim Disables configuring and building of ucsim
1620 \end_layout
1621
1622 \begin_layout List
1623 \labelwidthstring 00.00.0000
1624 -
1625 \begin_inset ERT
1626 status collapsed
1627
1628 \begin_layout Standard
1629
1630
1631 \backslash
1632 /
1633 \end_layout
1634
1635 \end_inset
1636
1637 -disable-device-lib Disables automatically building device libraries
1638 \end_layout
1639
1640 \begin_layout List
1641 \labelwidthstring 00.00.0000
1642 -
1643 \begin_inset ERT
1644 status collapsed
1645
1646 \begin_layout Standard
1647
1648
1649 \backslash
1650 /
1651 \end_layout
1652
1653 \end_inset
1654
1655 -disable-packihx Disables building packihx
1656 \newline
1657
1658 \end_layout
1659
1660 \begin_layout List
1661 \labelwidthstring 00.00.0000
1662 -
1663 \begin_inset ERT
1664 status collapsed
1665
1666 \begin_layout Standard
1667
1668
1669 \backslash
1670 /
1671 \end_layout
1672
1673 \end_inset
1674
1675 -enable-doc Build pdf, html and txt files from the lyx sources
1676 \end_layout
1677
1678 \begin_layout List
1679 \labelwidthstring 00.00.0000
1680 -
1681 \begin_inset ERT
1682 status collapsed
1683
1684 \begin_layout Standard
1685
1686
1687 \backslash
1688 /
1689 \end_layout
1690
1691 \end_inset
1692
1693 -enable-libgc Use the Bohem memory allocator.
1694  Lower runtime footprint.
1695 \end_layout
1696
1697 \begin_layout List
1698 \labelwidthstring 00.00.0000
1699 -
1700 \begin_inset ERT
1701 status collapsed
1702
1703 \begin_layout Standard
1704
1705
1706 \backslash
1707 /
1708 \end_layout
1709
1710 \end_inset
1711
1712 -without-ccache Do not use ccache even if available
1713 \end_layout
1714
1715 \begin_layout Standard
1716 Furthermore the environment variables CC, CFLAGS, ...
1717  the tools and their arguments can be influenced.
1718  Please see `configure -
1719 \begin_inset ERT
1720 status collapsed
1721
1722 \begin_layout Standard
1723
1724
1725 \backslash
1726 /
1727 \end_layout
1728
1729 \end_inset
1730
1731 -help' and the man/info pages of `configure' for details.
1732 \newline
1733
1734 \newline
1735 The names of the
1736  standard libraries STD_LIB, STD_INT_LIB, STD_LONG_LIB, STD_FP_LIB, STD_DS390_LI
1737 B, STD_XA51_LIB and the environment variables SDCC_DIR_NAME, SDCC_INCLUDE_NAME,
1738  SDCC_LIB_NAME are defined by `configure' too.
1739  At the moment it's not possible to change the default settings (it was
1740  simply never required).
1741 \newline
1742
1743 \newline
1744 These configure options are compiled into the binaries,
1745  and can only be changed by rerunning 'configure' and recompiling SDCC.
1746  The configure options are written in 
1747 \emph on
1748 italics
1749 \emph default
1750  to distinguish them from run time environment variables (see section search
1751  paths).
1752 \newline
1753
1754 \newline
1755 The settings for 
1756 \begin_inset Quotes sld
1757 \end_inset
1758
1759 Win32 builds
1760 \begin_inset Quotes srd
1761 \end_inset
1762
1763  are used by the SDCC team to build the official Win32 binaries.
1764  The SDCC team uses Mingw32 to build the official Windows binaries, because
1765  it's
1766 \end_layout
1767
1768 \begin_layout Enumerate
1769 open source, 
1770 \end_layout
1771
1772 \begin_layout Enumerate
1773 a gcc compiler and last but not least
1774 \end_layout
1775
1776 \begin_layout Enumerate
1777 the binaries can be built by cross compiling on SDCC Distributed Compile
1778  Farm.
1779 \end_layout
1780
1781 \begin_layout Standard
1782 See the examples, how to pass the Win32 settings to 'configure'.
1783  The other Win32 builds using Borland, VC or whatever don't use 'configure',
1784  but a header file sdcc_vc_in.h is the same as sdccconf.h built by 'configure'
1785  for Win32.
1786 \newline
1787
1788 \newline
1789 These defaults are:
1790 \newline
1791
1792 \end_layout
1793
1794 \begin_layout Standard
1795 \align center
1796 \begin_inset Tabular
1797 <lyxtabular version="3" rows="9" columns="3">
1798 <features>
1799 <column alignment="block" valignment="top" leftline="true" width="0in">
1800 <column alignment="block" valignment="top" leftline="true" width="0in">
1801 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1802 <row topline="true" bottomline="true">
1803 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1804 \begin_inset Text
1805
1806 \begin_layout Standard
1807 Variable
1808 \end_layout
1809
1810 \end_inset
1811 </cell>
1812 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1813 \begin_inset Text
1814
1815 \begin_layout Standard
1816 default
1817 \end_layout
1818
1819 \end_inset
1820 </cell>
1821 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1822 \begin_inset Text
1823
1824 \begin_layout Standard
1825 Win32 builds
1826 \end_layout
1827
1828 \end_inset
1829 </cell>
1830 </row>
1831 <row topline="true">
1832 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1833 \begin_inset Text
1834
1835 \begin_layout Standard
1836
1837 \emph on
1838 PREFIX
1839 \end_layout
1840
1841 \end_inset
1842 </cell>
1843 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1844 \begin_inset Text
1845
1846 \begin_layout Standard
1847 /usr/local
1848 \end_layout
1849
1850 \end_inset
1851 </cell>
1852 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1853 \begin_inset Text
1854
1855 \begin_layout Standard
1856
1857 \backslash
1858 sdcc
1859 \end_layout
1860
1861 \end_inset
1862 </cell>
1863 </row>
1864 <row topline="true">
1865 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1866 \begin_inset Text
1867
1868 \begin_layout Standard
1869
1870 \emph on
1871 EXEC_PREFIX
1872 \end_layout
1873
1874 \end_inset
1875 </cell>
1876 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1877 \begin_inset Text
1878
1879 \begin_layout Standard
1880
1881 \emph on
1882 $PREFIX
1883 \end_layout
1884
1885 \end_inset
1886 </cell>
1887 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1888 \begin_inset Text
1889
1890 \begin_layout Standard
1891
1892 \emph on
1893 $PREFIX
1894 \end_layout
1895
1896 \end_inset
1897 </cell>
1898 </row>
1899 <row topline="true">
1900 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1901 \begin_inset Text
1902
1903 \begin_layout Standard
1904
1905 \emph on
1906 BINDIR
1907 \end_layout
1908
1909 \end_inset
1910 </cell>
1911 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1912 \begin_inset Text
1913
1914 \begin_layout Standard
1915
1916 \emph on
1917 $EXEC_PREFIX
1918 \emph default
1919 /bin
1920 \end_layout
1921
1922 \end_inset
1923 </cell>
1924 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1925 \begin_inset Text
1926
1927 \begin_layout Standard
1928
1929 \emph on
1930 $EXEC_PREFIX
1931 \emph default
1932
1933 \backslash
1934 bin
1935 \end_layout
1936
1937 \end_inset
1938 </cell>
1939 </row>
1940 <row topline="true">
1941 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1942 \begin_inset Text
1943
1944 \begin_layout Standard
1945
1946 \emph on
1947 DATADIR
1948 \end_layout
1949
1950 \end_inset
1951 </cell>
1952 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1953 \begin_inset Text
1954
1955 \begin_layout Standard
1956
1957 \emph on
1958 $DATAROOTDIR
1959 \end_layout
1960
1961 \end_inset
1962 </cell>
1963 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1964 \begin_inset Text
1965
1966 \begin_layout Standard
1967
1968 \emph on
1969 $DATAROOTDIR
1970 \end_layout
1971
1972 \end_inset
1973 </cell>
1974 </row>
1975 <row topline="true">
1976 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1977 \begin_inset Text
1978
1979 \begin_layout Standard
1980
1981 \emph on
1982 DATAROOTDIR
1983 \end_layout
1984
1985 \end_inset
1986 </cell>
1987 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1988 \begin_inset Text
1989
1990 \begin_layout Standard
1991
1992 \emph on
1993 $PREFIX
1994 \emph default
1995 /share
1996 \end_layout
1997
1998 \end_inset
1999 </cell>
2000 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2001 \begin_inset Text
2002
2003 \begin_layout Standard
2004
2005 \emph on
2006 $PREFIX
2007 \end_layout
2008
2009 \end_inset
2010 </cell>
2011 </row>
2012 <row topline="true">
2013 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2014 \begin_inset Text
2015
2016 \begin_layout Standard
2017
2018 \emph on
2019 DOCDIR
2020 \end_layout
2021
2022 \end_inset
2023 </cell>
2024 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2025 \begin_inset Text
2026
2027 \begin_layout Standard
2028
2029 \emph on
2030 $DATAROOTDIR
2031 \emph default
2032 /sdcc/doc
2033 \end_layout
2034
2035 \end_inset
2036 </cell>
2037 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2038 \begin_inset Text
2039
2040 \begin_layout Standard
2041
2042 \emph on
2043 $DATAROOTDIR
2044 \emph default
2045
2046 \backslash
2047 doc
2048 \end_layout
2049
2050 \end_inset
2051 </cell>
2052 </row>
2053 <row topline="true">
2054 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2055 \begin_inset Text
2056
2057 \begin_layout Standard
2058
2059 \emph on
2060 INCLUDE_DIR_SUFFIX
2061 \end_layout
2062
2063 \end_inset
2064 </cell>
2065 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2066 \begin_inset Text
2067
2068 \begin_layout Standard
2069 sdcc/include
2070 \end_layout
2071
2072 \end_inset
2073 </cell>
2074 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2075 \begin_inset Text
2076
2077 \begin_layout Standard
2078 include
2079 \end_layout
2080
2081 \end_inset
2082 </cell>
2083 </row>
2084 <row topline="true" bottomline="true">
2085 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2086 \begin_inset Text
2087
2088 \begin_layout Standard
2089
2090 \emph on
2091 LIB_DIR_SUFFIX
2092 \end_layout
2093
2094 \end_inset
2095 </cell>
2096 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2097 \begin_inset Text
2098
2099 \begin_layout Standard
2100 sdcc/lib
2101 \end_layout
2102
2103 \end_inset
2104 </cell>
2105 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2106 \begin_inset Text
2107
2108 \begin_layout Standard
2109 lib
2110 \end_layout
2111
2112 \end_inset
2113 </cell>
2114 </row>
2115 </lyxtabular>
2116
2117 \end_inset
2118
2119
2120 \newline
2121
2122 \end_layout
2123
2124 \begin_layout Standard
2125 \noindent
2126 'configure' also computes relative paths.
2127  This is needed for full relocatability of a binary package and to complete
2128  search paths (see section search paths below):
2129 \newline
2130  
2131 \end_layout
2132
2133 \begin_layout Standard
2134 \align center
2135 \begin_inset Tabular
2136 <lyxtabular version="3" rows="4" columns="3">
2137 <features>
2138 <column alignment="block" valignment="top" leftline="true" width="0in">
2139 <column alignment="block" valignment="top" leftline="true" width="0in">
2140 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
2141 <row topline="true" bottomline="true">
2142 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2143 \begin_inset Text
2144
2145 \begin_layout Standard
2146 Variable (computed)
2147 \end_layout
2148
2149 \end_inset
2150 </cell>
2151 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2152 \begin_inset Text
2153
2154 \begin_layout Standard
2155 default
2156 \end_layout
2157
2158 \end_inset
2159 </cell>
2160 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2161 \begin_inset Text
2162
2163 \begin_layout Standard
2164 Win32 builds
2165 \end_layout
2166
2167 \end_inset
2168 </cell>
2169 </row>
2170 <row topline="true" bottomline="true">
2171 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2172 \begin_inset Text
2173
2174 \begin_layout Standard
2175
2176 \emph on
2177 BIN2DATA_DIR
2178 \end_layout
2179
2180 \end_inset
2181 </cell>
2182 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2183 \begin_inset Text
2184
2185 \begin_layout Standard
2186 ../share
2187 \end_layout
2188
2189 \end_inset
2190 </cell>
2191 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2192 \begin_inset Text
2193
2194 \begin_layout Standard
2195 ..
2196 \end_layout
2197
2198 \end_inset
2199 </cell>
2200 </row>
2201 <row bottomline="true">
2202 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2203 \begin_inset Text
2204
2205 \begin_layout Standard
2206
2207 \emph on
2208 PREFIX2BIN_DIR
2209 \end_layout
2210
2211 \end_inset
2212 </cell>
2213 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2214 \begin_inset Text
2215
2216 \begin_layout Standard
2217 bin
2218 \end_layout
2219
2220 \end_inset
2221 </cell>
2222 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2223 \begin_inset Text
2224
2225 \begin_layout Standard
2226 bin
2227 \end_layout
2228
2229 \end_inset
2230 </cell>
2231 </row>
2232 <row bottomline="true">
2233 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2234 \begin_inset Text
2235
2236 \begin_layout Standard
2237
2238 \emph on
2239 PREFIX2DATA_DIR
2240 \end_layout
2241
2242 \end_inset
2243 </cell>
2244 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2245 \begin_inset Text
2246
2247 \begin_layout Standard
2248 share/sdcc
2249 \end_layout
2250
2251 \end_inset
2252 </cell>
2253 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2254 \begin_inset Text
2255
2256 \begin_layout Standard
2257
2258 \end_layout
2259
2260 \end_inset
2261 </cell>
2262 </row>
2263 </lyxtabular>
2264
2265 \end_inset
2266
2267
2268 \newline
2269
2270 \end_layout
2271
2272 \begin_layout Standard
2273 \noindent
2274 Examples:
2275 \end_layout
2276
2277 \begin_layout LyX-Code
2278 ./configure
2279 \newline
2280 ./configure -
2281 \begin_inset ERT
2282 status collapsed
2283
2284 \begin_layout Standard
2285
2286
2287 \backslash
2288 /
2289 \end_layout
2290
2291 \end_inset
2292
2293 -prefix=
2294 \begin_inset Quotes srd
2295 \end_inset
2296
2297 /usr/bin
2298 \begin_inset Quotes srd
2299 \end_inset
2300
2301  -
2302 \begin_inset ERT
2303 status collapsed
2304
2305 \begin_layout Standard
2306
2307
2308 \backslash
2309 /
2310 \end_layout
2311
2312 \end_inset
2313
2314 -datarootdir=
2315 \begin_inset Quotes srd
2316 \end_inset
2317
2318 /usr/share
2319 \begin_inset Quotes srd
2320 \end_inset
2321
2322
2323 \newline
2324 ./configure -
2325 \begin_inset ERT
2326 status collapsed
2327
2328 \begin_layout Standard
2329
2330
2331 \backslash
2332 /
2333 \end_layout
2334
2335 \end_inset
2336
2337 -disable-avr-port -
2338 \begin_inset ERT
2339 status collapsed
2340
2341 \begin_layout Standard
2342
2343
2344 \backslash
2345 /
2346 \end_layout
2347
2348 \end_inset
2349
2350 -disable-xa51-port
2351 \end_layout
2352
2353 \begin_layout Standard
2354 To cross compile on linux for Mingw32 (see also 'sdcc/support/scripts/sdcc_mingw
2355 32'):
2356 \end_layout
2357
2358 \begin_layout LyX-Code
2359 ./configure 
2360 \backslash
2361
2362 \newline
2363 CC=
2364 \begin_inset Quotes srd
2365 \end_inset
2366
2367 i586-mingw32msvc-gcc
2368 \begin_inset Quotes srd
2369 \end_inset
2370
2371  CXX=
2372 \begin_inset Quotes srd
2373 \end_inset
2374
2375 i586-mingw32msvc-g++
2376 \begin_inset Quotes srd
2377 \end_inset
2378
2379  
2380 \backslash
2381  
2382 \newline
2383 RANLIB=
2384 \begin_inset Quotes srd
2385 \end_inset
2386
2387 i586-mingw32msvc-ranlib
2388 \begin_inset Quotes srd
2389 \end_inset
2390
2391  
2392 \backslash
2393
2394 \newline
2395 STRIP=
2396 \begin_inset Quotes srd
2397 \end_inset
2398
2399 i586-mingw32msvc-strip
2400 \begin_inset Quotes srd
2401 \end_inset
2402
2403  
2404 \backslash
2405
2406 \newline
2407 -
2408 \begin_inset ERT
2409 status collapsed
2410
2411 \begin_layout Standard
2412
2413
2414 \backslash
2415 /
2416 \end_layout
2417
2418 \end_inset
2419
2420 -prefix=
2421 \begin_inset Quotes srd
2422 \end_inset
2423
2424 /sdcc
2425 \begin_inset Quotes srd
2426 \end_inset
2427
2428  
2429 \backslash
2430
2431 \newline
2432 -
2433 \begin_inset ERT
2434 status collapsed
2435
2436 \begin_layout Standard
2437
2438
2439 \backslash
2440 /
2441 \end_layout
2442
2443 \end_inset
2444
2445 -datarootdir=
2446 \begin_inset Quotes srd
2447 \end_inset
2448
2449 /sdcc
2450 \begin_inset Quotes srd
2451 \end_inset
2452
2453  
2454 \backslash
2455
2456 \newline
2457 docdir=
2458 \begin_inset Quotes srd
2459 \end_inset
2460
2461
2462 \backslash
2463 ${datarootdir}/doc
2464 \begin_inset Quotes srd
2465 \end_inset
2466
2467  
2468 \backslash
2469
2470 \newline
2471 include_dir_suffix=
2472 \begin_inset Quotes srd
2473 \end_inset
2474
2475 include
2476 \begin_inset Quotes srd
2477 \end_inset
2478
2479  
2480 \backslash
2481
2482 \newline
2483 lib_dir_suffix=
2484 \begin_inset Quotes srd
2485 \end_inset
2486
2487 lib
2488 \begin_inset Quotes srd
2489 \end_inset
2490
2491  
2492 \backslash
2493
2494 \newline
2495 sdccconf_h_dir_separator=
2496 \begin_inset Quotes srd
2497 \end_inset
2498
2499
2500 \backslash
2501
2502 \backslash
2503
2504 \backslash
2505
2506 \backslash
2507
2508 \begin_inset Quotes srd
2509 \end_inset
2510
2511  
2512 \backslash
2513
2514 \newline
2515 -
2516 \begin_inset ERT
2517 status collapsed
2518
2519 \begin_layout Standard
2520
2521
2522 \backslash
2523 /
2524 \end_layout
2525
2526 \end_inset
2527
2528 -disable-device-lib
2529 \backslash
2530
2531 \newline
2532 -
2533 \begin_inset ERT
2534 status collapsed
2535
2536 \begin_layout Standard
2537
2538
2539 \backslash
2540 /
2541 \end_layout
2542
2543 \end_inset
2544
2545 -host=i586-mingw32msvc
2546 \backslash
2547
2548 \newline
2549 -
2550 \begin_inset ERT
2551 status collapsed
2552
2553 \begin_layout Standard
2554
2555
2556 \backslash
2557 /
2558 \end_layout
2559
2560 \end_inset
2561
2562 -build=unknown-unknown-linux-gnu
2563 \end_layout
2564
2565 \begin_layout Standard
2566 To 
2567 \begin_inset Quotes sld
2568 \end_inset
2569
2570 cross
2571 \begin_inset Quotes srd
2572 \end_inset
2573
2574 compile on Cygwin for Mingw32 (see also sdcc/support/scripts/sdcc_cygwin_mingw32
2575 ):
2576 \end_layout
2577
2578 \begin_layout LyX-Code
2579 ./configure -C 
2580 \backslash
2581
2582 \newline
2583 -
2584 \begin_inset ERT
2585 status collapsed
2586
2587 \begin_layout Standard
2588
2589
2590 \backslash
2591 /
2592 \end_layout
2593
2594 \end_inset
2595
2596 -prefix=
2597 \begin_inset Quotes srd
2598 \end_inset
2599
2600 /sdcc
2601 \begin_inset Quotes srd
2602 \end_inset
2603
2604  
2605 \backslash
2606
2607 \newline
2608 -
2609 \begin_inset ERT
2610 status collapsed
2611
2612 \begin_layout Standard
2613
2614
2615 \backslash
2616 /
2617 \end_layout
2618
2619 \end_inset
2620
2621 -datarootdir=
2622 \begin_inset Quotes srd
2623 \end_inset
2624
2625 /sdcc
2626 \begin_inset Quotes srd
2627 \end_inset
2628
2629  
2630 \backslash
2631
2632 \newline
2633 docdir=
2634 \begin_inset Quotes srd
2635 \end_inset
2636
2637
2638 \backslash
2639 ${datarootdir}/doc
2640 \begin_inset Quotes srd
2641 \end_inset
2642
2643  
2644 \backslash
2645  
2646 \newline
2647 include_dir_suffix=
2648 \begin_inset Quotes srd
2649 \end_inset
2650
2651 include
2652 \begin_inset Quotes srd
2653 \end_inset
2654
2655  
2656 \backslash
2657
2658 \newline
2659 lib_dir_suffix=
2660 \begin_inset Quotes srd
2661 \end_inset
2662
2663 lib
2664 \begin_inset Quotes srd
2665 \end_inset
2666
2667  
2668 \backslash
2669
2670 \newline
2671 sdccconf_h_dir_separator=
2672 \begin_inset Quotes srd
2673 \end_inset
2674
2675
2676 \backslash
2677
2678 \backslash
2679
2680 \backslash
2681
2682 \backslash
2683
2684 \begin_inset Quotes srd
2685 \end_inset
2686
2687  
2688 \backslash
2689
2690 \newline
2691 CC=
2692 \begin_inset Quotes srd
2693 \end_inset
2694
2695 gcc -mno-cygwin
2696 \begin_inset Quotes srd
2697 \end_inset
2698
2699  
2700 \backslash
2701
2702 \newline
2703 CXX=
2704 \begin_inset Quotes srd
2705 \end_inset
2706
2707 g++ -mno-cygwin
2708 \begin_inset Quotes srd
2709 \end_inset
2710
2711  
2712 \end_layout
2713
2714 \begin_layout Standard
2715 'configure' is quite slow on Cygwin (at least on windows before Win2000/XP).
2716  The option '-
2717 \begin_inset ERT
2718 status collapsed
2719
2720 \begin_layout Standard
2721
2722
2723 \backslash
2724 /
2725 \end_layout
2726
2727 \end_inset
2728
2729 -C' turns on caching, which gives a little bit extra speed.
2730  However if options are changed, it can be necessary to delete the config.cache
2731  file.
2732 \end_layout
2733
2734 \begin_layout Section
2735 Install paths
2736 \begin_inset LatexCommand \label{sub:Install-paths}
2737
2738 \end_inset
2739
2740
2741 \begin_inset LatexCommand \index{Install paths}
2742
2743 \end_inset
2744
2745
2746 \end_layout
2747
2748 \begin_layout Standard
2749 \begin_inset VSpace medskip
2750 \end_inset
2751
2752
2753 \end_layout
2754
2755 \begin_layout Standard
2756 \align center
2757 \begin_inset Tabular
2758 <lyxtabular version="3" rows="5" columns="4">
2759 <features>
2760 <column alignment="left" valignment="top" leftline="true" width="0">
2761 <column alignment="left" valignment="top" leftline="true" width="0">
2762 <column alignment="left" valignment="top" leftline="true" width="0">
2763 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
2764 <row topline="true" bottomline="true">
2765 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2766 \begin_inset Text
2767
2768 \begin_layout Standard
2769
2770 \series bold
2771 Description
2772 \end_layout
2773
2774 \end_inset
2775 </cell>
2776 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2777 \begin_inset Text
2778
2779 \begin_layout Standard
2780
2781 \series bold
2782 Path
2783 \end_layout
2784
2785 \end_inset
2786 </cell>
2787 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2788 \begin_inset Text
2789
2790 \begin_layout Standard
2791
2792 \series bold
2793 Default
2794 \end_layout
2795
2796 \end_inset
2797 </cell>
2798 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2799 \begin_inset Text
2800
2801 \begin_layout Standard
2802
2803 \series bold
2804 Win32 builds
2805 \end_layout
2806
2807 \end_inset
2808 </cell>
2809 </row>
2810 <row topline="true">
2811 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2812 \begin_inset Text
2813
2814 \begin_layout Standard
2815 Binary files*
2816 \end_layout
2817
2818 \end_inset
2819 </cell>
2820 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2821 \begin_inset Text
2822
2823 \begin_layout Standard
2824
2825 \emph on
2826 $EXEC_PREFIX
2827 \end_layout
2828
2829 \end_inset
2830 </cell>
2831 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2832 \begin_inset Text
2833
2834 \begin_layout Standard
2835 /usr/local/bin
2836 \end_layout
2837
2838 \end_inset
2839 </cell>
2840 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2841 \begin_inset Text
2842
2843 \begin_layout Standard
2844
2845 \backslash
2846 sdcc
2847 \backslash
2848 bin
2849 \end_layout
2850
2851 \end_inset
2852 </cell>
2853 </row>
2854 <row topline="true">
2855 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2856 \begin_inset Text
2857
2858 \begin_layout Standard
2859 Include files
2860 \end_layout
2861
2862 \end_inset
2863 </cell>
2864 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2865 \begin_inset Text
2866
2867 \begin_layout Standard
2868
2869 \emph on
2870 $DATADIR/ $INCLUDE_DIR_SUFFIX
2871 \end_layout
2872
2873 \end_inset
2874 </cell>
2875 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2876 \begin_inset Text
2877
2878 \begin_layout Standard
2879 /usr/local/share/sdcc/include
2880 \end_layout
2881
2882 \end_inset
2883 </cell>
2884 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2885 \begin_inset Text
2886
2887 \begin_layout Standard
2888
2889 \backslash
2890 sdcc
2891 \backslash
2892 include
2893 \end_layout
2894
2895 \end_inset
2896 </cell>
2897 </row>
2898 <row topline="true">
2899 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2900 \begin_inset Text
2901
2902 \begin_layout Standard
2903 Library file**
2904 \end_layout
2905
2906 \end_inset
2907 </cell>
2908 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2909 \begin_inset Text
2910
2911 \begin_layout Standard
2912
2913 \emph on
2914 $DATADIR/$LIB_DIR_SUFFIX
2915 \end_layout
2916
2917 \end_inset
2918 </cell>
2919 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2920 \begin_inset Text
2921
2922 \begin_layout Standard
2923 /usr/local/share/sdcc/lib
2924 \end_layout
2925
2926 \end_inset
2927 </cell>
2928 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2929 \begin_inset Text
2930
2931 \begin_layout Standard
2932
2933 \backslash
2934 sdcc
2935 \backslash
2936 lib
2937 \end_layout
2938
2939 \end_inset
2940 </cell>
2941 </row>
2942 <row topline="true" bottomline="true">
2943 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2944 \begin_inset Text
2945
2946 \begin_layout Standard
2947 Documentation
2948 \end_layout
2949
2950 \end_inset
2951 </cell>
2952 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2953 \begin_inset Text
2954
2955 \begin_layout Standard
2956
2957 \emph on
2958 $DOCDIR
2959 \end_layout
2960
2961 \end_inset
2962 </cell>
2963 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2964 \begin_inset Text
2965
2966 \begin_layout Standard
2967 /usr/local/share/sdcc/doc
2968 \end_layout
2969
2970 \end_inset
2971 </cell>
2972 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2973 \begin_inset Text
2974
2975 \begin_layout Standard
2976
2977 \backslash
2978 sdcc
2979 \backslash
2980 doc
2981 \end_layout
2982
2983 \end_inset
2984 </cell>
2985 </row>
2986 </lyxtabular>
2987
2988 \end_inset
2989
2990
2991 \end_layout
2992
2993 \begin_layout Verse
2994
2995 \size footnotesize
2996 *compiler, preprocessor, assembler, and linker
2997 \newline
2998 **the 
2999 \shape italic
3000 model
3001 \shape default
3002  is auto-appended by the compiler, e.g.
3003  small, large, z80, ds390 etc
3004 \end_layout
3005
3006 \begin_layout Standard
3007 \noindent
3008 The install paths can still be changed during `make install' with e.g.:
3009 \end_layout
3010
3011 \begin_layout LyX-Code
3012 make install prefix=$(HOME)/local/sdcc
3013 \end_layout
3014
3015 \begin_layout Standard
3016 Of course this doesn't change the search paths compiled into the binaries.
3017 \newline
3018
3019 \newline
3020 Moreove
3021 r the install path can be changed by defining DESTDIR
3022 \begin_inset LatexCommand \index{DESTDIR}
3023
3024 \end_inset
3025
3026 :
3027 \end_layout
3028
3029 \begin_layout LyX-Code
3030 make install DESTDIR=$(HOME)/sdcc.rpm/
3031 \end_layout
3032
3033 \begin_layout Standard
3034 Please note that DESTDIR must have a trailing slash!
3035 \end_layout
3036
3037 \begin_layout Section
3038 Search Paths
3039 \begin_inset LatexCommand \label{sub:Search-Paths}
3040
3041 \end_inset
3042
3043
3044 \begin_inset LatexCommand \index{Search path}
3045
3046 \end_inset
3047
3048
3049 \end_layout
3050
3051 \begin_layout Standard
3052 Some search paths or parts of them are determined by configure variables
3053  (in 
3054 \emph on
3055 italics
3056 \emph default
3057 , see section above).
3058  Further search paths are determined by environment variables during runtime.
3059  
3060 \newline
3061 The paths searched when running the compiler are as follows (the first
3062  catch wins):
3063 \newline
3064
3065 \newline
3066 1.
3067  Binary files (preprocessor, assembler and linker)
3068 \newline
3069
3070 \end_layout
3071
3072 \begin_layout Standard
3073 \align center
3074 \begin_inset Tabular
3075 <lyxtabular version="3" rows="4" columns="3">
3076 <features>
3077 <column alignment="block" valignment="top" leftline="true" width="0in">
3078 <column alignment="block" valignment="top" leftline="true" width="0in">
3079 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
3080 <row topline="true" bottomline="true">
3081 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3082 \begin_inset Text
3083
3084 \begin_layout Standard
3085 Search path
3086 \end_layout
3087
3088 \end_inset
3089 </cell>
3090 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3091 \begin_inset Text
3092
3093 \begin_layout Standard
3094 default
3095 \end_layout
3096
3097 \end_inset
3098 </cell>
3099 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3100 \begin_inset Text
3101
3102 \begin_layout Standard
3103 Win32 builds
3104 \end_layout
3105
3106 \end_inset
3107 </cell>
3108 </row>
3109 <row topline="true">
3110 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3111 \begin_inset Text
3112
3113 \begin_layout Standard
3114 $SDCC_HOME/
3115 \emph on
3116 $PPREFIX2BIN_DIR
3117 \end_layout
3118
3119 \end_inset
3120 </cell>
3121 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3122 \begin_inset Text
3123
3124 \begin_layout Standard
3125 $SDCC_HOME/bin
3126 \end_layout
3127
3128 \end_inset
3129 </cell>
3130 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3131 \begin_inset Text
3132
3133 \begin_layout Standard
3134 $SDCC_HOME
3135 \backslash
3136 bin
3137 \end_layout
3138
3139 \end_inset
3140 </cell>
3141 </row>
3142 <row topline="true">
3143 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3144 \begin_inset Text
3145
3146 \begin_layout Standard
3147 Path of argv[0] (if available)
3148 \end_layout
3149
3150 \end_inset
3151 </cell>
3152 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3153 \begin_inset Text
3154
3155 \begin_layout Standard
3156 Path of argv[0]
3157 \end_layout
3158
3159 \end_inset
3160 </cell>
3161 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3162 \begin_inset Text
3163
3164 \begin_layout Standard
3165 Path of argv[0]
3166 \end_layout
3167
3168 \end_inset
3169 </cell>
3170 </row>
3171 <row topline="true" bottomline="true">
3172 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3173 \begin_inset Text
3174
3175 \begin_layout Standard
3176 $PATH
3177 \end_layout
3178
3179 \end_inset
3180 </cell>
3181 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3182 \begin_inset Text
3183
3184 \begin_layout Standard
3185 $PATH
3186 \end_layout
3187
3188 \end_inset
3189 </cell>
3190 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3191 \begin_inset Text
3192
3193 \begin_layout Standard
3194 $PATH
3195 \end_layout
3196
3197 \end_inset
3198 </cell>
3199 </row>
3200 </lyxtabular>
3201
3202 \end_inset
3203
3204  
3205 \newline
3206
3207 \end_layout
3208
3209 \begin_layout Standard
3210 \noindent
3211 2.
3212  Include files
3213 \newline
3214
3215 \end_layout
3216
3217 \begin_layout Standard
3218 \align center
3219 \begin_inset Tabular
3220 <lyxtabular version="3" rows="6" columns="3">
3221 <features>
3222 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3223 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3224 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
3225 <row topline="true" bottomline="true">
3226 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3227 \begin_inset Text
3228
3229 \begin_layout Standard
3230 Search path
3231 \end_layout
3232
3233 \end_inset
3234 </cell>
3235 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3236 \begin_inset Text
3237
3238 \begin_layout Standard
3239 default
3240 \end_layout
3241
3242 \end_inset
3243 </cell>
3244 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3245 \begin_inset Text
3246
3247 \begin_layout Standard
3248 Win32 builds
3249 \end_layout
3250
3251 \end_inset
3252 </cell>
3253 </row>
3254 <row topline="true">
3255 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3256 \begin_inset Text
3257
3258 \begin_layout Standard
3259 -
3260 \begin_inset ERT
3261 status collapsed
3262
3263 \begin_layout Standard
3264
3265
3266 \backslash
3267 /
3268 \end_layout
3269
3270 \end_inset
3271
3272 -I dir
3273 \end_layout
3274
3275 \end_inset
3276 </cell>
3277 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3278 \begin_inset Text
3279
3280 \begin_layout Standard
3281 -
3282 \begin_inset ERT
3283 status collapsed
3284
3285 \begin_layout Standard
3286
3287
3288 \backslash
3289 /
3290 \end_layout
3291
3292 \end_inset
3293
3294 -I dir
3295 \end_layout
3296
3297 \end_inset
3298 </cell>
3299 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3300 \begin_inset Text
3301
3302 \begin_layout Standard
3303 -
3304 \begin_inset ERT
3305 status collapsed
3306
3307 \begin_layout Standard
3308
3309
3310 \backslash
3311 /
3312 \end_layout
3313
3314 \end_inset
3315
3316 -I dir
3317 \end_layout
3318
3319 \end_inset
3320 </cell>
3321 </row>
3322 <row topline="true">
3323 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3324 \begin_inset Text
3325
3326 \begin_layout Standard
3327 $SDCC_INCLUDE
3328 \end_layout
3329
3330 \end_inset
3331 </cell>
3332 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3333 \begin_inset Text
3334
3335 \begin_layout Standard
3336 $SDCC_INCLUDE
3337 \end_layout
3338
3339 \end_inset
3340 </cell>
3341 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3342 \begin_inset Text
3343
3344 \begin_layout Standard
3345 $SDCC_INCLUDE
3346 \end_layout
3347
3348 \end_inset
3349 </cell>
3350 </row>
3351 <row topline="true">
3352 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3353 \begin_inset Text
3354
3355 \begin_layout Standard
3356 $SDCC_HOME/
3357 \newline
3358
3359 \emph on
3360 $PREFIX2DATA_DIR/
3361 \newline
3362 $INCLUDE_DIR_SUFFIX
3363 \end_layout
3364
3365 \end_inset
3366 </cell>
3367 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3368 \begin_inset Text
3369
3370 \begin_layout Standard
3371 $SDCC_ HOME/
3372 \newline
3373 share/sdcc/
3374 \newline
3375 include
3376 \end_layout
3377
3378 \end_inset
3379 </cell>
3380 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3381 \begin_inset Text
3382
3383 \begin_layout Standard
3384 $SDCC_HOME
3385 \backslash
3386 include
3387 \end_layout
3388
3389 \end_inset
3390 </cell>
3391 </row>
3392 <row topline="true">
3393 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3394 \begin_inset Text
3395
3396 \begin_layout Standard
3397 path(argv[0])/
3398 \newline
3399
3400 \emph on
3401 $BIN2DATADIR/
3402 \emph default
3403
3404 \newline
3405
3406 \emph on
3407 $INCLUDE_DIR_SUFFIX
3408 \end_layout
3409
3410 \end_inset
3411 </cell>
3412 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3413 \begin_inset Text
3414
3415 \begin_layout Standard
3416 path(argv[0])/
3417 \newline
3418 ../sdcc/include
3419 \newline
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 \InsetSpace ~
3455 \InsetSpace ~
3456 \InsetSpace ~
3457 \InsetSpace ~
3458
3459 \end_layout
3460
3461 \end_inset
3462 </cell>
3463 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3464 \begin_inset Text
3465
3466 \begin_layout Standard
3467 path(argv[0])
3468 \backslash
3469 ..
3470 \backslash
3471 include
3472 \end_layout
3473
3474 \end_inset
3475 </cell>
3476 </row>
3477 <row topline="true" bottomline="true">
3478 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3479 \begin_inset Text
3480
3481 \begin_layout Standard
3482
3483 \emph on
3484 $DATADIR/
3485 \emph default
3486
3487 \newline
3488
3489 \emph on
3490 $INCLUDE_DIR_SUFFIX
3491 \end_layout
3492
3493 \end_inset
3494 </cell>
3495 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3496 \begin_inset Text
3497
3498 \begin_layout Standard
3499 /usr/local/share/sdcc/
3500 \newline
3501 include
3502 \end_layout
3503
3504 \end_inset
3505 </cell>
3506 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3507 \begin_inset Text
3508
3509 \begin_layout Standard
3510 (not on Win32)
3511 \end_layout
3512
3513 \end_inset
3514 </cell>
3515 </row>
3516 </lyxtabular>
3517
3518 \end_inset
3519
3520  
3521 \newline
3522
3523 \end_layout
3524
3525 \begin_layout Standard
3526 \noindent
3527 The option -
3528 \begin_inset ERT
3529 status collapsed
3530
3531 \begin_layout Standard
3532
3533
3534 \backslash
3535 /
3536 \end_layout
3537
3538 \end_inset
3539
3540 -nostdinc disables the last two search paths.
3541 \newline
3542
3543 \newline
3544 3.
3545  Library files 
3546 \newline
3547
3548 \end_layout
3549
3550 \begin_layout Standard
3551 With the exception of 
3552 \begin_inset Quotes sld
3553 \end_inset
3554
3555 -
3556 \begin_inset ERT
3557 status collapsed
3558
3559 \begin_layout Standard
3560
3561
3562 \backslash
3563 /
3564 \end_layout
3565
3566 \end_inset
3567
3568 -L dir
3569 \begin_inset Quotes srd
3570 \end_inset
3571
3572  the 
3573 \shape italic
3574 model
3575 \shape default
3576  is auto-appended by the compiler (e.g.
3577  small, large, z80, ds390 etc.).
3578  
3579 \newline
3580
3581 \end_layout
3582
3583 \begin_layout Standard
3584 \align center
3585 \begin_inset Tabular
3586 <lyxtabular version="3" rows="6" columns="3">
3587 <features>
3588 <column alignment="block" valignment="top" leftline="true" width="1.7in">
3589 <column alignment="block" valignment="top" leftline="true" width="1.2in">
3590 <column alignment="block" valignment="top" leftline="true" rightline="true" width="1.2in">
3591 <row topline="true" bottomline="true">
3592 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3593 \begin_inset Text
3594
3595 \begin_layout Standard
3596 Search path
3597 \end_layout
3598
3599 \end_inset
3600 </cell>
3601 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3602 \begin_inset Text
3603
3604 \begin_layout Standard
3605 default
3606 \end_layout
3607
3608 \end_inset
3609 </cell>
3610 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3611 \begin_inset Text
3612
3613 \begin_layout Standard
3614 Win32 builds
3615 \end_layout
3616
3617 \end_inset
3618 </cell>
3619 </row>
3620 <row topline="true">
3621 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3622 \begin_inset Text
3623
3624 \begin_layout Standard
3625 -
3626 \begin_inset ERT
3627 status collapsed
3628
3629 \begin_layout Standard
3630
3631
3632 \backslash
3633 /
3634 \end_layout
3635
3636 \end_inset
3637
3638 -L dir
3639 \end_layout
3640
3641 \end_inset
3642 </cell>
3643 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3644 \begin_inset Text
3645
3646 \begin_layout Standard
3647 -
3648 \begin_inset ERT
3649 status collapsed
3650
3651 \begin_layout Standard
3652
3653
3654 \backslash
3655 /
3656 \end_layout
3657
3658 \end_inset
3659
3660 -L dir
3661 \end_layout
3662
3663 \end_inset
3664 </cell>
3665 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3666 \begin_inset Text
3667
3668 \begin_layout Standard
3669 -
3670 \begin_inset ERT
3671 status collapsed
3672
3673 \begin_layout Standard
3674
3675
3676 \backslash
3677 /
3678 \end_layout
3679
3680 \end_inset
3681
3682 -L dir
3683 \end_layout
3684
3685 \end_inset
3686 </cell>
3687 </row>
3688 <row topline="true">
3689 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3690 \begin_inset Text
3691
3692 \begin_layout Standard
3693 $SDCC_LIB/
3694 \newline
3695
3696 \emph on
3697 <model>
3698 \end_layout
3699
3700 \end_inset
3701 </cell>
3702 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3703 \begin_inset Text
3704
3705 \begin_layout Standard
3706 $SDCC_LIB/
3707 \newline
3708
3709 \emph on
3710 <model>
3711 \end_layout
3712
3713 \end_inset
3714 </cell>
3715 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3716 \begin_inset Text
3717
3718 \begin_layout Standard
3719 $SDCC_LIB
3720 \backslash
3721
3722 \newline
3723
3724 \emph on
3725 <model>
3726 \end_layout
3727
3728 \end_inset
3729 </cell>
3730 </row>
3731 <row topline="true">
3732 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3733 \begin_inset Text
3734
3735 \begin_layout Standard
3736 $SDCC_HOME/
3737 \newline
3738
3739 \emph on
3740 $PREFIX2DATA_DIR/
3741 \newline
3742 $LIB_DIR_SUFFIX/<model>
3743 \end_layout
3744
3745 \end_inset
3746 </cell>
3747 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3748 \begin_inset Text
3749
3750 \begin_layout Standard
3751 $SDCC_HOME/
3752 \newline
3753 share/sdcc/
3754 \newline
3755 lib/
3756 \emph on
3757 <model>
3758 \end_layout
3759
3760 \end_inset
3761 </cell>
3762 <cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3763 \begin_inset Text
3764
3765 \begin_layout Standard
3766 $SDCC_HOME
3767 \backslash
3768 lib
3769 \backslash
3770
3771 \emph on
3772
3773 \newline
3774 <model>
3775 \end_layout
3776
3777 \end_inset
3778 </cell>
3779 </row>
3780 <row topline="true">
3781 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3782 \begin_inset Text
3783
3784 \begin_layout Standard
3785 path(argv[0])/
3786 \newline
3787
3788 \emph on
3789 $BIN2DATADIR/
3790 \emph default
3791
3792 \newline
3793
3794 \emph on
3795 $LIB_DIR_SUFFIX/<model>
3796 \end_layout
3797
3798 \end_inset
3799 </cell>
3800 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3801 \begin_inset Text
3802
3803 \begin_layout Standard
3804 path(argv[0])/
3805 \newline
3806 ../sdcc/lib/
3807 \emph on
3808 <model>
3809 \newline
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 \InsetSpace ~
3846 \InsetSpace ~
3847 \InsetSpace ~
3848 \InsetSpace ~
3849
3850 \end_layout
3851
3852 \end_inset
3853 </cell>
3854 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3855 \begin_inset Text
3856
3857 \begin_layout Standard
3858 path(argv[0])
3859 \backslash
3860
3861 \newline
3862 ..
3863 \backslash
3864 lib
3865 \backslash
3866
3867 \emph on
3868 <model>
3869 \newline
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 \InsetSpace ~
3902 \InsetSpace ~
3903 \InsetSpace ~
3904 \InsetSpace ~
3905
3906 \end_layout
3907
3908 \end_inset
3909 </cell>
3910 </row>
3911 <row topline="true" bottomline="true">
3912 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3913 \begin_inset Text
3914
3915 \begin_layout Standard
3916
3917 \emph on
3918 $DATADIR/
3919 \newline
3920 $LIB_DIR_SUFFIX/<model>
3921 \end_layout
3922
3923 \end_inset
3924 </cell>
3925 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3926 \begin_inset Text
3927
3928 \begin_layout Standard
3929 /usr/local/share/sdcc/
3930 \newline
3931 lib/
3932 \emph on
3933 <model>
3934 \end_layout
3935
3936 \end_inset
3937 </cell>
3938 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3939 \begin_inset Text
3940
3941 \begin_layout Standard
3942 (not on Win32)
3943 \end_layout
3944
3945 \end_inset
3946 </cell>
3947 </row>
3948 </lyxtabular>
3949
3950 \end_inset
3951
3952
3953 \newline
3954
3955 \end_layout
3956
3957 \begin_layout Standard
3958 \begin_inset Note Note
3959 status collapsed
3960
3961 \begin_layout Standard
3962 Don't delete any of the stray spaces in the table above without checking
3963  the HTML output (last line)!
3964 \end_layout
3965
3966 \end_inset
3967
3968
3969 \end_layout
3970
3971 \begin_layout Standard
3972 \InsetSpace ~
3973
3974 \newline
3975 The option -
3976 \begin_inset ERT
3977 status collapsed
3978
3979 \begin_layout Standard
3980
3981
3982 \backslash
3983 /
3984 \end_layout
3985
3986 \end_inset
3987
3988 -nostdlib disables the last two search paths.
3989 \end_layout
3990
3991 \begin_layout Section
3992 Building SDCC
3993 \begin_inset LatexCommand \index{Building SDCC}
3994
3995 \end_inset
3996
3997
3998 \end_layout
3999
4000 \begin_layout Subsection
4001 Building SDCC on Linux
4002 \begin_inset LatexCommand \label{sub:Building-SDCC-on-Linux}
4003
4004 \end_inset
4005
4006
4007 \end_layout
4008
4009 \begin_layout Enumerate
4010
4011 \series medium
4012 Download the source package
4013 \series default
4014  either from the SDCC Subversion repository or from snapshot builds
4015 \series medium
4016 , it will be named something like sdcc
4017 \series default
4018 -src
4019 \series medium
4020 -yyyymmdd-rrrr.t
4021 \series default
4022 ar.
4023 \series medium
4024 bz2
4025 \series default
4026  
4027 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
4028
4029 \end_inset
4030
4031 .
4032 \end_layout
4033
4034 \begin_layout Enumerate
4035
4036 \series medium
4037 Bring up a command line terminal, such as xterm.
4038 \end_layout
4039
4040 \begin_layout Enumerate
4041
4042 \series medium
4043 Unpack the file using a command like: 
4044 \family sans
4045 \series bold
4046 "tar -xvzf sdcc-src-yyyymmdd-rrrr.tar.bz2
4047 \begin_inset Quotes srd
4048 \end_inset
4049
4050
4051 \family default
4052 \series medium
4053 , this will create a sub-directory called sdcc with all of the sources.
4054 \end_layout
4055
4056 \begin_layout Enumerate
4057 Change directory into the main SDCC directory, for example type: 
4058 \family sans
4059 \series bold
4060 "cd sdcc
4061 \series default
4062 ".
4063 \end_layout
4064
4065 \begin_layout Enumerate
4066
4067 \series medium
4068 Type 
4069 \family sans
4070 \series bold
4071 "./configure
4072 \family default
4073 \series default
4074 ".
4075  This configures the package for compilation on your system.
4076 \end_layout
4077
4078 \begin_layout Enumerate
4079
4080 \series medium
4081 Type 
4082 \family sans
4083 \series bold
4084 "make
4085 \family default
4086 \series default
4087 "
4088 \series medium
4089 .
4090
4091 \series default
4092  All of the source packages will compile, this can take a while.
4093 \end_layout
4094
4095 \begin_layout Enumerate
4096
4097 \series medium
4098 Type 
4099 \family sans
4100 \series bold
4101 "make install"
4102 \family default
4103 \series default
4104  as root
4105 \series medium
4106 .
4107
4108 \series default
4109  This copies the binary executables, the include files, the libraries and
4110  the documentation to the install directories.
4111  Proceed with section 
4112 \begin_inset LatexCommand \ref{sec:Testing-the-SDCC}
4113
4114 \end_inset
4115
4116 .
4117 \end_layout
4118
4119 \begin_layout Subsection
4120 Building SDCC on Mac OS X
4121 \end_layout
4122
4123 \begin_layout Standard
4124 Follow the instruction for Linux.
4125 \newline
4126
4127 \newline
4128 On Mac OS X 10.2.x it was reported, that the
4129  default gcc (version 3.1 20020420 (prerelease)) fails to compile SDCC.
4130  Fortunately there's also gcc 2.9.x installed, which works fine.
4131  This compiler can be selected by running 'configure' with:
4132 \end_layout
4133
4134 \begin_layout LyX-Code
4135 ./configure CC=gcc2 CXX=g++2
4136 \end_layout
4137
4138 \begin_layout Standard
4139 Universal (ppc and i386) binaries can be produced on Mac OS X 10.4.x with
4140  Xcode.
4141  Run 'configure' with:
4142 \end_layout
4143
4144 \begin_layout LyX-Code
4145 ./configure 
4146 \backslash
4147
4148 \end_layout
4149
4150 \begin_layout LyX-Code
4151 LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
4152  ppc" 
4153 \backslash
4154
4155 \end_layout
4156
4157 \begin_layout LyX-Code
4158 CXXFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
4159  ppc" 
4160 \backslash
4161
4162 \end_layout
4163
4164 \begin_layout LyX-Code
4165 CFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
4166 \end_layout
4167
4168 \begin_layout Subsection
4169 Cross compiling SDCC on Linux for Windows
4170 \end_layout
4171
4172 \begin_layout Standard
4173 With the Mingw32 gcc cross compiler it's easy to compile SDCC for Win32.
4174  See section 'Configure Options'.
4175 \end_layout
4176
4177 \begin_layout Subsection
4178 Building SDCC using Cygwin and Mingw32
4179 \end_layout
4180
4181 \begin_layout Standard
4182 For building and installing a Cygwin executable follow the instructions
4183  for Linux.
4184 \newline
4185
4186 \newline
4187 On Cygwin a 
4188 \begin_inset Quotes sld
4189 \end_inset
4190
4191 native
4192 \begin_inset Quotes srd
4193 \end_inset
4194
4195  Win32-binary can be built, which will not need the Cygwin-DLL.
4196  For the necessary 'configure' options see section 'configure options' or
4197  the script 'sdcc/support/scripts/sdcc_cygwin_mingw32'.
4198 \newline
4199
4200 \newline
4201 In order to install
4202  Cygwin on Windows download setup.exe from 
4203 \begin_inset LatexCommand \url[www.cygwin.com]{http://www.cygwin.com/}
4204
4205 \end_inset
4206
4207 .
4208  Run it, set the 
4209 \begin_inset Quotes sld
4210 \end_inset
4211
4212 default text file type
4213 \begin_inset Quotes srd
4214 \end_inset
4215
4216  to 
4217 \begin_inset Quotes sld
4218 \end_inset
4219
4220 unix
4221 \begin_inset Quotes srd
4222 \end_inset
4223
4224  and download/install at least the following packages.
4225  Some packages are selected by default, others will be automatically selected
4226  because of dependencies with the manually selected packages.
4227  Never deselect these packages!
4228 \end_layout
4229
4230 \begin_layout Itemize
4231 flex
4232 \end_layout
4233
4234 \begin_layout Itemize
4235 bison
4236 \end_layout
4237
4238 \begin_layout Itemize
4239 gcc ; version 3.x is fine, no need to use the old 2.9x
4240 \end_layout
4241
4242 \begin_layout Itemize
4243 binutils ; selected with gcc
4244 \end_layout
4245
4246 \begin_layout Itemize
4247 make
4248 \end_layout
4249
4250 \begin_layout Itemize
4251 rxvt ; a nice console, which makes life much easier under windoze (see below)
4252 \end_layout
4253
4254 \begin_layout Itemize
4255 man ; not really needed for building SDCC, but you'll miss it sooner or
4256  later
4257 \end_layout
4258
4259 \begin_layout Itemize
4260 less ; not really needed for building SDCC, but you'll miss it sooner or
4261  later
4262 \end_layout
4263
4264 \begin_layout Itemize
4265 svn ; only if you use Subversion access
4266 \end_layout
4267
4268 \begin_layout Standard
4269 If you want to develop something you'll need:
4270 \end_layout
4271
4272 \begin_layout Itemize
4273 python ; for the regression tests
4274 \end_layout
4275
4276 \begin_layout Itemize
4277 gdb ; the gnu debugger, together with the nice GUI 
4278 \begin_inset Quotes sld
4279 \end_inset
4280
4281 insight
4282 \begin_inset Quotes srd
4283 \end_inset
4284
4285
4286 \end_layout
4287
4288 \begin_layout Itemize
4289 openssh ; to access the CF or commit changes
4290 \end_layout
4291
4292 \begin_layout Itemize
4293 autoconf and autoconf-devel ; if you want to fight with 'configure', don't
4294  use autoconf-stable!
4295 \end_layout
4296
4297 \begin_layout Standard
4298 rxvt is a nice console with history.
4299  Replace in your cygwin.bat the line
4300 \end_layout
4301
4302 \begin_layout LyX-Code
4303 bash -
4304 \begin_inset ERT
4305 status collapsed
4306
4307 \begin_layout Standard
4308
4309
4310 \backslash
4311 /
4312 \end_layout
4313
4314 \end_inset
4315
4316 -login -i 
4317 \end_layout
4318
4319 \begin_layout Standard
4320 with (one line):
4321 \end_layout
4322
4323 \begin_layout LyX-Code
4324 rxvt -sl 1000 -fn "Lucida Console-12" -sr -cr red
4325 \end_layout
4326
4327 \begin_layout LyX-Code
4328      -bg black -fg white -geometry 100x65 -e bash -
4329 \begin_inset ERT
4330 status collapsed
4331
4332 \begin_layout Standard
4333
4334
4335 \backslash
4336 /
4337 \end_layout
4338
4339 \end_inset
4340
4341 -login
4342 \end_layout
4343
4344 \begin_layout Standard
4345 Text selected with the mouse is automatically copied to the clipboard, pasting
4346  works with shift-insert.
4347 \newline
4348
4349 \newline
4350 The other good tip is to make sure you have no //c/-styl
4351 e paths anywhere, use /cygdrive/c/ instead.
4352  Using // invokes a network lookup which is very slow.
4353  If you think 
4354 \begin_inset Quotes sld
4355 \end_inset
4356
4357 cygdrive
4358 \begin_inset Quotes srd
4359 \end_inset
4360
4361  is too long, you can change it with e.g.
4362 \end_layout
4363
4364 \begin_layout LyX-Code
4365 mount -s -u -c /mnt
4366 \end_layout
4367
4368 \begin_layout Standard
4369 SDCC sources use the unix line ending LF.
4370  Life is much easier, if you store the source tree on a drive which is mounted
4371  in binary mode.
4372  And use an editor which can handle LF-only line endings.
4373  Make sure not to commit files with windows line endings.
4374  The tabulator spacing
4375 \begin_inset LatexCommand \index{tabulator spacing (8 columns)}
4376
4377 \end_inset
4378
4379  used in the project is 8.
4380  Although a tabulator spacing of 8 is a sensible choice for programmers
4381  (it's a power of 2 and allows to display 8/16 bit signed variables without
4382  loosing columns) the plan is to move towards using only spaces in the source.
4383 \end_layout
4384
4385 \begin_layout Subsection
4386 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)
4387 \end_layout
4388
4389 \begin_layout Standard
4390
4391 \series medium
4392 Download the source package
4393 \series default
4394  either from the SDCC Subversion repository or from the 
4395 \begin_inset LatexCommand \url[snapshot builds]{http://sdcc.sourceforge.net/snap.php}
4396
4397 \end_inset
4398
4399
4400 \series medium
4401 , it will be named something like sdcc
4402 \series default
4403 -src
4404 \series medium
4405 -yyyymmdd-rrrr.tar.bz2.
4406
4407 \series default
4408  SDCC is distributed with all the projects, workspaces, and files you need
4409  to build it using Visual C++ 6.0/NET (except for SDCDB and ucSim).
4410  The workspace name is 'sdcc.dsw'.
4411  Please note that as it is now, all the executables are created in a folder
4412  called sdcc
4413 \backslash
4414 bin_vc.
4415  Once built you need to copy the executables from sdcc
4416 \backslash
4417 bin_vc to sdcc
4418 \backslash
4419 bin before running SDCC.
4420  
4421 \newline
4422
4423 \newline
4424 WARNING: Visual studio is very picky with line terminations; it expects
4425  the 0x0d, 0x0a DOS style line endings, not the 0x0a Unix style line endings.
4426  When using the Subversion repository it's easiest to configure the svn
4427  client to convert automatically for you.
4428  If however you are getting a message such as "This makefile was not generated
4429  by Developer Studio etc.
4430  etc.
4431 \begin_inset Quotes srd
4432 \end_inset
4433
4434  when opening the sdcc.dsw workspace or any of the *.dsp projects, then you
4435  need to convert the Unix style line endings to DOS style line endings.
4436  To do so you can use the 
4437 \begin_inset Quotes sld
4438 \end_inset
4439
4440 unix2dos
4441 \begin_inset Quotes srd
4442 \end_inset
4443
4444  utility freely available on the internet.
4445  Doug Hawkins reported in the sdcc-user list that this works:
4446 \newline
4447
4448 \newline
4449 C:
4450 \backslash
4451 Programming
4452 \backslash
4453 SDCC> unix2dos sdcc.dsw
4454 \newline
4455 C:
4456 \backslash
4457 Programming
4458 \backslash
4459 SDCC> for /R %I in (*.dsp) do @unix2dos "%I"
4460 \newline
4461
4462 \newline
4463 In order to build SDCC with MSVC
4464  you need win32 executables of bison.exe, flex.exe, and gawk.exe.
4465  One good place to get them is 
4466 \begin_inset LatexCommand \url[here]{http://unxutils.sourceforge.net}
4467
4468 \end_inset
4469
4470
4471 \newline
4472
4473 \newline
4474 Download the file UnxUtils
4475 \begin_inset LatexCommand \index{UnxUtils}
4476
4477 \end_inset
4478
4479 .zip.
4480  Now you have to install the utilities and setup MSVC so it can locate the
4481  required programs.
4482  Here there are two alternatives (choose one!):
4483 \end_layout
4484
4485 \begin_layout Enumerate
4486 The easy way:
4487 \newline
4488
4489 \newline
4490 a) Extract UnxUtils.zip to your C:
4491 \backslash
4492  hard disk PRESERVING the original paths, otherwise bison won't work.
4493  (If you are using WinZip make certain that 'Use folder names' is selected)
4494 \newline
4495
4496 \newline
4497 b)
4498  In the Visual C++ IDE click Tools, Options, select the Directory tab, in
4499  'Show directories for:' select 'Executable files', and in the directories
4500  window add a new path: 'C:
4501 \backslash
4502 user
4503 \backslash
4504 local
4505 \backslash
4506 wbin', click ok.
4507 \newline
4508
4509 \newline
4510 (As a side effect, you get a bunch of Unix utilities that
4511  could be useful, such as diff and patch.)
4512 \end_layout
4513
4514 \begin_layout Enumerate
4515 A more compact way:
4516 \newline
4517
4518 \newline
4519 This one avoids extracting a bunch of files you may not
4520  use, but requires some extra work:
4521 \newline
4522
4523 \newline
4524 a) Create a directory were to put the
4525  tools needed, or use a directory already present.
4526  Say for example 'C:
4527 \backslash
4528 util'.
4529 \newline
4530
4531 \newline
4532 b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and
4533  gawk.exe to such directory WITHOUT preserving the original paths.
4534  (If you are using WinZip make certain that 'Use folder names' is not selected)
4535 \newline
4536
4537 \newline
4538 c
4539 ) Rename bison.exe to '_bison.exe'.
4540 \newline
4541
4542 \newline
4543 d) Create a batch file 'bison.bat' in 'C:
4544 \backslash
4545 util
4546 \backslash
4547 ' and add these lines: 
4548 \newline
4549 \InsetSpace ~
4550 \InsetSpace ~
4551 set BISON_SIMPLE=C:
4552 \backslash
4553 util
4554 \backslash
4555 bison.simple 
4556 \newline
4557 \InsetSpace ~
4558 \InsetSpace ~
4559 set BISON_HAIRY=C:
4560 \backslash
4561 util
4562 \backslash
4563 bison.hairy
4564 \newline
4565 \InsetSpace ~
4566 \InsetSpace ~
4567 _bison %1 %2 %3 %4 %5 %6 %7 %8 %9
4568 \newline
4569
4570 \newline
4571 Steps 'c' and 'd' are needed
4572  because bison requires by default that the files 'bison.simple' and 'bison.hairy'
4573  reside in some weird Unix directory, '/usr/local/share/' I think.
4574  So it is necessary to tell bison where those files are located if they
4575  are not in such directory.
4576  That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.
4577 \newline
4578
4579 \newline
4580 e
4581 ) In the Visual C++ IDE click Tools, Options, select the Directory tab,
4582  in 'Show directories for:' select 'Executable files', and in the directories
4583  window add a new path: 'c:
4584 \backslash
4585 util', click ok.
4586  Note that you can use any other path instead of 'c:
4587 \backslash
4588 util', even the path where the Visual C++ tools are, probably: 'C:
4589 \backslash
4590 Program Files
4591 \backslash
4592 Microsoft Visual Studio
4593 \backslash
4594 Common
4595 \backslash
4596 Tools'.
4597  So you don't have to execute step 'e' :)
4598 \end_layout
4599
4600 \begin_layout Standard
4601 That is it.
4602  Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy
4603  the executables from sdcc
4604 \backslash
4605 bin_vc to sdcc
4606 \backslash
4607 bin, and you can compile using SDCC.
4608 \end_layout
4609
4610 \begin_layout Subsection
4611 Building SDCC Using Borland
4612 \end_layout
4613
4614 \begin_layout Enumerate
4615 From the sdcc directory, run the command "make -f Makefile.bcc".
4616  This should regenerate all the .exe files in the bin directory except for
4617  SDCDB and ucSim.
4618 \end_layout
4619
4620 \begin_layout Enumerate
4621 If you modify any source files and need to rebuild, be aware that the dependenci
4622 es may not be correctly calculated.
4623  The safest option is to delete all .obj files and run the build again.
4624  From a Cygwin BASH prompt, this can easily be done with the command (be
4625  sure you are in the sdcc directory):
4626 \newline
4627
4628 \newline
4629
4630 \family sans
4631 \series bold
4632 find .
4633  
4634 \backslash
4635 ( -name '*.obj' -o -name '*.lib' -o -name '*.rul' 
4636 \backslash
4637 ) -print -exec rm {} 
4638 \backslash
4639 ;
4640 \family default
4641 \series default
4642
4643 \newline
4644
4645 \newline
4646 or on Windows NT/2000/XP from the command prompt with the command:
4647 \newline
4648
4649 \family sans
4650 \series bold
4651
4652 \newline
4653 del /s *.obj *.lib *.rul
4654 \family default
4655 \series default
4656  from the sdcc directory.
4657 \end_layout
4658
4659 \begin_layout Subsection
4660 Windows Install Using a ZIP Package
4661 \end_layout
4662
4663 \begin_layout Enumerate
4664 Download the binary zip package from 
4665 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4666
4667 \end_inset
4668
4669  and unpack it using your favorite unpacking tool (gunzip, WinZip, etc).
4670  This should unpack to a group of sub-directories.
4671  An example directory structure after unpacking the mingw32 package is:
4672  c:
4673 \backslash
4674 sdcc
4675 \backslash
4676 bin for the executables, c:
4677 \backslash
4678 sdcc
4679 \backslash
4680 include and c:
4681 \backslash
4682 sdcc
4683 \backslash
4684 lib for the include and libraries.
4685 \end_layout
4686
4687 \begin_layout Enumerate
4688 Adjust your environment variable PATH to include the location of the bin
4689  directory or start sdcc using the full path.
4690 \end_layout
4691
4692 \begin_layout Subsection
4693 Windows Install Using the Setup Program
4694 \begin_inset LatexCommand \label{sub:Windows-Install}
4695
4696 \end_inset
4697
4698
4699 \end_layout
4700
4701 \begin_layout Standard
4702 Download the setup program 
4703 \emph on
4704 sdcc-x.y.z-setup.exe
4705 \emph default
4706  for an official release from 
4707 \newline
4708
4709 \begin_inset LatexCommand \url{http://sf.net/project/showfiles.php?group_id=599}
4710
4711 \end_inset
4712
4713  or a setup program for one of the snapshots 
4714 \emph on
4715 sdcc-yyyymmdd-xxxx-setup.exe
4716 \emph default
4717  from 
4718 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4719
4720 \end_inset
4721
4722  and execute it.
4723  A windows typical installer will guide you through the installation process.
4724 \end_layout
4725
4726 \begin_layout Subsection
4727 VPATH
4728 \begin_inset LatexCommand \index{VPATH}
4729
4730 \end_inset
4731
4732  feature
4733 \end_layout
4734
4735 \begin_layout Standard
4736 SDCC supports the VPATH feature provided by configure and make.
4737  It allows to separate the source and build trees.
4738  Here's an example:
4739 \end_layout
4740
4741 \begin_layout Standard
4742
4743 \family typewriter
4744 cd ~\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 \InsetSpace ~
4762 \InsetSpace ~
4763 \InsetSpace ~
4764 \InsetSpace ~
4765 # cd $HOME
4766 \end_layout
4767
4768 \begin_layout Standard
4769
4770 \family typewriter
4771 tar -xzf sdcc.src.tar.gz\InsetSpace ~
4772 # extract source to directory sdcc
4773 \end_layout
4774
4775 \begin_layout Standard
4776
4777 \family typewriter
4778 mkdir sdcc.build\InsetSpace ~
4779 \InsetSpace ~
4780 \InsetSpace ~
4781 \InsetSpace ~
4782 \InsetSpace ~
4783 \InsetSpace ~
4784 \InsetSpace ~
4785 \InsetSpace ~
4786 \InsetSpace ~
4787 # put output in sdcc.build
4788 \end_layout
4789
4790 \begin_layout Standard
4791
4792 \family typewriter
4793 cd sdcc.build
4794 \end_layout
4795
4796 \begin_layout Standard
4797
4798 \family typewriter
4799 ../sdcc/configure\InsetSpace ~
4800 \InsetSpace ~
4801 \InsetSpace ~
4802 \InsetSpace ~
4803 \InsetSpace ~
4804 \InsetSpace ~
4805 \InsetSpace ~
4806 \InsetSpace ~
4807 # configure is doing all the magic!
4808 \end_layout
4809
4810 \begin_layout Standard
4811
4812 \family typewriter
4813 make
4814 \end_layout
4815
4816 \begin_layout Standard
4817 \noindent
4818 That's it! 
4819 \series bold
4820 configure
4821 \series default
4822  will create the directory tree will all the necessary Makefiles in ~/sdcc.build.
4823  It automagically computes the variables srcdir, top_srcdir and top_buildir
4824  for each directory.
4825  After running 
4826 \series bold
4827 make
4828 \series default
4829  the generated files will be in ~/sdcc.build, while the source files stay
4830  in ~/sdcc.
4831 \newline
4832 This is not only usefull for building different binaries, e.g.
4833  when cross compiling.
4834  It also gives you a much better overview in the source tree when all the
4835  generated files are not scattered between the source files.
4836  And the best thing is: if you want to change a file you can leave the original
4837  file untouched in the source directory.
4838  Simply copy it to the build directory, edit it, enter `make clean', `rm
4839  Makefile.dep' and `make'.
4840  
4841 \series bold
4842 make
4843 \series default
4844  will do the rest for you!
4845 \end_layout
4846
4847 \begin_layout Section
4848 Building the Documentation
4849 \end_layout
4850
4851 \begin_layout Standard
4852 Add -
4853 \begin_inset ERT
4854 status collapsed
4855
4856 \begin_layout Standard
4857
4858
4859 \backslash
4860 /
4861 \end_layout
4862
4863 \end_inset
4864
4865 -enable-doc to the configure arguments to build the documentation together
4866  with all the other stuff.
4867  You will need several tools (LyX, LaTeX, LaTeX2HTML, pdflatex, dvipdf,
4868  dvips and makeindex) to get the job done.
4869  Another possibility is to change to the doc directory and to type 
4870 \family sans
4871 \series bold
4872
4873 \begin_inset Quotes srd
4874 \end_inset
4875
4876 make
4877 \begin_inset Quotes srd
4878 \end_inset
4879
4880
4881 \family default
4882 \series default
4883  there.
4884  You're invited to make changes and additions to this manual (sdcc/doc/sdccman.ly
4885 x).
4886  Using LyX 
4887 \begin_inset LatexCommand \url{http://www.lyx.org}
4888
4889 \end_inset
4890
4891  as editor is straightforward.
4892  Prebuilt documentation in html and pdf format is available from 
4893 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4894
4895 \end_inset
4896
4897 .
4898 \end_layout
4899
4900 \begin_layout Section
4901 Reading the Documentation
4902 \begin_inset LatexCommand \index{Documentation}
4903
4904 \end_inset
4905
4906
4907 \end_layout
4908
4909 \begin_layout Standard
4910 Currently reading the document in pdf format is recommended, as for unknown
4911  reason the hyperlinks are working there whereas in the html version they
4912  are not
4913 \begin_inset Foot
4914 status open
4915
4916 \begin_layout Standard
4917 If you should know why please drop us a note
4918 \end_layout
4919
4920 \end_inset
4921
4922 .
4923  
4924 \newline
4925 You'll find the pdf version
4926 \begin_inset LatexCommand \index{PDF version of this document}
4927
4928 \end_inset
4929
4930  at 
4931 \begin_inset LatexCommand \url{http://sdcc.sf.net/doc/sdccman.pdf}
4932
4933 \end_inset
4934
4935 .
4936  
4937 \newline
4938 A html version
4939 \begin_inset LatexCommand \index{HTML version of this document}
4940
4941 \end_inset
4942
4943  should be online at 
4944 \begin_inset LatexCommand \url{http://sdcc.sf.net/doc/sdccman.html/index.html}
4945
4946 \end_inset
4947
4948 .
4949 \newline
4950 This documentation is in some aspects different from a commercial documentation:
4951  
4952 \end_layout
4953
4954 \begin_layout Itemize
4955 It tries to document SDCC for several processor architectures in one document
4956  (commercially these probably would be separate documents/products).
4957  This document
4958 \begin_inset LatexCommand \index{Status of documentation}
4959
4960 \end_inset
4961
4962  currently matches SDCC for mcs51 and DS390 best and does give too few informati
4963 on about f.e.
4964  Z80, PIC14, PIC16 and HC08.
4965 \end_layout
4966
4967 \begin_layout Itemize
4968 There are many references pointing away from this documentation.
4969  Don't let this distract you.
4970  If there f.e.
4971  was a reference like 
4972 \begin_inset LatexCommand \url{http://www.opencores.org}
4973
4974 \end_inset
4975
4976  together with a statement 
4977 \begin_inset Quotes sld
4978 \end_inset
4979
4980 some processors which are targetted by SDCC can be implemented in a 
4981 \emph on
4982 f
4983 \emph default
4984 ield 
4985 \emph on
4986 p
4987 \emph default
4988 rogrammable 
4989 \emph on
4990 g
4991 \emph default
4992 ate 
4993 \emph on
4994 a
4995 \emph default
4996 rray
4997 \begin_inset LatexCommand \index{FPGA (field programmable gate array)}
4998
4999 \end_inset
5000
5001
5002 \begin_inset Quotes srd
5003 \end_inset
5004
5005  or 
5006 \begin_inset LatexCommand \url{http://sf.net/projects/fpgac}
5007
5008 \end_inset
5009
5010
5011 \begin_inset LatexCommand \index{FpgaC ((subset of) C to FPGA compiler)}
5012
5013 \end_inset
5014
5015  
5016 \begin_inset Quotes sld
5017 \end_inset
5018
5019 have you ever heard of an open source compiler that compiles a subset of
5020  C for an FPGA?
5021 \begin_inset Quotes srd
5022 \end_inset
5023
5024  we expect you to have a quick look there and come back.
5025  If you read this you are on the right track.
5026 \end_layout
5027
5028 \begin_layout Itemize
5029 Some sections attribute more space to problems, restrictions and warnings
5030  than to the solution.
5031 \end_layout
5032
5033 \begin_layout Itemize
5034 The installation section and the section about the debugger is intimidating.
5035 \end_layout
5036
5037 \begin_layout Itemize
5038 There are still lots of typos and there are more different writing styles
5039  than pictures.
5040 \end_layout
5041
5042 \begin_layout Section
5043 Testing the SDCC Compiler
5044 \begin_inset LatexCommand \label{sec:Testing-the-SDCC}
5045
5046 \end_inset
5047
5048
5049 \end_layout
5050
5051 \begin_layout Standard
5052 The first thing you should do after installing your SDCC compiler is to
5053  see if it runs.
5054  Type 
5055 \family sans
5056 \series bold
5057 "sdcc -
5058 \begin_inset ERT
5059 status collapsed
5060
5061 \begin_layout Standard
5062
5063
5064 \backslash
5065 /
5066 \end_layout
5067
5068 \end_inset
5069
5070 -version"
5071 \begin_inset LatexCommand \index{version}
5072
5073 \end_inset
5074
5075
5076 \family default
5077 \series default
5078  at the prompt, and the program should run and output its version like:
5079  
5080 \newline
5081
5082 \family typewriter
5083 SDCC : mcs51/z80/avr/ds390/pic16/pic14/ds400/hc08 2.5.6 #4169 (May 8 2006)
5084  (UNIX)
5085 \end_layout
5086
5087 \begin_layout Standard
5088 If it doesn't run, or gives a message about not finding sdcc program, then
5089  you need to check over your installation.
5090  Make sure that the sdcc bin directory is in your executable search path
5091  defined by the PATH environment setting (
5092 \series medium
5093 see 
5094 \series default
5095 section 
5096 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5097
5098 \end_inset
5099
5100 \InsetSpace ~
5101
5102 \series medium
5103 Install trouble-shooting for suggestions
5104 \series default
5105 ).
5106  Make sure that the sdcc program is in the bin folder, if not perhaps something
5107  did not install correctly.
5108 \newline
5109
5110 \newline
5111
5112 \series medium
5113 SDCC 
5114 \series default
5115 is commonly installed as described in section 
5116 \begin_inset Quotes sld
5117 \end_inset
5118
5119 Install and search paths
5120 \begin_inset Quotes srd
5121 \end_inset
5122
5123 .
5124 \newline
5125
5126 \newline
5127
5128 \series medium
5129 Make sure the compiler works on a very simple example.
5130  Type in the following test.c program using your favorite 
5131 \series default
5132 ASCII 
5133 \series medium
5134 editor:
5135 \end_layout
5136
5137 \begin_layout Verse
5138
5139 \family typewriter
5140 char test;
5141 \newline
5142
5143 \newline
5144 void main(void) {
5145 \newline
5146 \InsetSpace ~
5147 \InsetSpace ~
5148 \InsetSpace ~
5149 \InsetSpace ~
5150 test=0;
5151 \newline
5152 }
5153 \end_layout
5154
5155 \begin_layout Standard
5156
5157 \series medium
5158 Compile this using the following command: 
5159 \family sans
5160 \series bold
5161 "sdcc -c test.c".
5162
5163 \family default
5164 \series default
5165  
5166 \series medium
5167 If all goes well, the compiler will generate a test.asm and test.rel file.
5168  Congratulations, you've just compiled your first program with SDCC.
5169  We used the -c option to tell SDCC not to link the generated code, just
5170  to keep things simple for this step.
5171 \series default
5172
5173 \newline
5174
5175 \newline
5176
5177 \series medium
5178 The next step is to try it with the linker.
5179  Type in 
5180 \family sans
5181 \series bold
5182 "sdcc test.c
5183 \family default
5184 \series default
5185 "
5186 \series medium
5187 .
5188  If all goes well the compiler will link with the libraries and produce
5189  a test.ihx output file.
5190  If this step fails
5191 \series default
5192  
5193 \series medium
5194 (no test.ihx, and the linker generates warnings), then the problem is most
5195  likely that 
5196 \series default
5197 SDCC
5198 \series medium
5199  cannot find the 
5200 \series default
5201 /
5202 \series medium
5203 usr/local/share/sdcc/lib directory
5204 \series default
5205  
5206 \series medium
5207 (see 
5208 \series default
5209 section 
5210 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5211
5212 \end_inset
5213
5214 \InsetSpace ~
5215
5216 \series medium
5217 Install trouble-shooting for suggestions).
5218 \series default
5219
5220 \newline
5221
5222 \newline
5223
5224 \series medium
5225 The final test is to ensure 
5226 \series default
5227 SDCC
5228 \series medium
5229  can use the 
5230 \series default
5231 standard
5232 \series medium
5233  header files and libraries.
5234  Edit test.c and change it to the following:
5235 \end_layout
5236
5237 \begin_layout Verse
5238
5239 \family typewriter
5240 #include <string.h>
5241 \newline
5242
5243 \newline
5244 char str1[10];
5245 \newline
5246
5247 \newline
5248 void main(void) {
5249 \newline
5250 \InsetSpace ~
5251 \InsetSpace ~
5252 strcpy(str1, "testing");
5253 \newline
5254 }
5255 \end_layout
5256
5257 \begin_layout Standard
5258
5259 \series medium
5260 Compile this by typing 
5261 \family sans
5262 \series bold
5263 "sdcc test.c"
5264 \family default
5265 \series medium
5266 .
5267  This should generate a test.ihx output file, and it should give no warnings
5268  such as not finding the string.h file.
5269  If it cannot find the string.h file, then the problem is that 
5270 \series default
5271 SDCC
5272 \series medium
5273  cannot find the /usr/local/share/sdcc/include directory
5274 \series default
5275  
5276 \series medium
5277 (see the 
5278 \series default
5279 section 
5280 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5281
5282 \end_inset
5283
5284 \InsetSpace ~
5285
5286 \series medium
5287 Install trouble-shooting section for suggestions).
5288
5289 \series default
5290  Use option 
5291 \series bold
5292 -
5293 \begin_inset ERT
5294 status collapsed
5295
5296 \begin_layout Standard
5297
5298
5299 \backslash
5300 /
5301 \end_layout
5302
5303 \end_inset
5304
5305 -print-search-dirs
5306 \series default
5307
5308 \begin_inset LatexCommand \index{-\/-print-search-dirs}
5309
5310 \end_inset
5311
5312  to find exactly where SDCC is looking for the include and lib files.
5313 \end_layout
5314
5315 \begin_layout Section
5316 Install Trouble-shooting
5317 \begin_inset LatexCommand \label{sub:Install-Trouble-shooting}
5318
5319 \end_inset
5320
5321
5322 \begin_inset LatexCommand \index{Install trouble-shooting}
5323
5324 \end_inset
5325
5326
5327 \end_layout
5328
5329 \begin_layout Subsection
5330 If SDCC does not build correctly
5331 \end_layout
5332
5333 \begin_layout Standard
5334 A thing to try is starting from scratch by unpacking the .tgz source package
5335  again in an empty directory.
5336  Configure it like:
5337 \newline
5338
5339 \newline
5340
5341 \family sans
5342 \series bold
5343 ./configure 2>&1 | tee configure.log
5344 \family default
5345 \series default
5346
5347 \newline
5348
5349 \newline
5350 and build it like:
5351 \newline
5352
5353 \newline
5354
5355 \family sans
5356 \series bold
5357 make 2>&1 | tee make.log
5358 \family default
5359 \series default
5360
5361 \newline
5362
5363 \newline
5364 If anything goes wrong, you can review the log files to locate the problem.
5365  Or a relevant part of this can be attached to an email that could be helpful
5366  when requesting help from the mailing list.
5367 \end_layout
5368
5369 \begin_layout Subsection
5370 What the 
5371 \begin_inset Quotes sld
5372 \end_inset
5373
5374 ./configure
5375 \begin_inset Quotes srd
5376 \end_inset
5377
5378  does
5379 \end_layout
5380
5381 \begin_layout Standard
5382 The 
5383 \begin_inset Quotes sld
5384 \end_inset
5385
5386 ./configure
5387 \begin_inset Quotes srd
5388 \end_inset
5389
5390  command is a script that analyzes your system and performs some configuration
5391  to ensure the source package compiles on your system.
5392  It will take a few minutes to run, and will compile a few tests to determine
5393  what compiler features are installed.
5394 \end_layout
5395
5396 \begin_layout Subsection
5397 What the 
5398 \begin_inset Quotes sld
5399 \end_inset
5400
5401 make
5402 \begin_inset Quotes srd
5403 \end_inset
5404
5405  does
5406 \end_layout
5407
5408 \begin_layout Standard
5409 This runs the GNU make tool, which automatically compiles all the source
5410  packages into the final installed binary executables.
5411 \end_layout
5412
5413 \begin_layout Subsection
5414 What the 
5415 \begin_inset Quotes sld
5416 \end_inset
5417
5418 make install
5419 \begin_inset Quotes erd
5420 \end_inset
5421
5422  command does.
5423 \end_layout
5424
5425 \begin_layout Standard
5426 This will install the compiler, other executables libraries and include
5427  files into the appropriate directories.
5428  See sections 
5429 \begin_inset LatexCommand \ref{sub:Install-paths}
5430
5431 \end_inset
5432
5433 ,\InsetSpace ~
5434
5435 \begin_inset LatexCommand \ref{sub:Search-Paths}
5436
5437 \end_inset
5438
5439 \InsetSpace ~
5440 about install and search paths.
5441 \newline
5442 On most systems you will need super-user privilege
5443 s to do this.
5444 \end_layout
5445
5446 \begin_layout Section
5447 Components of SDCC
5448 \end_layout
5449
5450 \begin_layout Standard
5451 SDCC is not just a compiler, but a collection of tools by various developers.
5452  These include linkers, assemblers, simulators and other components.
5453  Here is a summary of some of the components.
5454  Note that the included simulator and assembler have separate documentation
5455  which you can find in the source package in their respective directories.
5456  As SDCC grows to include support for other processors, other packages from
5457  various developers are included and may have their own sets of documentation.
5458 \newline
5459
5460 \newline
5461 You
5462  might want to look at the files which are installed in <installdir>.
5463  At the time of this writing, we find the following programs for gcc-builds:
5464 \newline
5465
5466  
5467 \newline
5468 In <installdir>/bin:
5469 \end_layout
5470
5471 \begin_layout Itemize
5472 sdcc - The compiler.
5473 \end_layout
5474
5475 \begin_layout Itemize
5476 sdcpp - The C preprocessor.
5477 \end_layout
5478
5479 \begin_layout Itemize
5480 asx8051 - The assembler for 8051 type processors.
5481 \end_layout
5482
5483 \begin_layout Itemize
5484 as-z80
5485 \series bold
5486
5487 \series default
5488 as-gbz80 - The Z80 and GameBoy Z80 assemblers.
5489 \end_layout
5490
5491 \begin_layout Itemize
5492 aslink -The linker for 8051 type processors.
5493 \end_layout
5494
5495 \begin_layout Itemize
5496 link-z80
5497 \series bold
5498
5499 \series default
5500 link-gbz80 - The Z80 and GameBoy Z80 linkers.
5501 \end_layout
5502
5503 \begin_layout Itemize
5504 s51 - The ucSim 8051 simulator.
5505 \end_layout
5506
5507 \begin_layout Itemize
5508 sdcdb - The source debugger.
5509 \end_layout
5510
5511 \begin_layout Itemize
5512 packihx - A tool to pack (compress) Intel hex files.
5513 \end_layout
5514
5515 \begin_layout Standard
5516 In <installdir>/share/sdcc/include
5517 \end_layout
5518
5519 \begin_layout Itemize
5520 the include files
5521 \end_layout
5522
5523 \begin_layout Standard
5524 In <installdir>/share/sdcc/lib
5525 \end_layout
5526
5527 \begin_layout Itemize
5528 the subdirs src and small, large, z80, gbz80 and ds390 with the precompiled
5529  relocatables.
5530 \end_layout
5531
5532 \begin_layout Standard
5533 In <installdir>/share/sdcc/doc
5534 \end_layout
5535
5536 \begin_layout Itemize
5537 the documentation
5538 \end_layout
5539
5540 \begin_layout Standard
5541 As development for other processors proceeds, this list will expand to include
5542  executables to support processors like AVR, PIC, etc.
5543 \end_layout
5544
5545 \begin_layout Subsection
5546 sdcc - The Compiler
5547 \end_layout
5548
5549 \begin_layout Standard
5550 This is the actual compiler, it in turn uses the c-preprocessor and invokes
5551  the assembler and linkage editor.
5552 \end_layout
5553
5554 \begin_layout Subsection
5555 sdcpp - The C-Preprocessor
5556 \end_layout
5557
5558 \begin_layout Standard
5559 The preprocessor
5560 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
5561
5562 \end_inset
5563
5564  is a modified version of the GNU cpp
5565 \begin_inset LatexCommand \index{cpp|see{sdcpp}}
5566
5567 \end_inset
5568
5569  preprocessor 
5570 \begin_inset LatexCommand \url{http://gcc.gnu.org/}
5571
5572 \end_inset
5573
5574 .
5575  The C preprocessor is used to pull in #include sources, process #ifdef
5576  statements, #defines and so on.
5577 \end_layout
5578
5579 \begin_layout Subsection
5580 as
5581 \emph on
5582 xxxx
5583 \emph default
5584 , aslink, link-
5585 \emph on
5586 xxx
5587 \emph default
5588  - The Assemblers and Linkage Editors
5589 \end_layout
5590
5591 \begin_layout Standard
5592 This is retargettable assembler & linkage editor, it was developed by Alan
5593  Baldwin.
5594  John Hartman created the version for 8051, and I (Sandeep) have made some
5595  enhancements and bug fixes for it to work properly with SDCC.
5596 \end_layout
5597
5598 \begin_layout Subsection
5599 s51 - The Simulator
5600 \end_layout
5601
5602 \begin_layout Standard
5603 S51
5604 \begin_inset LatexCommand \index{s51}
5605
5606 \end_inset
5607
5608  is a free open source simulator developed by Daniel Drotos.
5609  The simulator is built as part of the build process.
5610  For more information visit Daniel's web site at: 
5611 \begin_inset LatexCommand \url{http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51}
5612
5613 \end_inset
5614
5615 .
5616  It currently supports the core mcs51, the Dallas DS80C390 and the Phillips
5617  XA51 family.
5618 \end_layout
5619
5620 \begin_layout Subsection
5621 sdcdb - Source Level Debugger
5622 \end_layout
5623
5624 \begin_layout Standard
5625 SDCDB
5626 \begin_inset LatexCommand \index{SDCDB (debugger)}
5627
5628 \end_inset
5629
5630  is the companion source level debugger.
5631  More about SDCDB in section 
5632 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
5633
5634 \end_inset
5635
5636 .
5637  The current version of the debugger uses Daniel's Simulator S51
5638 \begin_inset LatexCommand \index{s51}
5639
5640 \end_inset
5641
5642 , but can be easily changed to use other simulators.
5643 \end_layout
5644
5645 \begin_layout Chapter
5646 Using SDCC
5647 \end_layout
5648
5649 \begin_layout Section
5650 Compiling
5651 \end_layout
5652
5653 \begin_layout Subsection
5654 Single Source File Projects
5655 \end_layout
5656
5657 \begin_layout Standard
5658 For single source file 8051 projects the process is very simple.
5659  Compile your programs with the following command 
5660 \family sans
5661 \series bold
5662 "sdcc sourcefile.c".
5663
5664 \family default
5665 \series default
5666  This will compile, assemble and link your source file.
5667  Output files are as follows:
5668 \end_layout
5669
5670 \begin_layout Itemize
5671 sourcefile.asm
5672 \begin_inset LatexCommand \index{<file>.asm}
5673
5674 \end_inset
5675
5676  - Assembler source
5677 \begin_inset LatexCommand \index{Assembler source}
5678
5679 \end_inset
5680
5681  file created by the compiler
5682 \end_layout
5683
5684 \begin_layout Itemize
5685 sourcefile.lst
5686 \begin_inset LatexCommand \index{<file>.lst}
5687
5688 \end_inset
5689
5690  - Assembler listing
5691 \begin_inset LatexCommand \index{Assembler listing}
5692
5693 \end_inset
5694
5695  file created by the Assembler
5696 \end_layout
5697
5698 \begin_layout Itemize
5699 sourcefile.rst
5700 \begin_inset LatexCommand \index{<file>.rst}
5701
5702 \end_inset
5703
5704  - Assembler listing
5705 \begin_inset LatexCommand \index{Assembler listing}
5706
5707 \end_inset
5708
5709  file updated with linkedit information, created by linkage editor
5710 \end_layout
5711
5712 \begin_layout Itemize
5713 sourcefile.sym
5714 \begin_inset LatexCommand \index{<file>.sym}
5715
5716 \end_inset
5717
5718  - symbol listing
5719 \begin_inset LatexCommand \index{Symbol listing}
5720
5721 \end_inset
5722
5723  for the sourcefile, created by the assembler
5724 \end_layout
5725
5726 \begin_layout Itemize
5727 sourcefile.rel
5728 \begin_inset LatexCommand \index{<file>.rel}
5729
5730 \end_inset
5731
5732  or sourcefile.o
5733 \begin_inset LatexCommand \index{<file>.o}
5734
5735 \end_inset
5736
5737  - Object file
5738 \begin_inset LatexCommand \index{Object file}
5739
5740 \end_inset
5741
5742  created by the assembler, input to Linkage editor
5743 \end_layout
5744
5745 \begin_layout Itemize
5746 sourcefile.map
5747 \begin_inset LatexCommand \index{<file>.map}
5748
5749 \end_inset
5750
5751  - The memory map
5752 \begin_inset LatexCommand \index{Memory map}
5753
5754 \end_inset
5755
5756  for the load module, created by the Linker
5757 \end_layout
5758
5759 \begin_layout Itemize
5760 sourcefile.mem
5761 \begin_inset LatexCommand \index{<file>.mem}
5762
5763 \end_inset
5764
5765  - A file with a summary of the memory usage
5766 \end_layout
5767
5768 \begin_layout Itemize
5769 sourcefile.ihx
5770 \begin_inset LatexCommand \index{<file>.ihx}
5771
5772 \end_inset
5773
5774  - The load module in Intel hex format
5775 \begin_inset LatexCommand \index{Intel hex format}
5776
5777 \end_inset
5778
5779  (you can select the Motorola S19 format
5780 \begin_inset LatexCommand \index{Motorola S19 format}
5781
5782 \end_inset
5783
5784  with -
5785 \begin_inset ERT
5786 status collapsed
5787
5788 \begin_layout Standard
5789
5790
5791 \backslash
5792 /
5793 \end_layout
5794
5795 \end_inset
5796
5797 -out-fmt-s19
5798 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
5799
5800 \end_inset
5801
5802 .
5803  If you need another format you might want to use 
5804 \family sans
5805 \shape italic
5806 objdump
5807 \family default
5808 \shape default
5809
5810 \begin_inset LatexCommand \index{objdump (tool)}
5811
5812 \end_inset
5813
5814  or
5815 \family sans
5816 \shape italic
5817  srecord
5818 \family default
5819 \shape default
5820
5821 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5822
5823 \end_inset
5824
5825
5826 \begin_inset Note Note
5827 status collapsed
5828
5829 \begin_layout Standard
5830 hyperlinks needed
5831 \end_layout
5832
5833 \end_inset
5834
5835  - see also section 
5836 \begin_inset LatexCommand \vref{sub:Postprocessing-the-Intel}
5837
5838 \end_inset
5839
5840 ).
5841  Both formats are documented in the documentation of srecord
5842 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5843
5844 \end_inset
5845
5846
5847 \end_layout
5848
5849 \begin_layout Itemize
5850 sourcefile.adb
5851 \begin_inset LatexCommand \index{<file>.adb}
5852
5853 \end_inset
5854
5855  - An intermediate file containing debug information needed to create the
5856  .cdb file (with -
5857 \begin_inset ERT
5858 status collapsed
5859
5860 \begin_layout Standard
5861
5862
5863 \backslash
5864 /
5865 \end_layout
5866
5867 \end_inset
5868
5869 -debug
5870 \begin_inset LatexCommand \index{-\/-debug}
5871
5872 \end_inset
5873
5874
5875 \end_layout
5876
5877 \begin_layout Itemize
5878 sourcefile.cdb
5879 \begin_inset LatexCommand \index{<file>.cdb}
5880
5881 \end_inset
5882
5883  - An optional file (with -
5884 \begin_inset ERT
5885 status collapsed
5886
5887 \begin_layout Standard
5888
5889
5890 \backslash
5891 /
5892 \end_layout
5893
5894 \end_inset
5895
5896 -debug) containing debug information.
5897  The format is documented in cdbfileformat.pdf
5898 \end_layout
5899
5900 \begin_layout Itemize
5901 sourcefile.
5902  - (no extension)
5903 \begin_inset LatexCommand \index{<file> (no extension)}
5904
5905 \end_inset
5906
5907  An optional AOMF or AOMF51
5908 \begin_inset LatexCommand \index{AOMF, AOMF51}
5909
5910 \end_inset
5911
5912  
5913 \begin_inset LatexCommand \label{OMF file}
5914
5915 \end_inset
5916
5917 file containing debug information (generated with option -
5918 \begin_inset ERT
5919 status collapsed
5920
5921 \begin_layout Standard
5922
5923
5924 \backslash
5925 /
5926 \end_layout
5927
5928 \end_inset
5929
5930 -debug).
5931  The (Intel)
5932 \emph on
5933  a
5934 \emph default
5935 bsolute 
5936 \emph on
5937 o
5938 \emph default
5939 bject 
5940 \emph on
5941 m
5942 \emph default
5943 odule 
5944 \emph on
5945 f
5946 \emph default
5947 ormat is a subformat of the OMF51 format and is commonly used by third party
5948  tools (debuggers
5949 \begin_inset LatexCommand \index{Debugger}
5950
5951 \end_inset
5952
5953 , simulators, emulators).
5954 \end_layout
5955
5956 \begin_layout Itemize
5957 sourcefile.dump*
5958 \begin_inset LatexCommand \index{<file>.dump*}
5959
5960 \end_inset
5961
5962  - Dump file to debug the compiler it self (generated with option -
5963 \begin_inset ERT
5964 status collapsed
5965
5966 \begin_layout Standard
5967
5968
5969 \backslash
5970 /
5971 \end_layout
5972
5973 \end_inset
5974
5975 -dumpall) (see section 
5976 \begin_inset LatexCommand \ref{sub:Intermediate-Dump-Options}
5977
5978 \end_inset
5979
5980 \InsetSpace ~
5981  and section 
5982 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
5983
5984 \end_inset
5985
5986 \InsetSpace ~
5987
5988 \begin_inset Quotes sld
5989 \end_inset
5990
5991 Anatomy of the compiler
5992 \begin_inset Quotes srd
5993 \end_inset
5994
5995 ).
5996 \end_layout
5997
5998 \begin_layout Subsection
5999 Postprocessing the Intel Hex
6000 \begin_inset LatexCommand \index{Intel hex format}
6001
6002 \end_inset
6003
6004  file
6005 \begin_inset LatexCommand \label{sub:Postprocessing-the-Intel}
6006
6007 \end_inset
6008
6009
6010 \end_layout
6011
6012 \begin_layout Standard
6013 In most cases this won't be needed but the Intel Hex file
6014 \begin_inset LatexCommand \index{<file>.ihx}
6015
6016 \end_inset
6017
6018  which is generated by SDCC might include lines of varying length and the
6019  addresses within the file are not guaranteed to be strictly ascending.
6020  If your toolchain or a bootloader does not like this you can use the tool
6021  
6022 \family typewriter
6023 packihx
6024 \family default
6025
6026 \begin_inset LatexCommand \index{packihx (tool)}
6027
6028 \end_inset
6029
6030  which is part of the SDCC distribution: 
6031 \newline
6032
6033 \newline
6034
6035 \family sans
6036 \series bold
6037  packihx sourcefile.ihx >sourcefile.hex
6038 \family default
6039 \series default
6040
6041 \newline
6042
6043 \newline
6044 The separately available
6045 \emph on
6046  srecord
6047 \emph default
6048
6049 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
6050
6051 \end_inset
6052
6053  package additionally allows to set undefined locations to a predefined
6054  value, to insert checksums
6055 \begin_inset LatexCommand \index{checksum}
6056
6057 \end_inset
6058
6059  of various flavours (crc, add, xor) and to perform other manipulations
6060  (convert, split, crop, offset, ...).
6061  
6062 \newline
6063
6064 \newline
6065
6066 \family sans
6067 \series bold
6068 srec_cat\InsetSpace ~
6069 \InsetSpace ~
6070 sourcefile.ihx -intel\InsetSpace ~
6071 \InsetSpace ~
6072 -o sourcefile.hex -intel
6073 \newline
6074
6075 \newline
6076
6077 \family default
6078 \series default
6079 An example for a more complex command line
6080 \begin_inset Foot
6081 status open
6082
6083 \begin_layout Standard
6084 the command backfills
6085 \begin_inset LatexCommand \index{backfill unused memory}
6086
6087 \end_inset
6088
6089  unused memory with 0x12 and the overall 16 bit sum of the complete 64 kByte
6090  block is zero.
6091  If the program counter on an mcs51 runs wild the backfill pattern 0x12
6092  will be interpreted as an 
6093 \family typewriter
6094 lcall
6095 \family default
6096  to address 
6097 \family typewriter
6098 0x1212
6099 \family default
6100  (where an emergency routine could sit).
6101 \end_layout
6102
6103 \end_inset
6104
6105  could look like:
6106 \newline
6107
6108 \newline
6109
6110 \family sans
6111 \series bold
6112 \size footnotesize
6113 srec_cat\InsetSpace ~
6114 sourcefile.ihx -intel\InsetSpace ~
6115 \InsetSpace ~
6116 -fill 0x12 0x0000 0xfffe\InsetSpace ~
6117 -little-endian-checksum-nega
6118 tive 0xfffe 0x02 0x02\InsetSpace ~
6119 \InsetSpace ~
6120 -o sourcefile.hex -intel
6121 \size default
6122
6123 \newline
6124
6125 \newline
6126
6127 \family default
6128 \series default
6129 The srecord package is available at 
6130 \begin_inset LatexCommand \url{http://sf.net/projects/srecord}
6131
6132 \end_inset
6133
6134  .
6135 \end_layout
6136
6137 \begin_layout Subsection
6138 Projects with Multiple Source Files
6139 \end_layout
6140
6141 \begin_layout Standard
6142 SDCC can compile only ONE file at a time.
6143  Let us for example assume that you have a project containing the following
6144  files:
6145 \newline
6146
6147 \newline
6148 foo1.c (contains some functions)
6149 \newline
6150 foo2.c (contains some more functions)
6151 \newline
6152 foomai
6153 n.c (contains more functions and the function main)
6154 \newline
6155
6156 \size footnotesize
6157
6158 \newline
6159
6160 \size default
6161 The first two files will need to be compiled separately with the commands:
6162 \size footnotesize
6163  
6164 \size default
6165
6166 \newline
6167
6168 \newline
6169
6170 \family sans
6171 \series bold
6172 sdcc\InsetSpace ~
6173 -c\InsetSpace ~
6174 foo1.c
6175 \family default
6176 \series default
6177 \size footnotesize
6178
6179 \newline
6180
6181 \family sans
6182 \series bold
6183 \size default
6184 sdcc\InsetSpace ~
6185 -c\InsetSpace ~
6186 foo2.c
6187 \family default
6188 \series default
6189
6190 \newline
6191
6192 \newline
6193 Then compile the source file containing the 
6194 \emph on
6195 main()
6196 \emph default
6197  function and link
6198 \begin_inset LatexCommand \index{Linker}
6199
6200 \end_inset
6201
6202  the files together with the following command: 
6203 \newline
6204
6205 \newline
6206
6207 \family sans
6208 \series bold
6209 sdcc\InsetSpace ~
6210 foomain.c\InsetSpace ~
6211 foo1.rel\InsetSpace ~
6212 foo2.rel
6213 \family default
6214 \series default
6215
6216 \begin_inset LatexCommand \index{<file>.rel}
6217
6218 \end_inset
6219
6220
6221 \newline
6222
6223 \newline
6224 Alternatively, 
6225 \emph on
6226 foomain.c 
6227 \emph default
6228 can be separately compiled as well: 
6229 \family sans
6230 \series bold
6231
6232 \newline
6233
6234 \newline
6235 sdcc\InsetSpace ~
6236 -c\InsetSpace ~
6237 foomain.c
6238 \newline
6239 sdcc foomain.rel foo1.rel foo2.rel
6240 \newline
6241
6242 \newline
6243
6244 \family default
6245 \series default
6246 The file containing the 
6247 \emph on
6248 main()
6249 \emph default
6250  function
6251 \emph on
6252  
6253 \emph default
6254 \noun on
6255 must
6256 \noun default
6257  be the 
6258 \noun on
6259 first
6260 \noun default
6261  file specified in the command line, since the linkage editor processes
6262  file in the order they are presented to it.
6263  The linker is invoked from SDCC using a script file with extension .lnk
6264 \begin_inset LatexCommand \index{<file>.lnk}
6265
6266 \end_inset
6267
6268 .
6269  You can view this file to troubleshoot linking problems such as those arising
6270  from missing libraries.
6271 \end_layout
6272
6273 \begin_layout Subsection
6274 Projects with Additional Libraries
6275 \begin_inset LatexCommand \index{Libraries}
6276
6277 \end_inset
6278
6279
6280 \end_layout
6281
6282 \begin_layout Standard
6283 Some reusable routines may be compiled into a library, see the documentation
6284  for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc)
6285  for how to create a 
6286 \emph on
6287 .lib
6288 \begin_inset LatexCommand \index{<file>.lib}
6289
6290 \end_inset
6291
6292
6293 \emph default
6294  library file.
6295  Libraries created in this manner can be included in the command line.
6296  Make sure you include the -L <library-path> option to tell the linker where
6297  to look for these files if they are not in the current directory.
6298  Here is an example, assuming you have the source file 
6299 \emph on
6300 foomain.c
6301 \emph default
6302  and a library
6303 \emph on
6304  foolib.lib
6305 \emph default
6306  in the directory 
6307 \emph on
6308 mylib
6309 \emph default
6310  (if that is not the same as your current project):
6311 \newline
6312
6313 \newline
6314
6315 \family sans
6316 \series bold
6317 sdcc foomain.c foolib.lib -L mylib
6318 \newline
6319
6320 \newline
6321
6322 \family default
6323 \series default
6324 Note here that
6325 \emph on
6326  mylib
6327 \emph default
6328  must be an absolute path name.
6329 \newline
6330
6331 \newline
6332 The most efficient way to use libraries is
6333  to keep separate modules in separate source files.
6334  The lib file now should name all the modules.rel
6335 \begin_inset LatexCommand \index{<file>.rel}
6336
6337 \end_inset
6338
6339  files.
6340  For an example see the standard library file 
6341 \emph on
6342 libsdcc.lib
6343 \emph default
6344  in the directory <installdir>/share/lib/small.
6345 \end_layout
6346
6347 \begin_layout Subsection
6348 Using sdcclib to Create and Manage Libraries
6349 \begin_inset LatexCommand \index{sdcclib}
6350
6351 \end_inset
6352
6353
6354 \end_layout
6355
6356 \begin_layout Standard
6357 Alternatively, instead of having a .rel file for each entry on the library
6358  file as described in the preceding section, sdcclib can be used to embed
6359  all the modules belonging to such library in the library file itself.
6360  This results in a larger library file, but it greatly reduces the number
6361  of disk files accessed by the linker.
6362   Additionally, the packed library file contains an index of all include
6363  modules and symbols that significantly speeds up the linking process.
6364  To display a list of options supported by sdcclib type:
6365 \newline
6366
6367 \end_layout
6368
6369 \begin_layout Standard
6370
6371 \family sans
6372 \series bold
6373 sdcclib -?
6374 \begin_inset LatexCommand \index{sdcclib}
6375
6376 \end_inset
6377
6378
6379 \newline
6380
6381 \newline
6382
6383 \family default
6384 \series default
6385 To create a new library file, start by compiling all the required modules.
6386  For example:
6387 \newline
6388
6389 \end_layout
6390
6391 \begin_layout Standard
6392
6393 \family sans
6394 \series bold
6395 sdcc -c _divsint.c
6396 \end_layout
6397
6398 \begin_layout Standard
6399
6400 \family sans
6401 \series bold
6402 sdcc -c _divuint.c
6403 \end_layout
6404
6405 \begin_layout Standard
6406
6407 \family sans
6408 \series bold
6409 sdcc -c _modsint.c
6410 \end_layout
6411
6412 \begin_layout Standard
6413
6414 \family sans
6415 \series bold
6416 sdcc -c _moduint.c
6417 \end_layout
6418
6419 \begin_layout Standard
6420
6421 \family sans
6422 \series bold
6423 sdcc -c _mulint.c
6424 \newline
6425
6426 \end_layout
6427
6428 \begin_layout Standard
6429 This will create files _divsint.rel, _divuint.rel, _modsint.rel, _moduint.rel,
6430  and _mulint.rel.
6431  The next step is to add the .rel files to the library file:
6432 \newline
6433
6434 \end_layout
6435
6436 \begin_layout Standard
6437
6438 \family sans
6439 \series bold
6440 sdcclib libint.lib _divsint.rel
6441 \family default
6442
6443 \begin_inset LatexCommand \index{sdcclib}
6444
6445 \end_inset
6446
6447
6448 \end_layout
6449
6450 \begin_layout Standard
6451
6452 \family sans
6453 \series bold
6454 sdcclib libint.lib _divuint.rel
6455 \end_layout
6456
6457 \begin_layout Standard
6458
6459 \family sans
6460 \series bold
6461 sdcclib libint.lib _modsint.rel
6462 \end_layout
6463
6464 \begin_layout Standard
6465
6466 \family sans
6467 \series bold
6468 sdcclib libint.lib _moduint.rel
6469 \end_layout
6470
6471 \begin_layout Standard
6472
6473 \family sans
6474 \series bold
6475 sdcclib libint.lib _mulint.rel
6476 \family default
6477 \series default
6478
6479 \newline
6480
6481 \end_layout
6482
6483 \begin_layout Standard
6484 Or, if you preffer:
6485 \family sans
6486 \series bold
6487
6488 \newline
6489
6490 \end_layout
6491
6492 \begin_layout Standard
6493
6494 \family sans
6495 \series bold
6496 sdcclib libint.lib _divsint.rel _divuint.rel _modsint.rel _moduint.rel _mulint.rel
6497 \family default
6498 \series default
6499
6500 \newline
6501
6502 \end_layout
6503
6504 \begin_layout Standard
6505 If the file already exists in the library, it will be replaced.
6506  If a list of .rel files is available, you can tell sdcclib to add those
6507  files to a library.
6508  For example, if the file 'myliblist.txt' contains
6509 \family sans
6510 \series bold
6511
6512 \newline
6513
6514 \end_layout
6515
6516 \begin_layout Standard
6517
6518 \family sans
6519 \series bold
6520 _divsint.rel
6521 \end_layout
6522
6523 \begin_layout Standard
6524
6525 \family sans
6526 \series bold
6527 _divuint.rel
6528 \end_layout
6529
6530 \begin_layout Standard
6531
6532 \family sans
6533 \series bold
6534 _modsint.rel
6535 \end_layout
6536
6537 \begin_layout Standard
6538
6539 \family sans
6540 \series bold
6541 _moduint.rel
6542 \end_layout
6543
6544 \begin_layout Standard
6545
6546 \family sans
6547 \series bold
6548 _mulint.rel
6549 \family default
6550 \series default
6551
6552 \newline
6553
6554 \end_layout
6555
6556 \begin_layout Standard
6557 Use
6558 \family sans
6559 \series bold
6560
6561 \newline
6562
6563 \end_layout
6564
6565 \begin_layout Standard
6566
6567 \family sans
6568 \series bold
6569 sdcclib -l libint.lib myliblist.txt
6570 \family default
6571 \series default
6572
6573 \newline
6574
6575 \end_layout
6576
6577 \begin_layout Standard
6578 Additionally, you can instruct sdcclib to compiles the files before adding
6579  them to the library.
6580  This is achieved using the environment variables SDCCLIB_CC and/or SDCCLIB_AS.
6581  For example:
6582 \family sans
6583 \series bold
6584
6585 \newline
6586
6587 \end_layout
6588
6589 \begin_layout Standard
6590
6591 \family sans
6592 \series bold
6593 set SDCCLIB_CC=sdcc -c
6594 \end_layout
6595
6596 \begin_layout Standard
6597
6598 \family sans
6599 \series bold
6600 sdcclib -l libint.lib myliblist.txt
6601 \family default
6602 \series default
6603
6604 \newline
6605
6606 \end_layout
6607
6608 \begin_layout Standard
6609 To see what modules and symbols are included in the library, options -s
6610  and -m are available.
6611  For example:
6612 \newline
6613
6614 \newline
6615
6616 \family sans
6617 \series bold
6618 sdcclib -s libint.lib
6619 \family default
6620
6621 \begin_inset LatexCommand \index{sdcclib}
6622
6623 \end_inset
6624
6625
6626 \newline
6627
6628 \family typewriter
6629 \series default
6630 _divsint.rel:
6631 \end_layout
6632
6633 \begin_layout Standard
6634
6635 \family typewriter
6636 __divsint_a_1_1
6637 \end_layout
6638
6639 \begin_layout Standard
6640
6641 \family typewriter
6642 __divsint_PARM_2
6643 \end_layout
6644
6645 \begin_layout Standard
6646
6647 \family typewriter
6648 __divsint
6649 \newline
6650 _divuint.rel:
6651 \end_layout
6652
6653 \begin_layout Standard
6654
6655 \family typewriter
6656 __divuint_a_1_1
6657 \end_layout
6658
6659 \begin_layout Standard
6660
6661 \family typewriter
6662 __divuint_PARM_2
6663 \end_layout
6664
6665 \begin_layout Standard
6666
6667 \family typewriter
6668 __divuint_reste_1_1
6669 \end_layout
6670
6671 \begin_layout Standard
6672
6673 \family typewriter
6674 __divuint_count_1_1
6675 \end_layout
6676
6677 \begin_layout Standard
6678
6679 \family typewriter
6680 __divuint
6681 \newline
6682 _modsint.rel:
6683 \end_layout
6684
6685 \begin_layout Standard
6686
6687 \family typewriter
6688 __modsint_a_1_1
6689 \end_layout
6690
6691 \begin_layout Standard
6692
6693 \family typewriter
6694 __modsint_PARM_2
6695 \end_layout
6696
6697 \begin_layout Standard
6698
6699 \family typewriter
6700 __modsint
6701 \newline
6702 _moduint.rel:
6703 \end_layout
6704
6705 \begin_layout Standard
6706
6707 \family typewriter
6708 __moduint_a_1_1
6709 \end_layout
6710
6711 \begin_layout Standard
6712
6713 \family typewriter
6714 __moduint_PARM_2
6715 \end_layout
6716
6717 \begin_layout Standard
6718
6719 \family typewriter
6720 __moduint_count_1_1
6721 \end_layout
6722
6723 \begin_layout Standard
6724
6725 \family typewriter
6726 __moduint
6727 \newline
6728 _mulint.rel:
6729 \end_layout
6730
6731 \begin_layout Standard
6732
6733 \family typewriter
6734 __mulint_PARM_2
6735 \end_layout
6736
6737 \begin_layout Standard
6738
6739 \family typewriter
6740 __mulint
6741 \family default
6742 \series bold
6743
6744 \newline
6745
6746 \end_layout
6747
6748 \begin_layout Standard
6749 If the source files are compiled using -
6750 \begin_inset ERT
6751 status collapsed
6752
6753 \begin_layout Standard
6754
6755
6756 \backslash
6757 /
6758 \end_layout
6759
6760 \end_inset
6761
6762 -debug
6763 \begin_inset LatexCommand \index{-\/-debug}
6764
6765 \end_inset
6766
6767 , the corresponding debug information file .adb will be include in the library
6768  file as well.
6769  The library files created with sdcclib are plain text files, so they can
6770  be viewed with a text editor.
6771  It is not recomended to modify a library file created with sdcclib using
6772  a text editor, as there are file indexes numbers located accross the file
6773  used by the linker to quickly locate the required module to link.
6774  Once a .rel file (as well as a .adb file) is added to a library using sdcclib,
6775  it can be safely deleted, since all the information required for linking
6776  is embedded in the library file itself.
6777  Library files created using sdcclib are used as described in the preceding
6778  sections.
6779 \begin_inset VSpace bigskip
6780 \end_inset
6781
6782
6783 \end_layout
6784
6785 \begin_layout Section
6786 Command Line Options
6787 \begin_inset LatexCommand \index{Command Line Options}
6788
6789 \end_inset
6790
6791
6792 \begin_inset LatexCommand \label{sec:Command-Line-Options}
6793
6794 \end_inset
6795
6796
6797 \end_layout
6798
6799 \begin_layout Subsection
6800 Processor Selection Options
6801 \begin_inset LatexCommand \index{Options processor selection}
6802
6803 \end_inset
6804
6805
6806 \begin_inset LatexCommand \index{Processor selection options}
6807
6808 \end_inset
6809
6810
6811 \end_layout
6812
6813 \begin_layout List
6814 \labelwidthstring 00.00.0000
6815
6816 \series bold
6817 -mmcs51
6818 \begin_inset LatexCommand \index{-mmcs51}
6819
6820 \end_inset
6821
6822
6823 \series default
6824  Generate code for the Intel MCS51
6825 \begin_inset LatexCommand \index{MCS51}
6826
6827 \end_inset
6828
6829  family of processors.
6830  This is the default processor target.
6831 \end_layout
6832
6833 \begin_layout List
6834 \labelwidthstring 00.00.0000
6835
6836 \series bold
6837 -mds390
6838 \begin_inset LatexCommand \index{-mds390}
6839
6840 \end_inset
6841
6842
6843 \series default
6844  Generate code for the Dallas DS80C390
6845 \begin_inset LatexCommand \index{DS80C390}
6846
6847 \end_inset
6848
6849  processor.
6850 \end_layout
6851
6852 \begin_layout List
6853 \labelwidthstring 00.00.0000
6854
6855 \series bold
6856 -mds400
6857 \begin_inset LatexCommand \index{-mds400}
6858
6859 \end_inset
6860
6861
6862 \series default
6863  Generate code for the Dallas DS80C400
6864 \begin_inset LatexCommand \index{DS80C400}
6865
6866 \end_inset
6867
6868  processor.
6869 \end_layout
6870
6871 \begin_layout List
6872 \labelwidthstring 00.00.0000
6873
6874 \series bold
6875 -mhc08
6876 \begin_inset LatexCommand \index{-mhc08}
6877
6878 \end_inset
6879
6880
6881 \series default
6882  Generate code for the Freescale/Motorola HC08
6883 \begin_inset LatexCommand \index{HC08}
6884
6885 \end_inset
6886
6887  family of processors.
6888 \end_layout
6889
6890 \begin_layout List
6891 \labelwidthstring 00.00.0000
6892
6893 \series bold
6894 -mz80
6895 \begin_inset LatexCommand \index{-mz80}
6896
6897 \end_inset
6898
6899
6900 \series default
6901  Generate code for the Zilog Z80
6902 \begin_inset LatexCommand \index{Z80}
6903
6904 \end_inset
6905
6906  family of processors.
6907 \end_layout
6908
6909 \begin_layout List
6910 \labelwidthstring 00.00.0000
6911
6912 \series bold
6913 -mgbz80
6914 \begin_inset LatexCommand \index{-mgbz80}
6915
6916 \end_inset
6917
6918
6919 \series default
6920  Generate code for the GameBoy Z80
6921 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
6922
6923 \end_inset
6924
6925  processor (Not actively maintained).
6926 \end_layout
6927
6928 \begin_layout List
6929 \labelwidthstring 00.00.0000
6930
6931 \series bold
6932 -mavr
6933 \begin_inset LatexCommand \index{-mavr}
6934
6935 \end_inset
6936
6937
6938 \series default
6939  Generate code for the Atmel AVR
6940 \begin_inset LatexCommand \index{AVR}
6941
6942 \end_inset
6943
6944  processor (Not maintained, not complete).
6945  AVR users should probably have a look at winavr 
6946 \begin_inset LatexCommand \url{http://sourceforge.net/projects/winavr}
6947
6948 \end_inset
6949
6950  or 
6951 \begin_inset LatexCommand \url{http://www.avrfreaks.net/index.php?name=PNphpBB2&file=index}
6952
6953 \end_inset
6954
6955 , which is based on AVR-port of the gcc compiler.
6956 \end_layout
6957
6958 \begin_layout Standard
6959 \begin_inset Note Note
6960 status collapsed
6961
6962 \begin_layout Standard
6963 I think it is fair to direct users there for now.
6964  Open source is also about avoiding unnecessary work .
6965  But I didn't find the 'official' link.
6966 \end_layout
6967
6968 \end_inset
6969
6970
6971 \end_layout
6972
6973 \begin_layout List
6974 \labelwidthstring 00.00.0000
6975
6976 \series bold
6977 -mpic14
6978 \begin_inset LatexCommand \index{-mpic14}
6979
6980 \end_inset
6981
6982
6983 \series default
6984  Generate code for the Microchip PIC 14
6985 \begin_inset LatexCommand \index{PIC14}
6986
6987 \end_inset
6988
6989 -bit processors (p16f84 and variants.
6990  In development, not complete).
6991 \end_layout
6992
6993 \begin_layout Standard
6994 \begin_inset Note Note
6995 status collapsed
6996
6997 \begin_layout Standard
6998 p16f627 p16f628 p16f84 p16f873 p16f877?
6999 \end_layout
7000
7001 \end_inset
7002
7003
7004 \end_layout
7005
7006 \begin_layout List
7007 \labelwidthstring 00.00.0000
7008
7009 \series bold
7010 -mpic16
7011 \begin_inset LatexCommand \index{-mpic16}
7012
7013 \end_inset
7014
7015
7016 \series default
7017  Generate code for the Microchip PIC 16
7018 \begin_inset LatexCommand \index{PIC16}
7019
7020 \end_inset
7021
7022 -bit processors (p18f452 and variants.
7023  In development, not complete).
7024 \end_layout
7025
7026 \begin_layout List
7027 \labelwidthstring 00.00.0000
7028
7029 \series bold
7030 -mtlcs900h
7031 \series default
7032  Generate code for the Toshiba TLCS-900H
7033 \begin_inset LatexCommand \index{TLCS-900H}
7034
7035 \end_inset
7036
7037  processor (Not maintained, not complete).
7038 \end_layout
7039
7040 \begin_layout List
7041 \labelwidthstring 00.00.0000
7042
7043 \series bold
7044 -mxa51
7045 \begin_inset LatexCommand \index{-mxa51}
7046
7047 \end_inset
7048
7049
7050 \series default
7051  Generate code for the Phillips XA51
7052 \begin_inset LatexCommand \index{XA51}
7053
7054 \end_inset
7055
7056  processor (Not maintained, not complete).
7057 \end_layout
7058
7059 \begin_layout Standard
7060 \begin_inset VSpace bigskip
7061 \end_inset
7062
7063
7064 \end_layout
7065
7066 \begin_layout Subsection
7067 Preprocessor Options
7068 \begin_inset LatexCommand \index{Options preprocessor}
7069
7070 \end_inset
7071
7072
7073 \begin_inset LatexCommand \index{Preprocessor options}
7074
7075 \end_inset
7076
7077
7078 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
7079
7080 \end_inset
7081
7082
7083 \end_layout
7084
7085 \begin_layout List
7086 \labelwidthstring 00.00.0000
7087
7088 \series bold
7089 -I<path>
7090 \begin_inset LatexCommand \index{-I<path>}
7091
7092 \end_inset
7093
7094
7095 \series default
7096  The additional location where the preprocessor will look for <..h> or 
7097 \begin_inset Quotes eld
7098 \end_inset
7099
7100 ..h
7101 \begin_inset Quotes erd
7102 \end_inset
7103
7104  files.
7105 \end_layout
7106
7107 \begin_layout List
7108 \labelwidthstring 00.00.0000
7109
7110 \series bold
7111 -D<macro[=value]>
7112 \begin_inset LatexCommand \index{-D<macro[=value]>}
7113
7114 \end_inset
7115
7116
7117 \series default
7118  Command line definition of macros.
7119  Passed to the preprocessor.
7120 \end_layout
7121
7122 \begin_layout List
7123 \labelwidthstring 00.00.0000
7124
7125 \series bold
7126 -M
7127 \begin_inset LatexCommand \index{-M}
7128
7129 \end_inset
7130
7131
7132 \series default
7133  Tell the preprocessor to output a rule suitable for make describing the
7134  dependencies of each object file.
7135  For each source file, the preprocessor outputs one make-rule whose target
7136  is the object file name for that source file and whose dependencies are
7137  all the files `#include'd in it.
7138  This rule may be a single line or may be continued with `
7139 \backslash
7140 '-newline if it is long.
7141  The list of rules is printed on standard output instead of the preprocessed
7142  C program.
7143  `-M' implies `-E
7144 \begin_inset LatexCommand \index{-E}
7145
7146 \end_inset
7147
7148 '.
7149 \end_layout
7150
7151 \begin_layout List
7152 \labelwidthstring 00.00.0000
7153
7154 \series bold
7155 -C
7156 \begin_inset LatexCommand \index{-C}
7157
7158 \end_inset
7159
7160
7161 \series default
7162  Tell the preprocessor not to discard comments.
7163  Used with the `-E' option.
7164 \end_layout
7165
7166 \begin_layout List
7167 \labelwidthstring 00.00.0000
7168
7169 \series bold
7170 -MM
7171 \begin_inset LatexCommand \index{-MM}
7172
7173 \end_inset
7174
7175
7176 \size large
7177 \bar under
7178  
7179 \series default
7180 \size default
7181 \bar default
7182 Like `-M' but the output mentions only the user header files included with
7183  `#include 
7184 \begin_inset Quotes eld
7185 \end_inset
7186
7187 file"'.
7188  System header files included with `#include <file>' are omitted.
7189 \end_layout
7190
7191 \begin_layout List
7192 \labelwidthstring 00.00.0000
7193
7194 \series bold
7195 -Aquestion(answer)
7196 \begin_inset LatexCommand \index{-Aquestion(answer)}
7197
7198 \end_inset
7199
7200
7201 \series default
7202  Assert the answer answer for question, in case it is tested with a preprocessor
7203  conditional such as `#if #question(answer)'.
7204  `-A-' disables the standard assertions that normally describe the target
7205  machine.
7206 \end_layout
7207
7208 \begin_layout List
7209 \labelwidthstring 00.00.0000
7210
7211 \series bold
7212 -Umacro
7213 \begin_inset LatexCommand \index{-Umacro}
7214
7215 \end_inset
7216
7217
7218 \series default
7219  Undefine macro macro.
7220  `-U' options are evaluated after all `-D' options, but before any `-include'
7221  and `-imacros' options.
7222 \end_layout
7223
7224 \begin_layout List
7225 \labelwidthstring 00.00.0000
7226
7227 \series bold
7228 -dM
7229 \begin_inset LatexCommand \index{-dM}
7230
7231 \end_inset
7232
7233
7234 \series default
7235  Tell the preprocessor to output only a list of the macro definitions that
7236  are in effect at the end of preprocessing.
7237  Used with the `-E' option.
7238 \end_layout
7239
7240 \begin_layout List
7241 \labelwidthstring 00.00.0000
7242
7243 \series bold
7244 -dD
7245 \begin_inset LatexCommand \index{-dD}
7246
7247 \end_inset
7248
7249
7250 \series default
7251  Tell the preprocessor to pass all macro definitions into the output, in
7252  their proper sequence in the rest of the output.
7253 \end_layout
7254
7255 \begin_layout List
7256 \labelwidthstring 00.00.0000
7257
7258 \series bold
7259 -dN
7260 \begin_inset LatexCommand \index{-dN}
7261
7262 \end_inset
7263
7264
7265 \size large
7266 \bar under
7267  
7268 \series default
7269 \size default
7270 \bar default
7271 Like `-dD' except that the macro arguments and contents are omitted.
7272  Only `#define name' is included in the output.
7273 \end_layout
7274
7275 \begin_layout List
7276 \labelwidthstring 00.00.0000
7277
7278 \series bold
7279 -pedantic-parse-number
7280 \begin_inset LatexCommand \index{pedantic}
7281
7282 \end_inset
7283
7284
7285 \begin_inset LatexCommand \index{-pedantic-parse-number}
7286
7287 \end_inset
7288
7289
7290 \size large
7291 \bar under
7292
7293 \begin_inset LatexCommand \label{lyx:-pedantic-parse-number}
7294
7295 \end_inset
7296
7297  
7298 \series default
7299 \size default
7300 \bar default
7301 Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed properly
7302  and the macro LO_B(3) gets expanded.
7303  See also #pragma pedantic_parse_number 
7304 \begin_inset LatexCommand \vpageref{ite:pedantic_parse_number}
7305
7306 \end_inset
7307
7308  in section
7309 \begin_inset LatexCommand \ref{sec:Pragmas}
7310
7311 \end_inset
7312
7313  
7314 \emph on
7315 Note: this functionality is not in conformance with C99 standard!
7316 \end_layout
7317
7318 \begin_layout List
7319 \labelwidthstring 00.00.0000
7320
7321 \series bold
7322 -Wp\InsetSpace ~
7323 preprocessorOption[,preprocessorOption]
7324 \series default
7325
7326 \begin_inset LatexCommand \index{-Wp preprocessorOption[,preprocessorOption]}
7327
7328 \end_inset
7329
7330 ...
7331  Pass the preprocessorOption to the preprocessor 
7332 \family typewriter
7333 sdcpp
7334 \family default
7335
7336 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
7337
7338 \end_inset
7339
7340 .
7341  SDCC uses an adapted version of the preprocessor 
7342 \emph on
7343 cpp
7344 \emph default
7345  of the GNU Compiler Collection
7346 \begin_inset LatexCommand \index{gcc (GNU Compiler Collection)}
7347
7348 \end_inset
7349
7350  (
7351 \emph on
7352 gcc
7353 \emph default
7354  
7355 \begin_inset LatexCommand \url{http://gcc.gnu.org/}
7356
7357 \end_inset
7358
7359 ), if you need more dedicated options please refer to the GCC\InsetSpace ~
7360 4.1.1\InsetSpace ~
7361 CPP\InsetSpace ~
7362 Manual
7363  at 
7364 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/software/gcc/onlinedocs/}
7365
7366 \end_inset
7367
7368 .
7369 \end_layout
7370
7371 \begin_layout Standard
7372 \begin_inset VSpace bigskip
7373 \end_inset
7374
7375
7376 \end_layout
7377
7378 \begin_layout Subsection
7379 Linker Options
7380 \begin_inset LatexCommand \index{Options linker}
7381
7382 \end_inset
7383
7384
7385 \begin_inset LatexCommand \index{Linker options}
7386
7387 \end_inset
7388
7389
7390 \end_layout
7391
7392 \begin_layout List
7393 \labelwidthstring 00.00.0000
7394
7395 \series bold
7396 -L\InsetSpace ~
7397 -
7398 \series default
7399
7400 \begin_inset ERT
7401 status collapsed
7402
7403 \begin_layout Standard
7404
7405
7406 \backslash
7407 /
7408 \end_layout
7409
7410 \end_inset
7411
7412
7413 \series bold
7414 -lib-path
7415 \begin_inset LatexCommand \index{-\/-lib-path <path>}
7416
7417 \end_inset
7418
7419
7420 \begin_inset LatexCommand \index{-L -\/-lib-path}
7421
7422 \end_inset
7423
7424
7425 \series default
7426 \InsetSpace ~
7427 <absolute path to additional libraries> This option is passed to the linkage
7428  editor's additional libraries
7429 \begin_inset LatexCommand \index{Libraries}
7430
7431 \end_inset
7432
7433  search path.
7434  The path name must be absolute.
7435  Additional library files may be specified in the command line.
7436  See section Compiling programs for more details.
7437 \end_layout
7438
7439 \begin_layout List
7440 \labelwidthstring 00.00.0000
7441
7442 \series bold
7443 -
7444 \begin_inset ERT
7445 status collapsed
7446
7447 \begin_layout Standard
7448
7449
7450 \backslash
7451 /
7452 \end_layout
7453
7454 \end_inset
7455
7456 -xram-loc
7457 \series default
7458
7459 \begin_inset LatexCommand \index{-\/-xram-loc <Value>}
7460
7461 \end_inset
7462
7463 \InsetSpace ~
7464 <Value> The start location of the external ram
7465 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
7466
7467 \end_inset
7468
7469 , default value is 0.
7470  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7471 \begin_inset ERT
7472 status collapsed
7473
7474 \begin_layout Standard
7475
7476
7477 \backslash
7478 /
7479 \end_layout
7480
7481 \end_inset
7482
7483 -xram-loc 0x8000 or -
7484 \begin_inset ERT
7485 status collapsed
7486
7487 \begin_layout Standard
7488
7489
7490 \backslash
7491 /
7492 \end_layout
7493
7494 \end_inset
7495
7496 -xram-loc 32768.
7497 \end_layout
7498
7499 \begin_layout List
7500 \labelwidthstring 00.00.0000
7501
7502 \series bold
7503 -
7504 \begin_inset ERT
7505 status collapsed
7506
7507 \begin_layout Standard
7508
7509
7510 \backslash
7511 /
7512 \end_layout
7513
7514 \end_inset
7515
7516 -code-loc
7517 \series default
7518
7519 \begin_inset LatexCommand \index{-\/-code-loc <Value>}
7520
7521 \end_inset
7522
7523 \InsetSpace ~
7524 <Value> The start location of the code
7525 \begin_inset LatexCommand \index{code}
7526
7527 \end_inset
7528
7529  segment, default value 0.
7530  Note when this option is used the interrupt vector table
7531 \begin_inset LatexCommand \index{interrupt vector table}
7532
7533 \end_inset
7534
7535  is also relocated to the given address.
7536  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7537 \begin_inset ERT
7538 status collapsed
7539
7540 \begin_layout Standard
7541
7542
7543 \backslash
7544 /
7545 \end_layout
7546
7547 \end_inset
7548
7549 -code-loc 0x8000 or -
7550 \begin_inset ERT
7551 status collapsed
7552
7553 \begin_layout Standard
7554
7555
7556 \backslash
7557 /
7558 \end_layout
7559
7560 \end_inset
7561
7562 -code-loc 32768.
7563 \end_layout
7564
7565 \begin_layout List
7566 \labelwidthstring 00.00.0000
7567
7568 \series bold
7569 -
7570 \begin_inset ERT
7571 status collapsed
7572
7573 \begin_layout Standard
7574
7575
7576 \backslash
7577 /
7578 \end_layout
7579
7580 \end_inset
7581
7582 -stack-loc
7583 \series default
7584
7585 \begin_inset LatexCommand \index{-\/-stack-loc <Value>}
7586
7587 \end_inset
7588
7589 \InsetSpace ~
7590 <Value> By default the stack
7591 \begin_inset LatexCommand \index{stack}
7592
7593 \end_inset
7594
7595  is placed after the data segment.
7596  Using this option the stack can be placed anywhere in the internal memory
7597  space of the 8051.
7598  The value entered can be in Hexadecimal or Decimal format, e.g.
7599  -
7600 \begin_inset ERT
7601 status collapsed
7602
7603 \begin_layout Standard
7604
7605
7606 \backslash
7607 /
7608 \end_layout
7609
7610 \end_inset
7611
7612 -stack-loc 0x20 or -
7613 \begin_inset ERT
7614 status collapsed
7615
7616 \begin_layout Standard
7617
7618
7619 \backslash
7620 /
7621 \end_layout
7622
7623 \end_inset
7624
7625 -stack-loc 32.
7626  Since the sp register is incremented before a push or call, the initial
7627  sp will be set to one byte prior the provided value.
7628  The provided value should not overlap any other memory areas such as used
7629  register banks or the data segment and with enough space for the current
7630  application.
7631  The 
7632 \series bold
7633 -
7634 \begin_inset ERT
7635 status collapsed
7636
7637 \begin_layout Standard
7638
7639
7640 \backslash
7641 /
7642 \end_layout
7643
7644 \end_inset
7645
7646 -pack-iram
7647 \series default
7648 \InsetSpace ~
7649
7650 \begin_inset LatexCommand \index{-\/-pack-iram}
7651
7652 \end_inset
7653
7654  option (which is now a default setting) will override this setting, so
7655  you should also specify the 
7656 \series bold
7657 -
7658 \begin_inset ERT
7659 status collapsed
7660
7661 \begin_layout Standard
7662
7663
7664 \backslash
7665 /
7666 \end_layout
7667
7668 \end_inset
7669
7670 -no-pack-iram
7671 \series default
7672 \InsetSpace ~
7673
7674 \begin_inset LatexCommand \index{-\/-no-pack-iram}
7675
7676 \end_inset
7677
7678  option if you need to manually place the stack.
7679 \end_layout
7680
7681 \begin_layout List
7682 \labelwidthstring 00.00.0000
7683
7684 \series bold
7685 -
7686 \begin_inset ERT
7687 status collapsed
7688
7689 \begin_layout Standard
7690
7691
7692 \backslash
7693 /
7694 \end_layout
7695
7696 \end_inset
7697
7698 -xstack-loc
7699 \series default
7700
7701 \begin_inset LatexCommand \index{-\/-xstack-loc <Value>}
7702
7703 \end_inset
7704
7705 \InsetSpace ~
7706 <Value> By default the external stack
7707 \begin_inset LatexCommand \index{xstack}
7708
7709 \end_inset
7710
7711  is placed after the pdata
7712 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
7713
7714 \end_inset
7715
7716  segment.
7717  Using this option the xstack can be placed anywhere in the external memory
7718  space of the 8051.
7719  The value entered can be in Hexadecimal or Decimal format, e.g.
7720  -
7721 \begin_inset ERT
7722 status collapsed
7723
7724 \begin_layout Standard
7725
7726
7727 \backslash
7728 /
7729 \end_layout
7730
7731 \end_inset
7732
7733 -xstack-loc 0x8000 or -
7734 \begin_inset ERT
7735 status collapsed
7736
7737 \begin_layout Standard
7738
7739
7740 \backslash
7741 /
7742 \end_layout
7743
7744 \end_inset
7745
7746 -stack-loc 32768.
7747  The provided value should not overlap any other memory areas such as the
7748  pdata or xdata segment and with enough space for the current application.
7749 \end_layout
7750
7751 \begin_layout List
7752 \labelwidthstring 00.00.0000
7753
7754 \series bold
7755 -
7756 \begin_inset ERT
7757 status collapsed
7758
7759 \begin_layout Standard
7760
7761
7762 \backslash
7763 /
7764 \end_layout
7765
7766 \end_inset
7767
7768 -data-loc
7769 \series default
7770
7771 \begin_inset LatexCommand \index{-\/-data-loc <Value>}
7772
7773 \end_inset
7774
7775 \InsetSpace ~
7776 <Value> The start location of the internal ram data
7777 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
7778
7779 \end_inset
7780
7781  segment.
7782  The value entered can be in Hexadecimal or Decimal format, eg.
7783  -
7784 \begin_inset ERT
7785 status collapsed
7786
7787 \begin_layout Standard
7788
7789
7790 \backslash
7791 /
7792 \end_layout
7793
7794 \end_inset
7795
7796 -data-loc 0x20 or -
7797 \begin_inset ERT
7798 status collapsed
7799
7800 \begin_layout Standard
7801
7802
7803 \backslash
7804 /
7805 \end_layout
7806
7807 \end_inset
7808
7809 -data-loc 32.
7810  (By default, the start location of the internal ram data segment  is set
7811  as low as possible in memory, taking into account the used register banks
7812  and the bit segment at address 0x20.
7813  For example if register banks 0 and 1 are used without bit variables, the
7814  data segment will be set, if -
7815 \begin_inset ERT
7816 status collapsed
7817
7818 \begin_layout Standard
7819
7820
7821 \backslash
7822 /
7823 \end_layout
7824
7825 \end_inset
7826
7827 -data-loc is not used, to location 0x10.)
7828 \end_layout
7829
7830 \begin_layout List
7831 \labelwidthstring 00.00.0000
7832
7833 \series bold
7834 -
7835 \begin_inset ERT
7836 status collapsed
7837
7838 \begin_layout Standard
7839
7840
7841 \backslash
7842 /
7843 \end_layout
7844
7845 \end_inset
7846
7847 -idata-loc
7848 \series default
7849
7850 \begin_inset LatexCommand \index{-\/-idata-loc <Value>}
7851
7852 \end_inset
7853
7854 \InsetSpace ~
7855 <Value> The start location of the indirectly addressable internal ram
7856 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
7857
7858 \end_inset
7859
7860  of the 8051, default value is 0x80.
7861  The value entered can be in Hexadecimal or Decimal format, eg.
7862  -
7863 \begin_inset ERT
7864 status collapsed
7865
7866 \begin_layout Standard
7867
7868
7869 \backslash
7870 /
7871 \end_layout
7872
7873 \end_inset
7874
7875 -idata-loc 0x88 or -
7876 \begin_inset ERT
7877 status collapsed
7878
7879 \begin_layout Standard
7880
7881
7882 \backslash
7883 /
7884 \end_layout
7885
7886 \end_inset
7887
7888 -idata-loc 136.
7889 \end_layout
7890
7891 \begin_layout List
7892 \labelwidthstring 00.00.0000
7893
7894 \series bold
7895 -
7896 \begin_inset ERT
7897 status collapsed
7898
7899 \begin_layout Standard
7900
7901
7902 \backslash
7903 /
7904 \end_layout
7905
7906 \end_inset
7907
7908 -bit-loc
7909 \series default
7910 \InsetSpace ~
7911 <Value> The start location of the bit
7912 \begin_inset LatexCommand \index{bit}
7913
7914 \end_inset
7915
7916  addressable internal ram of the 8051.
7917  This is 
7918 \emph on
7919 not
7920 \emph default
7921  implemented yet.
7922  Instead an option can be passed directly to the linker: -Wl\InsetSpace ~
7923 -bBSEG=<Value>.
7924 \end_layout
7925
7926 \begin_layout List
7927 \labelwidthstring 00.00.0000
7928
7929 \series bold
7930 -
7931 \begin_inset ERT
7932 status collapsed
7933
7934 \begin_layout Standard
7935
7936
7937 \backslash
7938 /
7939 \end_layout
7940
7941 \end_inset
7942
7943 -out-fmt-ihx
7944 \begin_inset LatexCommand \index{-\/-out-fmt-ihx}
7945
7946 \end_inset
7947
7948
7949 \bar under
7950  
7951 \series default
7952 \bar default
7953 The linker output (final object code) is in Intel Hex format.
7954 \begin_inset LatexCommand \index{Intel hex format}
7955
7956 \end_inset
7957
7958  This is the default option.
7959  The format itself is documented in the documentation of srecord
7960 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
7961
7962 \end_inset
7963
7964 .
7965 \end_layout
7966
7967 \begin_layout List
7968 \labelwidthstring 00.00.0000
7969
7970 \series bold
7971 -
7972 \begin_inset ERT
7973 status collapsed
7974
7975 \begin_layout Standard
7976
7977
7978 \backslash
7979 /
7980 \end_layout
7981
7982 \end_inset
7983
7984 -out-fmt-s19
7985 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
7986
7987 \end_inset
7988
7989
7990 \bar under
7991  
7992 \series default
7993 \bar default
7994 The linker output (final object code) is in Motorola S19 format
7995 \begin_inset LatexCommand \index{Motorola S19 format}
7996
7997 \end_inset
7998
7999 .
8000  The format itself is documented in the documentation of srecord.
8001 \end_layout
8002
8003 \begin_layout List
8004 \labelwidthstring 00.00.0000
8005
8006 \series bold
8007 -
8008 \begin_inset ERT
8009 status collapsed
8010
8011 \begin_layout Standard
8012
8013
8014 \backslash
8015 /
8016 \end_layout
8017
8018 \end_inset
8019
8020 -out-fmt-elf
8021 \begin_inset LatexCommand \index{-\/-out-fmt-s19}
8022
8023 \end_inset
8024
8025
8026 \begin_inset LatexCommand \index{HC08!Options!-\/-out-fmt-elf}
8027
8028 \end_inset
8029
8030
8031 \bar under
8032  
8033 \series default
8034 \bar default
8035 The linker output (final object code) is in ELF format
8036 \begin_inset LatexCommand \index{ELF format}
8037
8038 \end_inset
8039
8040 .
8041  (Currently only supported for the HC08
8042 \begin_inset LatexCommand \index{HC08}
8043
8044 \end_inset
8045
8046  processors)
8047 \end_layout
8048
8049 \begin_layout List
8050 \labelwidthstring 00.00.0000
8051
8052 \series bold
8053 -Wl\InsetSpace ~
8054 linkOption[,linkOption]
8055 \series default
8056
8057 \begin_inset LatexCommand \index{-Wl linkOption[,linkOption]}
8058
8059 \end_inset
8060
8061
8062 \begin_inset LatexCommand \label{lyx:-Wl option}
8063
8064 \end_inset
8065
8066 ...
8067  Pass the linkOption to the linker.
8068  If a bootloader is used an option like 
8069 \begin_inset Quotes sld
8070 \end_inset
8071
8072 -Wl\InsetSpace ~
8073 -bCSEG=0x1000
8074 \begin_inset Quotes srd
8075 \end_inset
8076
8077  would be typical to set the start of the code segment.
8078  Either use the double quotes around this option or use no space (e.g.
8079  -Wl-bCSEG=0x1000).
8080  See also #pragma constseg and #pragma codeseg in section 
8081 \begin_inset LatexCommand \ref{sec:Pragmas}
8082
8083 \end_inset
8084
8085  .
8086  File sdcc/as/doc/asxhtm.html has more on linker options.
8087 \end_layout
8088
8089 \begin_layout Standard
8090 \begin_inset VSpace bigskip
8091 \end_inset
8092
8093
8094 \end_layout
8095
8096 \begin_layout Subsection
8097 MCS51 Options
8098 \begin_inset LatexCommand \index{Options MCS51}
8099
8100 \end_inset
8101
8102
8103 \begin_inset LatexCommand \index{MCS51 options}
8104
8105 \end_inset
8106
8107
8108 \end_layout
8109
8110 \begin_layout List
8111 \labelwidthstring 00.00.0000
8112
8113 \series bold
8114 -
8115 \begin_inset ERT
8116 status collapsed
8117
8118 \begin_layout Standard
8119
8120
8121 \backslash
8122 /
8123 \end_layout
8124
8125 \end_inset
8126
8127 -model-small
8128 \begin_inset LatexCommand \index{-\/-model-small}
8129
8130 \end_inset
8131
8132
8133 \series default
8134 \size large
8135 \emph on
8136  
8137 \size default
8138 \emph default
8139 Generate code for Small Model programs, see section Memory Models for more
8140  details.
8141  This is the default model.
8142 \end_layout
8143
8144 \begin_layout List
8145 \labelwidthstring 00.00.0000
8146
8147 \series bold
8148 -
8149 \begin_inset ERT
8150 status collapsed
8151
8152 \begin_layout Standard
8153
8154
8155 \backslash
8156 /
8157 \end_layout
8158
8159 \end_inset
8160
8161 -model-medium
8162 \begin_inset LatexCommand \index{-\/-model-medium}
8163
8164 \end_inset
8165
8166
8167 \series default
8168  Generate code for Medium model programs, see section Memory Models for
8169  more details.
8170  If this option is used all source files in the project have to be compiled
8171  with this option.
8172  It must also be used when invoking the linker.
8173 \end_layout
8174
8175 \begin_layout List
8176 \labelwidthstring 00.00.0000
8177
8178 \series bold
8179 -
8180 \begin_inset ERT
8181 status collapsed
8182
8183 \begin_layout Standard
8184
8185
8186 \backslash
8187 /
8188 \end_layout
8189
8190 \end_inset
8191
8192 -model-large
8193 \begin_inset LatexCommand \index{-\/-model-large}
8194
8195 \end_inset
8196
8197
8198 \series default
8199  Generate code for Large model programs, see section Memory Models for more
8200  details.
8201  If this option is used all source files in the project have to be compiled
8202  with this option.
8203  It must also be used when invoking the linker.
8204 \end_layout
8205
8206 \begin_layout List
8207 \labelwidthstring 00.00.0000
8208
8209 \series bold
8210 -
8211 \begin_inset ERT
8212 status collapsed
8213
8214 \begin_layout Standard
8215
8216
8217 \backslash
8218 /
8219 \end_layout
8220
8221 \end_inset
8222
8223 -xstack
8224 \begin_inset LatexCommand \index{-\/-xstack}
8225
8226 \end_inset
8227
8228
8229 \series default
8230  Uses a pseudo stack in the pdata
8231 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
8232
8233 \end_inset
8234
8235  area (usually the first 256 bytes in the external ram) for allocating variables
8236  and passing parameters.
8237  See section 
8238 \begin_inset LatexCommand \ref{sub:External-Stack}
8239
8240 \end_inset
8241
8242 \InsetSpace ~
8243  External Stack for more details.
8244 \end_layout
8245
8246 \begin_layout List
8247 \labelwidthstring 00.00.0000
8248
8249 \series bold
8250 -
8251 \begin_inset ERT
8252 status collapsed
8253
8254 \begin_layout Standard
8255
8256
8257 \backslash
8258 /
8259 \end_layout
8260
8261 \end_inset
8262
8263 -iram-size
8264 \series default
8265 \InsetSpace ~
8266 <Value>
8267 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
8268
8269 \end_inset
8270
8271  Causes the linker to check if the internal ram usage is within limits of
8272  the given value.
8273 \end_layout
8274
8275 \begin_layout List
8276 \labelwidthstring 00.00.0000
8277
8278 \series bold
8279 -
8280 \begin_inset ERT
8281 status collapsed
8282
8283 \begin_layout Standard
8284
8285
8286 \backslash
8287 /
8288 \end_layout
8289
8290 \end_inset
8291
8292 -xram-size
8293 \series default
8294 \InsetSpace ~
8295 <Value>
8296 \begin_inset LatexCommand \index{-\/-xram-size <Value>}
8297
8298 \end_inset
8299
8300  Causes the linker to check if the external ram usage is within limits of
8301  the given value.
8302 \end_layout
8303
8304 \begin_layout List
8305 \labelwidthstring 00.00.0000
8306
8307 \series bold
8308 -
8309 \begin_inset ERT
8310 status collapsed
8311
8312 \begin_layout Standard
8313
8314
8315 \backslash
8316 /
8317 \end_layout
8318
8319 \end_inset
8320
8321 -code-size
8322 \series default
8323 \InsetSpace ~
8324 <Value>
8325 \begin_inset LatexCommand \index{-\/-code-size <Value>}
8326
8327 \end_inset
8328
8329  Causes the linker to check if the code memory usage is within limits of
8330  the given value.
8331 \end_layout
8332
8333 \begin_layout List
8334 \labelwidthstring 00.00.0000
8335
8336 \series bold
8337 -
8338 \begin_inset ERT
8339 status collapsed
8340
8341 \begin_layout Standard
8342
8343
8344 \backslash
8345 /
8346 \end_layout
8347
8348 \end_inset
8349
8350 -stack-size
8351 \series default
8352 \InsetSpace ~
8353 <Value>
8354 \begin_inset LatexCommand \index{-\/-stack-size <Value>}
8355
8356 \end_inset
8357
8358  Causes the linker to check if there is at minimum <Value> bytes for stack.
8359 \end_layout
8360
8361 \begin_layout List
8362 \labelwidthstring 00.00.0000
8363
8364 \series bold
8365 -
8366 \begin_inset ERT
8367 status collapsed
8368
8369 \begin_layout Standard
8370
8371
8372 \backslash
8373 /
8374 \end_layout
8375
8376 \end_inset
8377
8378 -pack-iram
8379 \series default
8380 \InsetSpace ~
8381
8382 \begin_inset LatexCommand \index{-\/-pack-iram}
8383
8384 \end_inset
8385
8386  Causes the linker to use unused register banks for data variables and pack
8387  data, idata and stack together.
8388  This is the default now.
8389 \end_layout
8390
8391 \begin_layout List
8392 \labelwidthstring 00.00.0000
8393
8394 \series bold
8395 -
8396 \begin_inset ERT
8397 status collapsed
8398
8399 \begin_layout Standard
8400
8401
8402 \backslash
8403 /
8404 \end_layout
8405
8406 \end_inset
8407
8408 -no-pack-iram
8409 \series default
8410 \InsetSpace ~
8411
8412 \begin_inset LatexCommand \index{-\/-no-pack-iram}
8413
8414 \end_inset
8415
8416  Causes the linker to use old style for allocating memory areas.
8417 \end_layout
8418
8419 \begin_layout List
8420 \labelwidthstring 00.00.0000
8421
8422 \series bold
8423 -
8424 \begin_inset ERT
8425 status collapsed
8426
8427 \begin_layout Standard
8428
8429
8430 \backslash
8431 /
8432 \end_layout
8433
8434 \end_inset
8435
8436 -acall-ajmp
8437 \series default
8438 \InsetSpace ~
8439
8440 \begin_inset LatexCommand \index{-\/-acall-ajmp}
8441
8442 \end_inset
8443
8444  Replaces the three byte instructions lcall/ljmp with the two byte instructions
8445  acall/ajmp.
8446  Only use this option if your code is in the same 2k block of memory.
8447  You may need to use this option for some 8051 derivatives which lack the
8448  lcall/ljmp instructions..
8449 \end_layout
8450
8451 \begin_layout Standard
8452 \begin_inset VSpace bigskip
8453 \end_inset
8454
8455
8456 \end_layout
8457
8458 \begin_layout Subsection
8459 DS390 / DS400 Options
8460 \begin_inset LatexCommand \index{Options DS390}
8461
8462 \end_inset
8463
8464
8465 \begin_inset LatexCommand \index{DS390}
8466
8467 \end_inset
8468
8469
8470 \end_layout
8471
8472 \begin_layout List
8473 \labelwidthstring 00.00.0000
8474
8475 \series bold
8476 -
8477 \begin_inset ERT
8478 status collapsed
8479
8480 \begin_layout Standard
8481
8482
8483 \backslash
8484 /
8485 \end_layout
8486
8487 \end_inset
8488
8489 -model-flat24
8490 \series default
8491
8492 \begin_inset LatexCommand \index{DS390!Options!-\/-model-flat24}
8493
8494 \end_inset
8495
8496
8497 \size large
8498 \emph on
8499  
8500 \size default
8501 \emph default
8502 Generate 24-bit flat mode code.
8503  This is the one and only that the ds390 code generator supports right now
8504  and is default when using 
8505 \emph on
8506 -mds390
8507 \emph default
8508 .
8509  See section Memory Models for more details.
8510 \end_layout
8511
8512 \begin_layout List
8513 \labelwidthstring 00.00.0000
8514
8515 \series bold
8516 -
8517 \begin_inset ERT
8518 status collapsed
8519
8520 \begin_layout Standard
8521
8522
8523 \backslash
8524 /
8525 \end_layout
8526
8527 \end_inset
8528
8529 -protect-sp-update
8530 \begin_inset LatexCommand \index{DS390!Options!-\/-protect-sp-update}
8531
8532 \end_inset
8533
8534
8535 \series default
8536  disable interrupts during ESP:SP updates.
8537 \end_layout
8538
8539 \begin_layout List
8540 \labelwidthstring 00.00.0000
8541
8542 \series bold
8543 -
8544 \begin_inset ERT
8545 status collapsed
8546
8547 \begin_layout Standard
8548
8549
8550 \backslash
8551 /
8552 \end_layout
8553
8554 \end_inset
8555
8556 -stack-10bit
8557 \series default
8558
8559 \begin_inset LatexCommand \index{DS390!Options!-\/-stack-10bit}
8560
8561 \end_inset
8562
8563  Generate code for the 10 bit stack mode of the Dallas DS80C390 part.
8564  This is the one and only that the ds390 code generator supports right now
8565  and is default when using 
8566 \emph on
8567 -mds390
8568 \emph default
8569 .
8570  In this mode, the stack is located in the lower 1K of the internal RAM,
8571  which is mapped to 0x400000.
8572  Note that the support is incomplete, since it still uses a single byte
8573  as the stack pointer.
8574  This means that only the lower 256 bytes of the potential 1K stack space
8575  will actually be used.
8576  However, this does allow you to reclaim the precious 256 bytes of low RAM
8577  for use for the DATA and IDATA segments.
8578  The compiler will not generate any code to put the processor into 10 bit
8579  stack mode.
8580  It is important to ensure that the processor is in this mode before calling
8581  any re-entrant functions compiled with this option.
8582  In principle, this should work with the 
8583 \emph on
8584 -
8585 \begin_inset ERT
8586 status collapsed
8587
8588 \begin_layout Standard
8589
8590
8591 \backslash
8592 /
8593 \end_layout
8594
8595 \end_inset
8596
8597 -stack-auto
8598 \begin_inset LatexCommand \index{-\/-stack-auto}
8599
8600 \end_inset
8601
8602
8603 \emph default
8604  option, but that has not been tested.
8605  It is incompatible with the 
8606 \emph on
8607 -
8608 \begin_inset ERT
8609 status collapsed
8610
8611 \begin_layout Standard
8612
8613
8614 \backslash
8615 /
8616 \end_layout
8617
8618 \end_inset
8619
8620 -xstack
8621 \begin_inset LatexCommand \index{-\/-xstack}
8622
8623 \end_inset
8624
8625
8626 \emph default
8627  option.
8628  It also only makes sense if the processor is in 24 bit contiguous addressing
8629  mode (see the 
8630 \emph on
8631 -
8632 \begin_inset ERT
8633 status collapsed
8634
8635 \begin_layout Standard
8636
8637
8638 \backslash
8639 /
8640 \end_layout
8641
8642 \end_inset
8643
8644 -model-flat24 option
8645 \emph default
8646 ).
8647 \series bold
8648
8649 \begin_inset Note Note
8650 status collapsed
8651
8652 \begin_layout List
8653 \labelwidthstring 00.00.0000
8654
8655 \series bold
8656 -
8657 \begin_inset ERT
8658 status open
8659
8660 \begin_layout Standard
8661
8662
8663 \backslash
8664 /
8665 \end_layout
8666
8667 \end_inset
8668
8669 -stack-8-bit - switches off the 10-bit mode
8670 \end_layout
8671
8672 \end_inset
8673
8674
8675 \end_layout
8676
8677 \begin_layout List
8678 \labelwidthstring 00.00.0000
8679
8680 \series bold
8681 -
8682 \begin_inset ERT
8683 status collapsed
8684
8685 \begin_layout Standard
8686
8687
8688 \backslash
8689 /
8690 \end_layout
8691
8692 \end_inset
8693
8694 -stack-probe
8695 \begin_inset LatexCommand \index{DS390!Options!-\/-stack-probe}
8696
8697 \end_inset
8698
8699
8700 \series default
8701  insert call to function __stack_probe at each function prologue.
8702 \end_layout
8703
8704 \begin_layout List
8705 \labelwidthstring 00.00.0000
8706
8707 \series bold
8708 -
8709 \begin_inset ERT
8710 status open
8711
8712 \begin_layout Standard
8713
8714
8715 \backslash
8716 /
8717 \end_layout
8718
8719 \end_inset
8720
8721 -tini-libid
8722 \begin_inset LatexCommand \index{DS390!Options!-\/-tini-libid}
8723
8724 \end_inset
8725
8726
8727 \series default
8728  <nnnn> LibraryID used in -mTININative.
8729  
8730 \end_layout
8731
8732 \begin_layout List
8733 \labelwidthstring 00.00.0000
8734
8735 \series bold
8736 -
8737 \begin_inset ERT
8738 status collapsed
8739
8740 \begin_layout Standard
8741
8742
8743 \backslash
8744 /
8745 \end_layout
8746
8747 \end_inset
8748
8749 -use-accelerator
8750 \begin_inset LatexCommand \index{DS390!Options!-\/-use-accelerator}
8751
8752 \end_inset
8753
8754
8755 \series default
8756  generate code for DS390 Arithmetic Accelerator.
8757  
8758 \end_layout
8759
8760 \begin_layout Standard
8761 \begin_inset VSpace bigskip
8762 \end_inset
8763
8764
8765 \end_layout
8766
8767 \begin_layout Subsection
8768 Z80 Options
8769 \begin_inset LatexCommand \index{Options Z80}
8770
8771 \end_inset
8772
8773
8774 \begin_inset LatexCommand \index{Z80}
8775
8776 \end_inset
8777
8778
8779 \end_layout
8780
8781 \begin_layout List
8782 \labelwidthstring 00.00.0000
8783
8784 \series bold
8785 -
8786 \begin_inset ERT
8787 status collapsed
8788
8789 \begin_layout Standard
8790
8791
8792 \backslash
8793 /
8794 \end_layout
8795
8796 \end_inset
8797
8798 -callee-saves-bc
8799 \series default
8800
8801 \begin_inset LatexCommand \index{Z80!Options!-\/-callee-saves-bc}
8802
8803 \end_inset
8804
8805
8806 \size large
8807 \emph on
8808  
8809 \size default
8810 \emph default
8811 Force a called function to always save BC.
8812 \end_layout
8813
8814 \begin_layout List
8815 \labelwidthstring 00.00.0000
8816
8817 \series bold
8818 -
8819 \begin_inset ERT
8820 status collapsed
8821
8822 \begin_layout Standard
8823
8824
8825 \backslash
8826 /
8827 \end_layout
8828
8829 \end_inset
8830
8831 -no-std-crt0
8832 \series default
8833
8834 \begin_inset LatexCommand \index{Z80!Options!-\/-no-std-crt0}
8835
8836 \end_inset
8837
8838  When linking, skip the standard crt0.o object file.
8839  You must provide your own crt0.o for your system when linking.
8840 \end_layout
8841
8842 \begin_layout List
8843 \labelwidthstring 00.00.0000
8844
8845 \series bold
8846 -
8847 \begin_inset ERT
8848 status collapsed
8849
8850 \begin_layout Standard
8851
8852
8853 \backslash
8854 /
8855 \end_layout
8856
8857 \end_inset
8858
8859 -portmode=
8860 \series default
8861 <Value>
8862 \begin_inset LatexCommand \index{Z80!Options!-\/-portmode=<Value>}
8863
8864 \end_inset
8865
8866  Determinate PORT I/O mode (<Value> is z80 or z180).
8867 \end_layout
8868
8869 \begin_layout List
8870 \labelwidthstring 00.00.0000
8871
8872 \series bold
8873 -
8874 \begin_inset ERT
8875 status collapsed
8876
8877 \begin_layout Standard
8878
8879
8880 \backslash
8881 /
8882 \end_layout
8883
8884 \end_inset
8885
8886 -asm=
8887 \series default
8888 <Value>
8889 \begin_inset LatexCommand \index{Z80!Options!-\/-asm=<Value>}
8890
8891 \end_inset
8892
8893  Define assembler name (<Value> is rgbds, asxxxx, isas or z80asm).
8894 \end_layout
8895
8896 \begin_layout List
8897 \labelwidthstring 00.00.0000
8898
8899 \series bold
8900 -
8901 \begin_inset ERT
8902 status collapsed
8903
8904 \begin_layout Standard
8905
8906
8907 \backslash
8908 /
8909 \end_layout
8910
8911 \end_inset
8912
8913 -codeseg
8914 \series default
8915 \InsetSpace ~
8916 <Value>
8917 \begin_inset LatexCommand \index{Z80!Options!-\/-codeseg <Value>}
8918
8919 \end_inset
8920
8921  Use <Value> for the code segment name.
8922 \end_layout
8923
8924 \begin_layout List
8925 \labelwidthstring 00.00.0000
8926
8927 \series bold
8928 -
8929 \begin_inset ERT
8930 status collapsed
8931
8932 \begin_layout Standard
8933
8934
8935 \backslash
8936 /
8937 \end_layout
8938
8939 \end_inset
8940
8941 -constseg
8942 \series default
8943 \InsetSpace ~
8944 <Value>
8945 \begin_inset LatexCommand \index{Z80!Options!-\/-constseg <Value>}
8946
8947 \end_inset
8948
8949  Use <Value> for the const segment name.
8950 \end_layout
8951
8952 \begin_layout List
8953 \labelwidthstring 00.00.0000
8954 \begin_inset VSpace bigskip
8955 \end_inset
8956
8957
8958 \end_layout
8959
8960 \begin_layout Subsection
8961 GBZ80 Options
8962 \begin_inset LatexCommand \index{Options GBZ80}
8963
8964 \end_inset
8965
8966
8967 \begin_inset LatexCommand \index{GBZ80}
8968
8969 \end_inset
8970
8971
8972 \end_layout
8973
8974 \begin_layout List
8975 \labelwidthstring 00.00.0000
8976
8977 \series bold
8978 -
8979 \begin_inset ERT
8980 status collapsed
8981
8982 \begin_layout Standard
8983
8984
8985 \backslash
8986 /
8987 \end_layout
8988
8989 \end_inset
8990
8991 -callee-saves-bc
8992 \series default
8993
8994 \begin_inset LatexCommand \index{GBZ80!Options!-\/-callee-saves-bc}
8995
8996 \end_inset
8997
8998
8999 \size large
9000 \emph on
9001  
9002 \size default
9003 \emph default
9004 Force a called function to always save BC.
9005 \end_layout
9006
9007 \begin_layout List
9008 \labelwidthstring 00.00.0000
9009
9010 \series bold
9011 -
9012 \begin_inset ERT
9013 status collapsed
9014
9015 \begin_layout Standard
9016
9017
9018 \backslash
9019 /
9020 \end_layout
9021
9022 \end_inset
9023
9024 -no-std-crt0
9025 \series default
9026
9027 \begin_inset LatexCommand \index{Z80!Options!-\/-no-std-crt0}
9028
9029 \end_inset
9030
9031  When linking, skip the standard crt0.o object file.
9032  You must provide your own crt0.o for your system when linking.
9033 \end_layout
9034
9035 \begin_layout List
9036 \labelwidthstring 00.00.0000
9037
9038 \series bold
9039 -bo
9040 \series default
9041 \InsetSpace ~
9042 <Num>
9043 \begin_inset LatexCommand \index{GBZ80!Options!-bo <Num>}
9044
9045 \end_inset
9046
9047  Use code bank <Num>.
9048 \end_layout
9049
9050 \begin_layout List
9051 \labelwidthstring 00.00.0000
9052
9053 \series bold
9054 -ba
9055 \series default
9056 \InsetSpace ~
9057 <Num>
9058 \begin_inset LatexCommand \index{GBZ80!Options!-ba <Num>}
9059
9060 \end_inset
9061
9062  Use data bank <Num>.
9063 \end_layout
9064
9065 \begin_layout List
9066 \labelwidthstring 00.00.0000
9067
9068 \series bold
9069 -
9070 \begin_inset ERT
9071 status collapsed
9072
9073 \begin_layout Standard
9074
9075
9076 \backslash
9077 /
9078 \end_layout
9079
9080 \end_inset
9081
9082 -codeseg
9083 \series default
9084 \InsetSpace ~
9085 <Value>
9086 \begin_inset LatexCommand \index{GBZ80!Options!-\/-codeseg <Value>}
9087
9088 \end_inset
9089
9090  Use <Value> for the code segment name.
9091 \end_layout
9092
9093 \begin_layout List
9094 \labelwidthstring 00.00.0000
9095
9096 \series bold
9097 -
9098 \begin_inset ERT
9099 status collapsed
9100
9101 \begin_layout Standard
9102
9103
9104 \backslash
9105 /
9106 \end_layout
9107
9108 \end_inset
9109
9110 -constseg
9111 \series default
9112 \InsetSpace ~
9113 <Value>
9114 \begin_inset LatexCommand \index{GBZ80!Options!-\/-constseg <Value>}
9115
9116 \end_inset
9117
9118  Use <Value> for the const segment name.
9119 \end_layout
9120
9121 \begin_layout Standard
9122 \begin_inset VSpace bigskip
9123 \end_inset
9124
9125
9126 \end_layout
9127
9128 \begin_layout Subsection
9129 Optimization Options
9130 \begin_inset LatexCommand \index{Options optimization}
9131
9132 \end_inset
9133
9134
9135 \begin_inset LatexCommand \index{Optimization options}
9136
9137 \end_inset
9138
9139
9140 \end_layout
9141
9142 \begin_layout List
9143 \labelwidthstring 00.00.0000
9144
9145 \series bold
9146 -
9147 \begin_inset ERT
9148 status collapsed
9149
9150 \begin_layout Standard
9151
9152
9153 \backslash
9154 /
9155 \end_layout
9156
9157 \end_inset
9158
9159 -nogcse
9160 \begin_inset LatexCommand \index{-\/-nogcse}
9161
9162 \end_inset
9163
9164
9165 \series default
9166  Will not do global subexpression elimination, this option may be used when
9167  the compiler creates undesirably large stack/data spaces to store compiler
9168  temporaries (
9169 \emph on
9170 s
9171 \emph default
9172 pill 
9173 \emph on
9174 loc
9175 \emph default
9176 ations, sloc
9177 \begin_inset LatexCommand \index{sloc (spill location)}
9178
9179 \end_inset
9180
9181 ).
9182  A warning message will be generated when this happens and the compiler
9183  will indicate the number of extra bytes it allocated.
9184  It is recommended that this option NOT be used, #pragma\InsetSpace ~
9185 nogcse
9186 \begin_inset LatexCommand \index{\#pragma nogcse}
9187
9188 \end_inset
9189
9190  can be used to turn off global subexpression elimination
9191 \begin_inset LatexCommand \index{Subexpression elimination}
9192
9193 \end_inset
9194
9195  for a given function only.
9196 \end_layout
9197
9198 \begin_layout List
9199 \labelwidthstring 00.00.0000
9200
9201 \series bold
9202 -
9203 \begin_inset ERT
9204 status collapsed
9205
9206 \begin_layout Standard
9207
9208
9209 \backslash
9210 /
9211 \end_layout
9212
9213 \end_inset
9214
9215 -noinvariant
9216 \begin_inset LatexCommand \index{-\/-noinvariant}
9217
9218 \end_inset
9219
9220
9221 \series default
9222  Will not do loop invariant optimizations, this may be turned off for reasons
9223  explained for the previous option.
9224  For more details of loop optimizations performed see Loop Invariants in
9225  section 
9226 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
9227
9228 \end_inset
9229
9230 .
9231  It is recommended that this option NOT be used, #pragma\InsetSpace ~
9232 noinvariant
9233 \begin_inset LatexCommand \index{\#pragma noinvariant}
9234
9235 \end_inset
9236
9237  can be used to turn off invariant optimizations for a given function only.
9238 \end_layout
9239
9240 \begin_layout List
9241 \labelwidthstring 00.00.0000
9242
9243 \series bold
9244 -
9245 \begin_inset ERT
9246 status collapsed
9247
9248 \begin_layout Standard
9249
9250
9251 \backslash
9252 /
9253 \end_layout
9254
9255 \end_inset
9256
9257 -noinduction
9258 \begin_inset LatexCommand \index{-\/-noinduction}
9259
9260 \end_inset
9261
9262
9263 \series default
9264  Will not do loop induction optimizations, see section strength reduction
9265  for more details.
9266  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9267 noinduction
9268 \begin_inset LatexCommand \index{\#pragma noinduction}
9269
9270 \end_inset
9271
9272  can be used to turn off induction optimizations for a given function only.
9273 \end_layout
9274
9275 \begin_layout List
9276 \labelwidthstring 00.00.0000
9277
9278 \series bold
9279 -
9280 \begin_inset ERT
9281 status collapsed
9282
9283 \begin_layout Standard
9284
9285
9286 \backslash
9287 /
9288 \end_layout
9289
9290 \end_inset
9291
9292 -nojtbound
9293 \begin_inset LatexCommand \index{-\/-nojtbound}
9294
9295 \end_inset
9296
9297
9298 \size large
9299 \bar under
9300  
9301 \series default
9302 \size default
9303 \bar default
9304  Will not generate boundary condition check when switch statements
9305 \begin_inset LatexCommand \index{switch statement}
9306
9307 \end_inset
9308
9309  are implemented using jump-tables.
9310  See section 
9311 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
9312
9313 \end_inset
9314
9315 \InsetSpace ~
9316 Switch Statements for more details.
9317  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9318 nojtbound
9319 \begin_inset LatexCommand \index{\#pragma nojtbound}
9320
9321 \end_inset
9322
9323  can be used to turn off boundary checking for jump tables for a given function
9324  only.
9325 \end_layout
9326
9327 \begin_layout List
9328 \labelwidthstring 00.00.0000
9329
9330 \series bold
9331 -
9332 \begin_inset ERT
9333 status collapsed
9334
9335 \begin_layout Standard
9336
9337
9338 \backslash
9339 /
9340 \end_layout
9341
9342 \end_inset
9343
9344 -noloopreverse
9345 \begin_inset LatexCommand \index{-\/-noloopreverse}
9346
9347 \end_inset
9348
9349
9350 \series default
9351 \size large
9352  
9353 \size default
9354 Will not do loop reversal 
9355 \begin_inset LatexCommand \index{Loop reversing}
9356
9357 \end_inset
9358
9359 optimization.
9360 \end_layout
9361
9362 \begin_layout List
9363 \labelwidthstring 00.00.0000
9364 -
9365 \begin_inset ERT
9366 status collapsed
9367
9368 \begin_layout Standard
9369
9370
9371 \backslash
9372 /
9373 \end_layout
9374
9375 \end_inset
9376
9377 -
9378 \series bold
9379 nolabelopt
9380 \series default
9381  
9382 \begin_inset LatexCommand \index{-\/-nolabelopt }
9383
9384 \end_inset
9385
9386 Will not optimize labels (makes the dumpfiles more readable).
9387 \end_layout
9388
9389 \begin_layout List
9390 \labelwidthstring 00.00.0000
9391
9392 \series bold
9393 -
9394 \begin_inset ERT
9395 status collapsed
9396
9397 \begin_layout Standard
9398
9399
9400 \backslash
9401 /
9402 \end_layout
9403
9404 \end_inset
9405
9406 -no-xinit-opt
9407 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
9408
9409 \end_inset
9410
9411
9412 \series default
9413  Will not memcpy initialized data from code space into xdata space.
9414  This saves a few bytes in code space if you don't have initialized data
9415 \begin_inset LatexCommand \index{Variable initialization}
9416
9417 \end_inset
9418
9419 .
9420 \end_layout
9421
9422 \begin_layout List
9423 \labelwidthstring 00.00.0000
9424
9425 \series bold
9426 -
9427 \begin_inset ERT
9428 status collapsed
9429
9430 \begin_layout Standard
9431
9432
9433 \backslash
9434 /
9435 \end_layout
9436
9437 \end_inset
9438
9439 -nooverlay
9440 \begin_inset LatexCommand \index{-\/-nooverlay}
9441
9442 \end_inset
9443
9444
9445 \series default
9446   The compiler will not overlay parameters and local variables of any function,
9447  see section Parameters and local variables for more details.
9448 \end_layout
9449
9450 \begin_layout List
9451 \labelwidthstring 00.00.0000
9452
9453 \series bold
9454 -
9455 \begin_inset ERT
9456 status collapsed
9457
9458 \begin_layout Standard
9459
9460
9461 \backslash
9462 /
9463 \end_layout
9464
9465 \end_inset
9466
9467 -no-peep
9468 \begin_inset LatexCommand \index{-\/-no-peep}
9469
9470 \end_inset
9471
9472
9473 \series default
9474  Disable peep-hole optimization with built-in rules.
9475 \end_layout
9476
9477 \begin_layout List
9478 \labelwidthstring 00.00.0000
9479
9480 \series bold
9481 -
9482 \begin_inset ERT
9483 status collapsed
9484
9485 \begin_layout Standard
9486
9487
9488 \backslash
9489 /
9490 \end_layout
9491
9492 \end_inset
9493
9494 -peep-file
9495 \series default
9496
9497 \begin_inset LatexCommand \index{-\/-peep-file}
9498
9499 \end_inset
9500
9501 \InsetSpace ~
9502 <filename> This option can be used to use additional rules to be used by
9503  the peep hole optimizer.
9504  See section 
9505 \begin_inset LatexCommand \ref{sub:Peephole-Optimizer}
9506
9507 \end_inset
9508
9509 \InsetSpace ~
9510 Peep Hole optimizations for details on how to write these rules.
9511 \end_layout
9512
9513 \begin_layout List
9514 \labelwidthstring 00.00.0000
9515
9516 \series bold
9517 -
9518 \begin_inset ERT
9519 status collapsed
9520
9521 \begin_layout Standard
9522
9523
9524 \backslash
9525 /
9526 \end_layout
9527
9528 \end_inset
9529
9530 -peep-asm
9531 \begin_inset LatexCommand \index{-\/-peep-asm}
9532
9533 \end_inset
9534
9535
9536 \series default
9537  Pass the inline assembler code through the peep hole optimizer.
9538  This can cause unexpected changes to inline assembler code, please go through
9539  the peephole optimizer
9540 \begin_inset LatexCommand \index{Peephole optimizer}
9541
9542 \end_inset
9543
9544  rules defined in the source file tree '<target>/peeph.def' before using
9545  this option.
9546 \end_layout
9547
9548 \begin_layout List
9549 \labelwidthstring 00.00.0000
9550
9551 \series bold
9552 -
9553 \begin_inset ERT
9554 status collapsed
9555
9556 \begin_layout Standard
9557
9558
9559 \backslash
9560 /
9561 \end_layout
9562
9563 \end_inset
9564
9565 -opt-code-speed
9566 \begin_inset LatexCommand \index{-\/-opt-code-speed}
9567
9568 \end_inset
9569
9570
9571 \series default
9572  The compiler will optimize code generation towards fast code, possibly
9573  at the expense of code size.
9574 \end_layout
9575
9576 \begin_layout List
9577 \labelwidthstring 00.00.0000
9578
9579 \series bold
9580 -
9581 \begin_inset ERT
9582 status collapsed
9583
9584 \begin_layout Standard
9585
9586
9587 \backslash
9588 /
9589 \end_layout
9590
9591 \end_inset
9592
9593 -opt-code-size
9594 \begin_inset LatexCommand \index{-\/-opt-code-size}
9595
9596 \end_inset
9597
9598
9599 \series default
9600  The compiler will optimize code generation towards compact code, possibly
9601  at the expense of code speed.
9602 \end_layout
9603
9604 \begin_layout Standard
9605 \begin_inset VSpace bigskip
9606 \end_inset
9607
9608
9609 \end_layout
9610
9611 \begin_layout Subsection
9612 Other Options
9613 \begin_inset LatexCommand \index{Options other}
9614
9615 \end_inset
9616
9617
9618 \end_layout
9619
9620 \begin_layout List
9621 \labelwidthstring 00.00.0000
9622
9623 \series bold
9624 -c\InsetSpace ~
9625 -
9626 \begin_inset ERT
9627 status collapsed
9628
9629 \begin_layout Standard
9630
9631
9632 \backslash
9633 /
9634 \end_layout
9635
9636 \end_inset
9637
9638 -compile-only
9639 \begin_inset LatexCommand \index{-\/-compile-only}
9640
9641 \end_inset
9642
9643
9644 \begin_inset LatexCommand \index{-c -\/-compile-only}
9645
9646 \end_inset
9647
9648
9649 \series default
9650  will compile and assemble the source, but will not call the linkage editor.
9651 \end_layout
9652
9653 \begin_layout List
9654 \labelwidthstring 00.00.0000
9655
9656 \series bold
9657 -
9658 \series default
9659
9660 \begin_inset ERT
9661 status collapsed
9662
9663 \begin_layout Standard
9664
9665
9666 \backslash
9667 /
9668 \end_layout
9669
9670 \end_inset
9671
9672
9673 \series bold
9674 -c1mode
9675 \begin_inset LatexCommand \index{-\/-c1mode}
9676
9677 \end_inset
9678
9679
9680 \series default
9681  reads the preprocessed source from standard input and compiles it.
9682  The file name for the assembler output must be specified using the -o option.
9683 \end_layout
9684
9685 \begin_layout List
9686 \labelwidthstring 00.00.0000
9687
9688 \series bold
9689 -E
9690 \begin_inset LatexCommand \index{-E}
9691
9692 \end_inset
9693
9694
9695 \series default
9696  Run only the C preprocessor.
9697  Preprocess all the C source files specified and output the results to standard
9698  output.
9699 \end_layout
9700
9701 \begin_layout List
9702 \labelwidthstring 00.00.0000
9703
9704 \series bold
9705 -o\InsetSpace ~
9706 <path/file>
9707 \begin_inset LatexCommand \index{-o <path/file>}
9708
9709 \end_inset
9710
9711  
9712 \series default
9713 The output path where everything will be placed or the file name used for
9714  all generated output files.
9715  If the parameter is a path, it must have a trailing slash (or backslash
9716  for the Windows binaries) to be recognized as a path.
9717
9718 \emph on
9719  
9720 \emph default
9721 Note for Windows users: if the path contains spaces, it should be surrounded
9722  by quotes.
9723  The trailing backslash should be doubled in order to prevent escaping the
9724  final quote, for example: 
9725 \emph on
9726 -o 
9727 \begin_inset Quotes sld
9728 \end_inset
9729
9730 F:
9731 \backslash
9732 Projects
9733 \backslash
9734 test3
9735 \backslash
9736 output 1
9737 \backslash
9738
9739 \backslash
9740
9741 \begin_inset Quotes srd
9742 \end_inset
9743
9744
9745 \emph default
9746  or put after the final quote, for example: 
9747 \emph on
9748 -o 
9749 \begin_inset Quotes sld
9750 \end_inset
9751
9752 F:
9753 \backslash
9754 Projects
9755 \backslash
9756 test3
9757 \backslash
9758 output 1
9759 \begin_inset Quotes srd
9760 \end_inset
9761
9762
9763 \backslash
9764
9765 \emph default
9766 .
9767  The path using slashes for directory delimiters can be used too, for example:
9768  
9769 \emph on
9770 -o 
9771 \begin_inset Quotes sld
9772 \end_inset
9773
9774 F:/Projects/test3/output 1/
9775 \begin_inset Quotes srd
9776 \end_inset
9777
9778
9779 \emph default
9780 .
9781 \end_layout
9782
9783 \begin_layout List
9784 \labelwidthstring 00.00.0000
9785
9786 \series bold
9787 -
9788 \begin_inset ERT
9789 status collapsed
9790
9791 \begin_layout Standard
9792
9793
9794 \backslash
9795 /
9796 \end_layout
9797
9798 \end_inset
9799
9800 -stack-auto
9801 \begin_inset LatexCommand \index{-\/-stack-auto}
9802
9803 \end_inset
9804
9805
9806 \series default
9807 \size large
9808 \emph on
9809  
9810 \size default
9811 \emph default
9812 All functions in the source file will be compiled as 
9813 \emph on
9814 reentrant
9815 \emph default
9816
9817 \begin_inset LatexCommand \index{reentrant}
9818
9819 \end_inset
9820
9821 , i.e.
9822  the parameters and local variables will be allocated on the stack
9823 \begin_inset LatexCommand \index{stack}
9824
9825 \end_inset
9826
9827 .
9828  See section 
9829 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
9830
9831 \end_inset
9832
9833  Parameters and Local Variables for more details.
9834  If this option is used all source files in the project should be compiled
9835  with this option.
9836  It automatically implies -
9837 \series bold
9838
9839 \begin_inset ERT
9840 status open
9841
9842 \begin_layout Standard
9843
9844
9845 \backslash
9846 /
9847 \end_layout
9848
9849 \end_inset
9850
9851
9852 \series default
9853 -int-long-reent and -
9854 \series bold
9855
9856 \begin_inset ERT
9857 status open
9858
9859 \begin_layout Standard
9860
9861
9862 \backslash
9863 /
9864 \end_layout
9865
9866 \end_inset
9867
9868
9869 \series default
9870 -float-reent.
9871  
9872 \end_layout
9873
9874 \begin_layout List
9875 \labelwidthstring 00.00.0000
9876
9877 \series bold
9878 -
9879 \begin_inset ERT
9880 status collapsed
9881
9882 \begin_layout Standard
9883
9884
9885 \backslash
9886 /
9887 \end_layout
9888
9889 \end_inset
9890
9891 -callee-saves
9892 \begin_inset LatexCommand \index{-\/-callee-saves}
9893
9894 \end_inset
9895
9896  
9897 \begin_inset LatexCommand \label{lyx:--callee-saves-function1[,function2][,function3]...}
9898
9899 \end_inset
9900
9901 function1[,function2][,function3]....
9902
9903 \series default
9904  The compiler by default uses a caller saves convention for register saving
9905  across function calls, however this can cause unnecessary register pushing
9906  and popping when calling small functions from larger functions.
9907  This option can be used to switch the register saving convention for the
9908  function names specified.
9909  The compiler will not save registers when calling these functions, no extra
9910  code will be generated at the entry and exit (function prologue
9911 \series bold
9912
9913 \begin_inset LatexCommand \index{function prologue}
9914
9915 \end_inset
9916
9917
9918 \series default
9919  and epilogue
9920 \series bold
9921
9922 \begin_inset LatexCommand \index{function epilogue}
9923
9924 \end_inset
9925
9926
9927 \series default
9928 ) for these functions to save and restore the registers used by these functions,
9929  this can SUBSTANTIALLY reduce code and improve run time performance of
9930  the generated code.
9931  In the future the compiler (with inter procedural analysis) will be able
9932  to determine the appropriate scheme to use for each function call.
9933  DO NOT use this option for built-in functions such as _mulint..., if this
9934  option is used for a library function the appropriate library function
9935  needs to be recompiled with the same option.
9936  If the project consists of multiple source files then all the source file
9937  should be compiled with the same -
9938 \begin_inset ERT
9939 status collapsed
9940
9941 \begin_layout Standard
9942
9943
9944 \backslash
9945 /
9946 \end_layout
9947
9948 \end_inset
9949
9950 -callee-saves option string.
9951  Also see #pragma\InsetSpace ~
9952 callee_saves 
9953 \begin_inset LatexCommand \index{\#pragma callee\_saves}
9954
9955 \end_inset
9956
9957  
9958 \begin_inset LatexCommand \vpageref{ite:callee_saves-function1[,function2[,function3...]]--}
9959
9960 \end_inset
9961
9962 .
9963 \end_layout
9964
9965 \begin_layout List
9966 \labelwidthstring 00.00.0000
9967
9968 \series bold
9969 -
9970 \begin_inset ERT
9971 status collapsed
9972
9973 \begin_layout Standard
9974
9975
9976 \backslash
9977 /
9978 \end_layout
9979
9980 \end_inset
9981
9982 -all-callee-saves
9983 \begin_inset LatexCommand \index{-\/-all-callee-saves}
9984
9985 \end_inset
9986
9987  
9988 \series default
9989 Function of
9990 \series bold
9991  
9992 \series default
9993 -
9994 \begin_inset ERT
9995 status collapsed
9996
9997 \begin_layout Standard
9998
9999
10000 \backslash
10001 /
10002 \end_layout
10003
10004 \end_inset
10005
10006 -callee-saves will be applied to all functions by default.
10007 \end_layout
10008
10009 \begin_layout List
10010 \labelwidthstring 00.00.0000
10011
10012 \series bold
10013 -
10014 \begin_inset ERT
10015 status collapsed
10016
10017 \begin_layout Standard
10018
10019
10020 \backslash
10021 /
10022 \end_layout
10023
10024 \end_inset
10025
10026 -debug
10027 \begin_inset LatexCommand \index{-\/-debug}
10028
10029 \end_inset
10030
10031
10032 \bar under
10033  
10034 \series default
10035 \bar default
10036 When this option is used the compiler will generate debug information.
10037  The debug information collected in a file with .cdb extension can be used
10038  with the SDCDB.
10039  For more information see documentation for SDCDB.
10040  Another file with no extension contains debug information in AOMF or AOMF51
10041 \begin_inset LatexCommand \index{AOMF, AOMF51}
10042
10043 \end_inset
10044
10045  format which is commonly used by third party tools.
10046 \end_layout
10047
10048 \begin_layout List
10049 \labelwidthstring 00.00.0000
10050
10051 \series bold
10052 -S
10053 \begin_inset LatexCommand \index{-S}
10054
10055 \end_inset
10056
10057
10058 \size large
10059 \bar under
10060  
10061 \series default
10062 \size default
10063 \bar default
10064 Stop after the stage of compilation proper; do not assemble.
10065  The output is an assembler code file for the input file specified.
10066 \end_layout
10067
10068 \begin_layout List
10069 \labelwidthstring 00.00.0000
10070
10071 \series bold
10072 -
10073 \begin_inset ERT
10074 status collapsed
10075
10076 \begin_layout Standard
10077
10078
10079 \backslash
10080 /
10081 \end_layout
10082
10083 \end_inset
10084
10085 -int-long-reent
10086 \begin_inset LatexCommand \index{-\/-int-long-reent}
10087
10088 \end_inset
10089
10090
10091 \series default
10092  Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
10093  Note by default these libraries are compiled as non-reentrant.
10094  See section Installation for more details.
10095 \end_layout
10096
10097 \begin_layout List
10098 \labelwidthstring 00.00.0000
10099
10100 \series bold
10101 -
10102 \begin_inset ERT
10103 status collapsed
10104
10105 \begin_layout Standard
10106
10107
10108 \backslash
10109 /
10110 \end_layout
10111
10112 \end_inset
10113
10114 -cyclomatic
10115 \begin_inset LatexCommand \index{-\/-cyclomatic}
10116
10117 \end_inset
10118
10119
10120 \bar under
10121  
10122 \series default
10123 \bar default
10124 This option will cause the compiler to generate an information message for
10125  each function in the source file.
10126  The message contains some 
10127 \emph on
10128 important
10129 \emph default
10130  information about the function.
10131  The number of edges and nodes the compiler detected in the control flow
10132  graph of the function, and most importantly the 
10133 \emph on
10134 cyclomatic complexity
10135 \begin_inset LatexCommand \index{Cyclomatic complexity}
10136
10137 \end_inset
10138
10139
10140 \emph default
10141  see section on Cyclomatic Complexity for more details.
10142 \end_layout
10143
10144 \begin_layout List
10145 \labelwidthstring 00.00.0000
10146
10147 \series bold
10148 -
10149 \begin_inset ERT
10150 status collapsed
10151
10152 \begin_layout Standard
10153
10154
10155 \backslash
10156 /
10157 \end_layout
10158
10159 \end_inset
10160
10161 -float-reent
10162 \begin_inset LatexCommand \index{-\/-float-reent}
10163
10164 \end_inset
10165
10166
10167 \series default
10168  Floating point library is compiled as reentrant
10169 \begin_inset LatexCommand \index{reentrant}
10170
10171 \end_inset
10172
10173 .
10174  See section Installation for more details.
10175 \end_layout
10176
10177 \begin_layout List
10178 \labelwidthstring 00.00.0000
10179
10180 \series bold
10181 -
10182 \begin_inset ERT
10183 status collapsed
10184
10185 \begin_layout Standard
10186
10187
10188 \backslash
10189 /
10190 \end_layout
10191
10192 \end_inset
10193
10194 -funsigned-char
10195 \begin_inset LatexCommand \index{-\/-funsigned-char}
10196
10197 \end_inset
10198
10199
10200 \series default
10201  The default signedness for every type is
10202 \family typewriter
10203  signed
10204 \family default
10205 .
10206  In some embedded environments the default signedness of
10207 \family typewriter
10208  char
10209 \family default
10210  is
10211 \family typewriter
10212  unsigned
10213 \family default
10214 .
10215  To set the signess for characters to unsigned, use the option -
10216 \series bold
10217
10218 \begin_inset ERT
10219 status open
10220
10221 \begin_layout Standard
10222
10223
10224 \backslash
10225 /
10226 \end_layout
10227
10228 \end_inset
10229
10230
10231 \series default
10232 -funsigned-char.
10233  If this option is set and no signedness keyword (unsigned/signed) is given,
10234  a char will be signed.
10235  All other types are unaffected.
10236 \end_layout
10237
10238 \begin_layout List
10239 \labelwidthstring 00.00.0000
10240
10241 \series bold
10242 -
10243 \begin_inset ERT
10244 status collapsed
10245
10246 \begin_layout Standard
10247
10248
10249 \backslash
10250 /
10251 \end_layout
10252
10253 \end_inset
10254
10255 -main-return
10256 \begin_inset LatexCommand \index{-\/-main-return}
10257
10258 \end_inset
10259
10260
10261 \series default
10262  This option can be used if the code generated is called by a monitor program
10263  or if the main routine includes an endless loop.
10264  This option results in slightly smaller code and saves two bytes of stack
10265  space.
10266  The return from the 'main'
10267 \begin_inset LatexCommand \index{main return}
10268
10269 \end_inset
10270
10271  function will return to the function calling main.
10272  The default setting is to lock up i.e.
10273  generate a '
10274 \family typewriter
10275 sjmp .
10276 \family default
10277 '.
10278 \end_layout
10279
10280 \begin_layout List
10281 \labelwidthstring 00.00.0000
10282
10283 \series bold
10284 -
10285 \begin_inset ERT
10286 status collapsed
10287
10288 \begin_layout Standard
10289
10290
10291 \backslash
10292 /
10293 \end_layout
10294
10295 \end_inset
10296
10297 -nostdinc
10298 \begin_inset LatexCommand \index{-\/-nostdinc}
10299
10300 \end_inset
10301
10302
10303 \series default
10304  This will prevent the compiler from passing on the default include path
10305  to the preprocessor.
10306 \end_layout
10307
10308 \begin_layout List
10309 \labelwidthstring 00.00.0000
10310
10311 \series bold
10312 -
10313 \begin_inset ERT
10314 status collapsed
10315
10316 \begin_layout Standard
10317
10318
10319 \backslash
10320 /
10321 \end_layout
10322
10323 \end_inset
10324
10325 -nostdlib
10326 \begin_inset LatexCommand \index{-\/-nostdlib}
10327
10328 \end_inset
10329
10330
10331 \series default
10332  This will prevent the compiler from passing on the default library
10333 \begin_inset LatexCommand \index{Libraries}
10334
10335 \end_inset
10336
10337  path to the linker.
10338 \end_layout
10339
10340 \begin_layout List
10341 \labelwidthstring 00.00.0000
10342
10343 \series bold
10344 -
10345 \begin_inset ERT
10346 status collapsed
10347
10348 \begin_layout Standard
10349
10350
10351 \backslash
10352 /
10353 \end_layout
10354
10355 \end_inset
10356
10357 -verbose
10358 \begin_inset LatexCommand \index{-\/-verbose}
10359
10360 \end_inset
10361
10362
10363 \series default
10364  Shows the various actions the compiler is performing.
10365 \end_layout
10366
10367 \begin_layout List
10368 \labelwidthstring 00.00.0000
10369
10370 \series bold
10371 -V
10372 \begin_inset LatexCommand \index{-V}
10373
10374 \end_inset
10375
10376
10377 \series default
10378  Shows the actual commands the compiler is executing.
10379 \end_layout
10380
10381 \begin_layout List
10382 \labelwidthstring 00.00.0000
10383
10384 \series bold
10385 -
10386 \begin_inset ERT
10387 status collapsed
10388
10389 \begin_layout Standard
10390
10391
10392 \backslash
10393 /
10394 \end_layout
10395
10396 \end_inset
10397
10398 -no-c-code-in-asm
10399 \begin_inset LatexCommand \index{-\/-no-c-code-in-asm}
10400
10401 \end_inset
10402
10403
10404 \series default
10405  Hides your ugly and inefficient c-code from the asm file, so you can always
10406  blame the compiler :)
10407 \end_layout
10408
10409 \begin_layout List
10410 \labelwidthstring 00.00.0000
10411
10412 \series bold
10413 -
10414 \begin_inset ERT
10415 status collapsed
10416
10417 \begin_layout Standard
10418
10419
10420 \backslash
10421 /
10422 \end_layout
10423
10424 \end_inset
10425
10426 -fverbose-asm
10427 \begin_inset LatexCommand \index{-\/-no-gen-comments}
10428
10429 \end_inset
10430
10431
10432 \series default
10433  Include code generator and peep-hole comments in the generated asm files.
10434 \end_layout
10435
10436 \begin_layout List
10437 \labelwidthstring 00.00.0000
10438
10439 \series bold
10440 -
10441 \begin_inset ERT
10442 status collapsed
10443
10444 \begin_layout Standard
10445
10446
10447 \backslash
10448 /
10449 \end_layout
10450
10451 \end_inset
10452
10453 -no-peep-comments
10454 \begin_inset LatexCommand \index{-\/-no-peep-comments}
10455
10456 \end_inset
10457
10458
10459 \series default
10460  Don't include peep-hole comments in the generated asm files even if -
10461 \series bold
10462
10463 \begin_inset ERT
10464 status open
10465
10466 \begin_layout Standard
10467
10468
10469 \backslash
10470 /
10471 \end_layout
10472
10473 \end_inset
10474
10475
10476 \series default
10477 -fverbose-asm option is specified.
10478 \end_layout
10479
10480 \begin_layout List
10481 \labelwidthstring 00.00.0000
10482
10483 \series bold
10484 -
10485 \begin_inset ERT
10486 status collapsed
10487
10488 \begin_layout Standard
10489
10490
10491 \backslash
10492 /
10493 \end_layout
10494
10495 \end_inset
10496
10497 -i-code-in-asm
10498 \begin_inset LatexCommand \index{-\/-i-code-in-asm}
10499
10500 \end_inset
10501
10502
10503 \series default
10504  Include i-codes in the asm file.
10505  Sounds like noise but is most helpful for debugging the compiler itself.
10506 \end_layout
10507
10508 \begin_layout List
10509 \labelwidthstring 00.00.0000
10510
10511 \series bold
10512 -
10513 \begin_inset ERT
10514 status collapsed
10515
10516 \begin_layout Standard
10517
10518
10519 \backslash
10520 /
10521 \end_layout
10522
10523 \end_inset
10524
10525 -less-pedantic
10526 \begin_inset LatexCommand \index{pedantic}
10527
10528 \end_inset
10529
10530
10531 \begin_inset LatexCommand \index{-\/-less-pedantic}
10532
10533 \end_inset
10534
10535
10536 \series default
10537
10538 \begin_inset LatexCommand \label{lyx:--less-pedantic}
10539
10540 \end_inset
10541
10542  Disable some of the more pedantic warnings
10543 \begin_inset LatexCommand \index{Warnings}
10544
10545 \end_inset
10546
10547 .
10548  For more details, see the less_pedantic pragma 
10549 \begin_inset LatexCommand \vpageref{ite:less_pedantic}
10550
10551 \end_inset
10552
10553 .
10554 \end_layout
10555
10556 \begin_layout List
10557 \labelwidthstring 00.00.0000
10558
10559 \series bold
10560 -
10561 \begin_inset ERT
10562 status collapsed
10563
10564 \begin_layout Standard
10565
10566
10567 \backslash
10568 /
10569 \end_layout
10570
10571 \end_inset
10572
10573 -disable-warning\InsetSpace ~
10574 <nnnn>
10575 \begin_inset LatexCommand \index{-\/-disable-warning}
10576
10577 \end_inset
10578
10579
10580 \series default
10581  Disable specific warning with number <nnnn>.
10582 \end_layout
10583
10584 \begin_layout List
10585 \labelwidthstring 00.00.0000
10586
10587 \series bold
10588 -
10589 \begin_inset ERT
10590 status collapsed
10591
10592 \begin_layout Standard
10593
10594
10595 \backslash
10596 /
10597 \end_layout
10598
10599 \end_inset
10600
10601 -Werror
10602 \begin_inset LatexCommand \index{-\/-Werror}
10603
10604 \end_inset
10605
10606
10607 \series default
10608  Treat all warnings as errors.
10609 \end_layout
10610
10611 \begin_layout List
10612 \labelwidthstring 00.00.0000
10613
10614 \series bold
10615 -
10616 \begin_inset ERT
10617 status collapsed
10618
10619 \begin_layout Standard
10620
10621
10622 \backslash
10623 /
10624 \end_layout
10625
10626 \end_inset
10627
10628 -print-search-dirs
10629 \begin_inset LatexCommand \index{-\/-print-search-dirs}
10630
10631 \end_inset
10632
10633
10634 \series default
10635  Display the directories in the compiler's search path
10636 \end_layout
10637
10638 \begin_layout List
10639 \labelwidthstring 00.00.0000
10640
10641 \series bold
10642 -
10643 \begin_inset ERT
10644 status collapsed
10645
10646 \begin_layout Standard
10647
10648
10649 \backslash
10650 /
10651 \end_layout
10652
10653 \end_inset
10654
10655 -vc
10656 \begin_inset LatexCommand \index{-\/-vc}
10657
10658 \end_inset
10659
10660
10661 \series default
10662  Display errors and warnings using MSVC style, so you can use SDCC with
10663  the visual studio IDE
10664 \begin_inset LatexCommand \index{IDE}
10665
10666 \end_inset
10667
10668 .
10669  With SDCC both offering a GCC-like (the default) and a MSVC-like
10670 \begin_inset LatexCommand \index{MSVC output style}
10671
10672 \end_inset
10673
10674  output style, integration into most programming editors should be straightforwa
10675 rd.
10676 \end_layout
10677
10678 \begin_layout List
10679 \labelwidthstring 00.00.0000
10680
10681 \series bold
10682 -
10683 \begin_inset ERT
10684 status collapsed
10685
10686 \begin_layout Standard
10687
10688
10689 \backslash
10690 /
10691 \end_layout
10692
10693 \end_inset
10694
10695 -use-stdout
10696 \begin_inset LatexCommand \index{-\/-use-stdout}
10697
10698 \end_inset
10699
10700
10701 \series default
10702  Send errors and warnings to stdout instead of stderr.
10703 \end_layout
10704
10705 \begin_layout List
10706 \labelwidthstring 00.00.0000
10707
10708 \series bold
10709 -Wa\InsetSpace ~
10710 asmOption[,asmOption]
10711 \series default
10712
10713 \begin_inset LatexCommand \index{-Wa asmOption[,asmOption]}
10714
10715 \end_inset
10716
10717 ...
10718  Pass the asmOption to the assembler
10719 \begin_inset LatexCommand \index{Options assembler}
10720
10721 \end_inset
10722
10723
10724 \begin_inset LatexCommand \index{Assembler options}
10725
10726 \end_inset
10727
10728 .
10729  See file sdcc/as/doc/asxhtm.html for assembler options.cd
10730 \end_layout
10731
10732 \begin_layout List
10733 \labelwidthstring 00.00.0000
10734
10735 \series bold
10736 -
10737 \begin_inset ERT
10738 status collapsed
10739
10740 \begin_layout Standard
10741
10742
10743 \backslash
10744 /
10745 \end_layout
10746
10747 \end_inset
10748
10749 -std-sdcc89
10750 \begin_inset LatexCommand \index{-\/-std-sdcc89}
10751
10752 \end_inset
10753
10754
10755 \series default
10756  Generally follow the C89 standard, but allow SDCC features that conflict
10757  with the standard (default).
10758 \end_layout
10759
10760 \begin_layout List
10761 \labelwidthstring 00.00.0000
10762
10763 \series bold
10764 -
10765 \begin_inset ERT
10766 status collapsed
10767
10768 \begin_layout Standard
10769
10770
10771 \backslash
10772 /
10773 \end_layout
10774
10775 \end_inset
10776
10777 -std-c89
10778 \begin_inset LatexCommand \index{-\/-std-c89}
10779
10780 \end_inset
10781
10782
10783 \series default
10784  Follow the C89 standard and disable SDCC features that conflict with the
10785  standard.
10786 \end_layout
10787
10788 \begin_layout List
10789 \labelwidthstring 00.00.0000
10790
10791 \series bold
10792 -
10793 \begin_inset ERT
10794 status collapsed
10795
10796 \begin_layout Standard
10797
10798
10799 \backslash
10800 /
10801 \end_layout
10802
10803 \end_inset
10804
10805 -std-sdcc99
10806 \begin_inset LatexCommand \index{-\/-std-sdcc99}
10807
10808 \end_inset
10809
10810
10811 \series default
10812  Generally follow the C99 standard, but allow SDCC features that conflict
10813  with the standard (incomplete support).
10814 \end_layout
10815
10816 \begin_layout List
10817 \labelwidthstring 00.00.0000
10818
10819 \series bold
10820 -
10821 \begin_inset ERT
10822 status collapsed
10823
10824 \begin_layout Standard
10825
10826
10827 \backslash
10828 /
10829 \end_layout
10830
10831 \end_inset
10832
10833 -std-c99
10834 \begin_inset LatexCommand \index{-\/-std-sdcc99}
10835
10836 \end_inset
10837
10838
10839 \series default
10840  Follow the C99 standard and disable SDCC features that conflict with the
10841  standard (incomplete support).
10842 \end_layout
10843
10844 \begin_layout List
10845 \labelwidthstring 00.00.0000
10846
10847 \series bold
10848 -
10849 \begin_inset ERT
10850 status collapsed
10851
10852 \begin_layout Standard
10853
10854
10855 \backslash
10856 /
10857 \end_layout
10858
10859 \end_inset
10860
10861 -codeseg
10862 \series default
10863
10864 \begin_inset LatexCommand \index{-\/-codeseg <Value>}
10865
10866 \end_inset
10867
10868
10869 \begin_inset LatexCommand \label{lyx:-codeseg}
10870
10871 \end_inset
10872
10873 \InsetSpace ~
10874 <Name> The name to be used for the code
10875 \begin_inset LatexCommand \index{code}
10876
10877 \end_inset
10878
10879  segment, default CSEG.
10880  This is useful if you need to tell the compiler to put the code in a special
10881  segment so you can later on tell the linker to put this segment in a special
10882  place in memory.
10883  Can be used for instance when using bank switching to put the code in a
10884  bank.
10885 \end_layout
10886
10887 \begin_layout List
10888 \labelwidthstring 00.00.0000
10889
10890 \series bold
10891 -
10892 \begin_inset ERT
10893 status collapsed
10894
10895 \begin_layout Standard
10896
10897
10898 \backslash
10899 /
10900 \end_layout
10901
10902 \end_inset
10903
10904 -constseg
10905 \series default
10906
10907 \begin_inset LatexCommand \index{-\/-constseg <Value>}
10908
10909 \end_inset
10910
10911 \InsetSpace ~
10912 <Name> The name to be used for the const
10913 \begin_inset LatexCommand \index{const}
10914
10915 \end_inset
10916
10917  segment, default CONST.
10918  This is useful if you need to tell the compiler to put the const data in
10919  a special segment so you can later on tell the linker to put this segment
10920  in a special place in memory.
10921  Can be used for instance when using bank switching to put the const data
10922  in a bank.
10923 \end_layout
10924
10925 \begin_layout List
10926 \labelwidthstring 00.00.0000
10927
10928 \series bold
10929 -
10930 \begin_inset ERT
10931 status collapsed
10932
10933 \begin_layout Standard
10934
10935
10936 \backslash
10937 /
10938 \end_layout
10939
10940 \end_inset
10941
10942 -fdollars-in-identifiers
10943 \begin_inset LatexCommand \index{-\/-fdollars-in-identifiers}
10944
10945 \end_inset
10946
10947
10948 \series default
10949  Permit '$' as an identifier character.
10950 \end_layout
10951
10952 \begin_layout List
10953 \labelwidthstring 00.00.0000
10954
10955 \series bold
10956 -
10957 \begin_inset ERT
10958 status collapsed
10959
10960 \begin_layout Standard
10961
10962
10963 \backslash
10964 /
10965 \end_layout
10966
10967 \end_inset
10968
10969 -more-pedantic
10970 \series default
10971
10972 \begin_inset LatexCommand \index{-\/-more-pedantic}
10973
10974 \end_inset
10975
10976
10977 \begin_inset LatexCommand \index{pedantic}
10978
10979 \end_inset
10980
10981  Actually this is 
10982 \series bold
10983 \emph on
10984 not
10985 \series default
10986 \emph default
10987  a SDCC compiler option but if you want 
10988 \emph on
10989 more
10990 \emph default
10991  warnings you can use a separate tool dedicated to syntax checking like
10992  splint
10993 \begin_inset LatexCommand \label{lyx:more-pedantic-SPLINT}
10994
10995 \end_inset
10996
10997
10998 \begin_inset LatexCommand \index{lint (syntax checking tool)}
10999
11000 \end_inset
11001
11002  
11003 \begin_inset LatexCommand \url{http://www.splint.org}
11004
11005 \end_inset
11006
11007 .
11008  To make your source files parseable by splint you will have to include
11009  
11010 \family sans
11011 lint.h
11012 \family default
11013
11014 \begin_inset LatexCommand \index{splint (syntax checking tool)}
11015
11016 \end_inset
11017
11018  in your source file and add brackets around extended keywords (like 
11019 \family sans
11020
11021 \begin_inset Quotes sld
11022 \end_inset
11023
11024 __at\InsetSpace ~
11025
11026 \series bold
11027 (
11028 \series default
11029 0xab
11030 \series bold
11031 )
11032 \series default
11033
11034 \begin_inset Quotes srd
11035 \end_inset
11036
11037
11038 \family default
11039  and 
11040 \family sans
11041
11042 \begin_inset Quotes sld
11043 \end_inset
11044
11045 __interrupt\InsetSpace ~
11046 (2)
11047 \begin_inset Quotes srd
11048 \end_inset
11049
11050
11051 \family default
11052 ).
11053  
11054 \newline
11055 Splint has an excellent on line manual at 
11056 \begin_inset LatexCommand \url{http://www.splint.org/manual/}
11057
11058 \end_inset
11059
11060  and it's capabilities go beyond pure syntax checking.
11061  You'll need to tell splint the location of SDCC's include files so a typical
11062  command line could look like this: 
11063 \newline
11064
11065 \family sans
11066 splint\InsetSpace ~
11067 -I\InsetSpace ~
11068 /usr/local/share/sdcc/include/mcs51/\InsetSpace ~
11069 \InsetSpace ~
11070 myprogram.c
11071 \end_layout
11072
11073 \begin_layout List
11074 \labelwidthstring 00.00.0000
11075
11076 \series bold
11077 -
11078 \begin_inset ERT
11079 status collapsed
11080
11081 \begin_layout Standard
11082
11083
11084 \backslash
11085 /
11086 \end_layout
11087
11088 \end_inset
11089
11090 -short-is-8bits
11091 \series default
11092
11093 \begin_inset LatexCommand \index{-\/-short-is-8bits}
11094
11095 \end_inset
11096
11097
11098 \begin_inset LatexCommand \label{lyx:--short-is-8bits}
11099
11100 \end_inset
11101
11102  Treat short as 8-bit (for backward compatibility with older versions of
11103  compiler - see section 
11104 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
11105
11106 \end_inset
11107
11108 )
11109 \end_layout
11110
11111 \begin_layout Standard
11112 \begin_inset VSpace bigskip
11113 \end_inset
11114
11115
11116 \end_layout
11117
11118 \begin_layout Subsection
11119 Intermediate Dump Options
11120 \begin_inset LatexCommand \label{sub:Intermediate-Dump-Options}
11121
11122 \end_inset
11123
11124
11125 \begin_inset LatexCommand \index{Options intermediate dump}
11126
11127 \end_inset
11128
11129
11130 \begin_inset LatexCommand \index{Intermediate dump options}
11131
11132 \end_inset
11133
11134
11135 \end_layout
11136
11137 \begin_layout Standard
11138 The following options are provided for the purpose of retargetting and debugging
11139  the compiler.
11140  They provide a means to dump the intermediate code (iCode
11141 \begin_inset LatexCommand \index{iCode}
11142
11143 \end_inset
11144
11145 ) generated by the compiler in human readable form at various stages of
11146  the compilation process.
11147  More on iCodes see chapter 
11148 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
11149
11150 \end_inset
11151
11152  
11153 \begin_inset Quotes srd
11154 \end_inset
11155
11156 The anatomy of the compiler
11157 \begin_inset Quotes srd
11158 \end_inset
11159
11160 .
11161 \end_layout
11162
11163 \begin_layout List
11164 \labelwidthstring 00.00.0000
11165
11166 \series bold
11167 -
11168 \begin_inset ERT
11169 status collapsed
11170
11171 \begin_layout Standard
11172
11173
11174 \backslash
11175 /
11176 \end_layout
11177
11178 \end_inset
11179
11180 -dumpraw
11181 \begin_inset LatexCommand \index{-\/-dumpraw}
11182
11183 \end_inset
11184
11185
11186 \series default
11187  This option will cause the compiler to dump the intermediate code into
11188  a file of named 
11189 \emph on
11190 <source filename>.dumpraw
11191 \emph default
11192  just after the intermediate code has been generated for a function, i.e.
11193  before any optimizations are done.
11194  The basic blocks
11195 \begin_inset LatexCommand \index{Basic blocks}
11196
11197 \end_inset
11198
11199  at this stage ordered in the depth first number, so they may not be in
11200  sequence of execution.
11201 \end_layout
11202
11203 \begin_layout List
11204 \labelwidthstring 00.00.0000
11205
11206 \series bold
11207 -
11208 \begin_inset ERT
11209 status collapsed
11210
11211 \begin_layout Standard
11212
11213
11214 \backslash
11215 /
11216 \end_layout
11217
11218 \end_inset
11219
11220 -dumpgcse
11221 \begin_inset LatexCommand \index{-\/-dumpgcse}
11222
11223 \end_inset
11224
11225
11226 \series default
11227  Will create a dump of iCodes, after global subexpression elimination
11228 \begin_inset LatexCommand \index{Global subexpression elimination}
11229
11230 \end_inset
11231
11232 , into a file named 
11233 \emph on
11234 <source filename>.dumpgcse.
11235 \end_layout
11236
11237 \begin_layout List
11238 \labelwidthstring 00.00.0000
11239
11240 \series bold
11241 -
11242 \begin_inset ERT
11243 status collapsed
11244
11245 \begin_layout Standard
11246
11247
11248 \backslash
11249 /
11250 \end_layout
11251
11252 \end_inset
11253
11254 -dumpdeadcode
11255 \begin_inset LatexCommand \index{-\/-dumpdeadcode}
11256
11257 \end_inset
11258
11259
11260 \series default
11261  Will create a dump of iCodes, after deadcode elimination
11262 \begin_inset LatexCommand \index{Dead-code elimination}
11263
11264 \end_inset
11265
11266 , into a file named 
11267 \emph on
11268 <source filename>.dumpdeadcode.
11269 \end_layout
11270
11271 \begin_layout List
11272 \labelwidthstring 00.00.0000
11273
11274 \series bold
11275 -
11276 \begin_inset ERT
11277 status collapsed
11278
11279 \begin_layout Standard
11280
11281
11282 \backslash
11283 /
11284 \end_layout
11285
11286 \end_inset
11287
11288 -dumploop
11289 \begin_inset LatexCommand \index{-\/-dumploop}
11290
11291 \end_inset
11292
11293
11294 \series default
11295 \size large
11296  
11297 \size default
11298 Will create a dump of iCodes, after loop optimizations
11299 \begin_inset LatexCommand \index{Loop optimization}
11300
11301 \end_inset
11302
11303 , into a file named 
11304 \emph on
11305 <source filename>.dumploop.
11306 \end_layout
11307
11308 \begin_layout List
11309 \labelwidthstring 00.00.0000
11310
11311 \series bold
11312 -
11313 \begin_inset ERT
11314 status collapsed
11315
11316 \begin_layout Standard
11317
11318
11319 \backslash
11320 /
11321 \end_layout
11322
11323 \end_inset
11324
11325 -dumprange
11326 \begin_inset LatexCommand \index{-\/-dumprange}
11327
11328 \end_inset
11329
11330
11331 \series default
11332 \size large
11333  
11334 \size default
11335 Will create a dump of iCodes, after live range analysis
11336 \begin_inset LatexCommand \index{Live range analysis}
11337
11338 \end_inset
11339
11340 , into a file named 
11341 \emph on
11342 <source filename>.dumprange.
11343 \end_layout
11344
11345 \begin_layout List
11346 \labelwidthstring 00.00.0000
11347
11348 \series bold
11349 -
11350 \begin_inset ERT
11351 status collapsed
11352
11353 \begin_layout Standard
11354
11355
11356 \backslash
11357 /
11358 \end_layout
11359
11360 \end_inset
11361
11362 -dumlrange
11363 \begin_inset LatexCommand \index{-\/-dumlrange}
11364
11365 \end_inset
11366
11367
11368 \series default
11369  Will dump the life ranges
11370 \begin_inset LatexCommand \index{Live range analysis}
11371
11372 \end_inset
11373
11374  for all symbols.
11375 \end_layout
11376
11377 \begin_layout List
11378 \labelwidthstring 00.00.0000
11379
11380 \series bold
11381 -
11382 \begin_inset ERT
11383 status collapsed
11384
11385 \begin_layout Standard
11386
11387
11388 \backslash
11389 /
11390 \end_layout
11391
11392 \end_inset
11393
11394 -dumpregassign
11395 \begin_inset LatexCommand \index{-\/-dumpregassign}
11396
11397 \end_inset
11398
11399
11400 \bar under
11401  
11402 \series default
11403 \bar default
11404 Will create a dump of iCodes, after register assignment
11405 \begin_inset LatexCommand \index{Register assignment}
11406
11407 \end_inset
11408
11409 , into a file named 
11410 \emph on
11411 <source filename>.dumprassgn.
11412 \end_layout
11413
11414 \begin_layout List
11415 \labelwidthstring 00.00.0000
11416
11417 \series bold
11418 -
11419 \begin_inset ERT
11420 status collapsed
11421
11422 \begin_layout Standard
11423
11424
11425 \backslash
11426 /
11427 \end_layout
11428
11429 \end_inset
11430
11431 -dumplrange
11432 \begin_inset LatexCommand \index{-\/-dumplrange}
11433
11434 \end_inset
11435
11436
11437 \series default
11438  Will create a dump of the live ranges of iTemp's
11439 \end_layout
11440
11441 \begin_layout List
11442 \labelwidthstring 00.00.0000
11443
11444 \series bold
11445 -
11446 \begin_inset ERT
11447 status collapsed
11448
11449 \begin_layout Standard
11450
11451
11452 \backslash
11453 /
11454 \end_layout
11455
11456 \end_inset
11457
11458 -dumpall
11459 \begin_inset LatexCommand \index{-\/-dumpall}
11460
11461 \end_inset
11462
11463
11464 \size large
11465 \bar under
11466  
11467 \series default
11468 \size default
11469 \bar default
11470 Will cause all the above mentioned dumps to be created.
11471 \end_layout
11472
11473 \begin_layout Standard
11474 \begin_inset VSpace bigskip
11475 \end_inset
11476
11477
11478 \end_layout
11479
11480 \begin_layout Subsection
11481 Redirecting output on Windows Shells
11482 \end_layout
11483
11484 \begin_layout Standard
11485 By default SDCC writes its error messages to 
11486 \begin_inset Quotes sld
11487 \end_inset
11488
11489 standard error
11490 \begin_inset Quotes srd
11491 \end_inset
11492
11493 .
11494  To force all messages to 
11495 \begin_inset Quotes sld
11496 \end_inset
11497
11498 standard output
11499 \begin_inset Quotes srd
11500 \end_inset
11501
11502  use 
11503 \series bold
11504 -
11505 \series default
11506 \emph on
11507
11508 \begin_inset ERT
11509 status collapsed
11510
11511 \begin_layout Standard
11512
11513
11514 \backslash
11515 /
11516 \end_layout
11517
11518 \end_inset
11519
11520
11521 \series bold
11522 \emph default
11523 -
11524 \series default
11525 use-stdout
11526 \begin_inset LatexCommand \index{-\/-use-stdout}
11527
11528 \end_inset
11529
11530 .
11531  Additionally, if you happen to have visual studio installed in your windows
11532  machine, you can use it to compile your sources using a custom build and
11533  the SDCC -
11534 \emph on
11535
11536 \begin_inset ERT
11537 status collapsed
11538
11539 \begin_layout Standard
11540
11541
11542 \backslash
11543 /
11544 \end_layout
11545
11546 \end_inset
11547
11548
11549 \emph default
11550 -vc
11551 \begin_inset LatexCommand \index{-\/-vc}
11552
11553 \end_inset
11554
11555  option.
11556  Something like this should work:
11557 \newline
11558
11559 \newline
11560
11561 \series bold
11562 c:
11563 \backslash
11564 sdcc
11565 \backslash
11566 bin
11567 \backslash
11568 sdcc.exe -
11569 \series default
11570 \emph on
11571
11572 \begin_inset ERT
11573 status collapsed
11574
11575 \begin_layout Standard
11576
11577
11578 \backslash
11579 /
11580 \end_layout
11581
11582 \end_inset
11583
11584
11585 \series bold
11586 \emph default
11587 -vc -
11588 \series default
11589 \emph on
11590
11591 \begin_inset ERT
11592 status collapsed
11593
11594 \begin_layout Standard
11595
11596
11597 \backslash
11598 /
11599 \end_layout
11600
11601 \end_inset
11602
11603
11604 \series bold
11605 \emph default
11606 -model-large -c $(InputPath)
11607 \series default
11608
11609 \begin_inset VSpace bigskip
11610 \end_inset
11611
11612
11613 \end_layout
11614
11615 \begin_layout Section
11616 Environment variables
11617 \begin_inset LatexCommand \index{Environment variables}
11618
11619 \end_inset
11620
11621
11622 \end_layout
11623
11624 \begin_layout Standard
11625 SDCC recognizes the following environment variables:
11626 \end_layout
11627
11628 \begin_layout List
11629 \labelwidthstring 00.00.0000
11630
11631 \series bold
11632 SDCC_LEAVE_SIGNALS
11633 \begin_inset LatexCommand \index{SDCC\_LEAVE\_SIGNALS}
11634
11635 \end_inset
11636
11637
11638 \series default
11639  SDCC installs a signal handler
11640 \begin_inset LatexCommand \index{signal handler}
11641
11642 \end_inset
11643
11644  to be able to delete temporary files after an user break (^C) or an exception.
11645  If this environment variable is set, SDCC won't install the signal handler
11646  in order to be able to debug SDCC.
11647 \end_layout
11648
11649 \begin_layout List
11650 \labelwidthstring 00.00.0000
11651
11652 \series bold
11653 TMP,\InsetSpace ~
11654 TEMP,\InsetSpace ~
11655 TMPDIR
11656 \begin_inset LatexCommand \index{TMP, TEMP, TMPDIR}
11657
11658 \end_inset
11659
11660
11661 \series default
11662  Path, where temporary files will be created.
11663  The order of the variables is the search order.
11664  In a standard *nix environment these variables are not set, and there's
11665  no need to set them.
11666  On Windows it's recommended to set one of them.
11667 \end_layout
11668
11669 \begin_layout List
11670 \labelwidthstring 00.00.0000
11671
11672 \series bold
11673 SDCC_HOME
11674 \begin_inset LatexCommand \index{SDCC\_HOME}
11675
11676 \end_inset
11677
11678
11679 \series default
11680  Path, see section 
11681 \begin_inset LatexCommand \ref{sub:Install-paths}
11682
11683 \end_inset
11684
11685 \InsetSpace ~
11686
11687 \begin_inset Quotes sld
11688 \end_inset
11689
11690  Install Paths
11691 \begin_inset Quotes srd
11692 \end_inset
11693
11694 .
11695 \end_layout
11696
11697 \begin_layout List
11698 \labelwidthstring 00.00.0000
11699
11700 \series bold
11701 SDCC_INCLUDE
11702 \begin_inset LatexCommand \index{SDCC\_INCLUDE}
11703
11704 \end_inset
11705
11706
11707 \series default
11708  Path, see section 
11709 \begin_inset LatexCommand \ref{sub:Search-Paths}
11710
11711 \end_inset
11712
11713 \InsetSpace ~
11714
11715 \begin_inset Quotes sld
11716 \end_inset
11717
11718 Search Paths
11719 \begin_inset Quotes srd
11720 \end_inset
11721
11722 .
11723 \end_layout
11724
11725 \begin_layout List
11726 \labelwidthstring 00.00.0000
11727
11728 \series bold
11729 SDCC_LIB
11730 \begin_inset LatexCommand \index{SDCC\_LIB}
11731
11732 \end_inset
11733
11734
11735 \series default
11736  Path, see section 
11737 \begin_inset LatexCommand \ref{sub:Search-Paths}
11738
11739 \end_inset
11740
11741 \InsetSpace ~
11742
11743 \begin_inset Quotes sld
11744 \end_inset
11745
11746 Search Paths
11747 \begin_inset Quotes srd
11748 \end_inset
11749
11750 ..
11751 \end_layout
11752
11753 \begin_layout Standard
11754 There are some more environment variables recognized by SDCC, but these
11755  are solely used for debugging purposes.
11756  They can change or disappear very quickly, and will never be documented.
11757 \begin_inset VSpace bigskip
11758 \end_inset
11759
11760
11761 \end_layout
11762
11763 \begin_layout Section
11764 Storage Class Language Extensions
11765 \end_layout
11766
11767 \begin_layout Subsection
11768 MCS51/DS390 Storage Class
11769 \begin_inset LatexCommand \index{Storage class}
11770
11771 \end_inset
11772
11773  Language Extensions
11774 \end_layout
11775
11776 \begin_layout Standard
11777 In addition to the ANSI storage classes SDCC allows the following MCS51
11778  specific storage classes:
11779 \end_layout
11780
11781 \begin_layout Subsubsection
11782 data
11783 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
11784
11785 \end_inset
11786
11787
11788 \begin_inset LatexCommand \index{\_\_data (mcs51, ds390 storage class)}
11789
11790 \end_inset
11791
11792  / near
11793 \begin_inset LatexCommand \index{near (storage class)}
11794
11795 \end_inset
11796
11797
11798 \begin_inset LatexCommand \index{\_\_near (storage class)}
11799
11800 \end_inset
11801
11802
11803 \end_layout
11804
11805 \begin_layout Standard
11806 This is the 
11807 \series bold
11808 default
11809 \series default
11810  storage class for the Small Memory model (
11811 \emph on
11812 data
11813 \emph default
11814  and 
11815 \emph on
11816 near
11817 \emph default
11818  or the more ANSI-C compliant forms 
11819 \emph on
11820 __data
11821 \emph default
11822  and 
11823 \emph on
11824 __near
11825 \emph default
11826  can be used synonymously).
11827  Variables declared with this storage class will be allocated in the directly
11828  addressable portion of the internal RAM of a 8051, e.g.:
11829 \end_layout
11830
11831 \begin_layout Verse
11832
11833 \family typewriter
11834 __data unsigned char test_data;
11835 \end_layout
11836
11837 \begin_layout Standard
11838 Writing 0x01 to this variable generates the assembly code:
11839 \end_layout
11840
11841 \begin_layout Verse
11842
11843 \family typewriter
11844 75*00 01\InsetSpace ~
11845 \InsetSpace ~
11846 \InsetSpace ~
11847 mov\InsetSpace ~
11848 \InsetSpace ~
11849 _test_data,#0x01
11850 \end_layout
11851
11852 \begin_layout Subsubsection
11853 xdata
11854 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
11855
11856 \end_inset
11857
11858
11859 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
11860
11861 \end_inset
11862
11863  / far
11864 \begin_inset LatexCommand \index{far (storage class)}
11865
11866 \end_inset
11867
11868
11869 \begin_inset LatexCommand \index{\_\_far (storage class)}
11870
11871 \end_inset
11872
11873
11874 \end_layout
11875
11876 \begin_layout Standard
11877 Variables declared with this storage class will be placed in the external
11878  RAM.
11879  This is the 
11880 \series bold
11881 default
11882 \series default
11883  storage class for the Large Memory model, e.g.:
11884 \end_layout
11885
11886 \begin_layout Verse
11887
11888 \family typewriter
11889 __xdata unsigned char test_xdata;
11890 \end_layout
11891
11892 \begin_layout Standard
11893 Writing 0x01 to this variable generates the assembly code:
11894 \end_layout
11895
11896 \begin_layout Verse
11897
11898 \family typewriter
11899 90s00r00\InsetSpace ~
11900 \InsetSpace ~
11901 \InsetSpace ~
11902 mov\InsetSpace ~
11903 \InsetSpace ~
11904 dptr,#_test_xdata 
11905 \newline
11906 74\InsetSpace ~
11907 01\InsetSpace ~
11908 \InsetSpace ~
11909 \InsetSpace ~
11910 \InsetSpace ~
11911 \InsetSpace ~
11912 \InsetSpace ~
11913 mov\InsetSpace ~
11914 \InsetSpace ~
11915 a,#0x01 
11916 \newline
11917 F0\InsetSpace ~
11918 \InsetSpace ~
11919 \InsetSpace ~
11920 \InsetSpace ~
11921 \InsetSpace ~
11922 \InsetSpace ~
11923 \InsetSpace ~
11924 \InsetSpace ~
11925 \InsetSpace ~
11926 movx\InsetSpace ~
11927 @dptr,a 
11928 \end_layout
11929
11930 \begin_layout Subsubsection
11931 idata
11932 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
11933
11934 \end_inset
11935
11936
11937 \begin_inset LatexCommand \index{\_\_idata (mcs51, ds390 storage class)}
11938
11939 \end_inset
11940
11941
11942 \end_layout
11943
11944 \begin_layout Standard
11945 Variables declared with this storage class will be allocated into the indirectly
11946  addressable portion of the internal ram of a 8051, e.g.:
11947 \end_layout
11948
11949 \begin_layout Verse
11950
11951 \family typewriter
11952 __idata unsigned char test_idata;
11953 \end_layout
11954
11955 \begin_layout Standard
11956 Writing 0x01 to this variable generates the assembly code:
11957 \end_layout
11958
11959 \begin_layout Verse
11960
11961 \family typewriter
11962 78r00\InsetSpace ~
11963 \InsetSpace ~
11964 \InsetSpace ~
11965 \InsetSpace ~
11966 \InsetSpace ~
11967 \InsetSpace ~
11968 \InsetSpace ~
11969 mov\InsetSpace ~
11970 \InsetSpace ~
11971 r0,#_test_idata
11972 \newline
11973 76\InsetSpace ~
11974 01\InsetSpace ~
11975 \InsetSpace ~
11976 \InsetSpace ~
11977 \InsetSpace ~
11978 \InsetSpace ~
11979 \InsetSpace ~
11980 \InsetSpace ~
11981 mov\InsetSpace ~
11982 \InsetSpace ~
11983 @r0,#0x01
11984 \end_layout
11985
11986 \begin_layout Standard
11987 Please note, the first 128 byte of idata physically access the same RAM
11988  as the data memory.
11989  The original 8051 had 128 byte idata memory, nowadays most devices have
11990  256 byte idata memory.
11991  The stack
11992 \begin_inset LatexCommand \index{stack}
11993
11994 \end_inset
11995
11996  is located in idata memory.
11997 \end_layout
11998
11999 \begin_layout Subsubsection
12000 pdata
12001 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
12002
12003 \end_inset
12004
12005
12006 \begin_inset LatexCommand \index{\_\_pdata (mcs51, ds390 storage class)}
12007
12008 \end_inset
12009
12010
12011 \end_layout
12012
12013 \begin_layout Standard
12014 Paged xdata access is just as straightforward as using the other addressing
12015  modes of a 8051.
12016  It is typically located at the start of xdata and has a maximum size of
12017  256 bytes.
12018  The following example writes 0x01 to the pdata variable.
12019  Please note, pdata access physically accesses xdata memory.
12020  The high byte of the address is determined by port P2 
12021 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
12022
12023 \end_inset
12024
12025 (or in case of some 8051 variants by a separate Special Function Register,
12026  see section 
12027 \begin_inset LatexCommand \ref{sub:MCS51-variants}
12028
12029 \end_inset
12030
12031 ).
12032  This is the 
12033 \series bold
12034 default
12035 \series default
12036  storage class for the Medium Memory model, e.g.:
12037 \end_layout
12038
12039 \begin_layout Verse
12040
12041 \family typewriter
12042 __pdata unsigned char test_pdata;
12043 \end_layout
12044
12045 \begin_layout Standard
12046 Writing 0x01 to this variable generates the assembly code:
12047 \end_layout
12048
12049 \begin_layout Verse
12050
12051 \family typewriter
12052 78r00\InsetSpace ~
12053 \InsetSpace ~
12054 \InsetSpace ~
12055 \InsetSpace ~
12056 \InsetSpace ~
12057 \InsetSpace ~
12058 mov r0,#_test_pdata
12059 \newline
12060 74 01\InsetSpace ~
12061 \InsetSpace ~
12062 \InsetSpace ~
12063 \InsetSpace ~
12064 \InsetSpace ~
12065 \InsetSpace ~
12066 mov a,#0x01 
12067 \newline
12068 F2\InsetSpace ~
12069 \InsetSpace ~
12070 \InsetSpace ~
12071 \InsetSpace ~
12072 \InsetSpace ~
12073 \InsetSpace ~
12074 \InsetSpace ~
12075 \InsetSpace ~
12076 \InsetSpace ~
12077 movx @r0,a
12078 \end_layout
12079
12080 \begin_layout Standard
12081 If the -
12082 \begin_inset ERT
12083 status collapsed
12084
12085 \begin_layout Standard
12086
12087
12088 \backslash
12089 /
12090 \end_layout
12091
12092 \end_inset
12093
12094 -xstack
12095 \begin_inset LatexCommand \index{-\/-xstack}
12096
12097 \end_inset
12098
12099  option is used the pdata memory area is followed by the xstack memory area
12100  and the sum of their sizes is limited to 256 bytes.
12101 \end_layout
12102
12103 \begin_layout Subsubsection
12104 code
12105 \begin_inset LatexCommand \index{code}
12106
12107 \end_inset
12108
12109
12110 \begin_inset LatexCommand \index{\_\_code}
12111
12112 \end_inset
12113
12114
12115 \end_layout
12116
12117 \begin_layout Standard
12118 'Variables' declared with this storage class will be placed in the code
12119  memory:
12120 \end_layout
12121
12122 \begin_layout Verse
12123
12124 \family typewriter
12125 __code unsigned char test_code;
12126 \end_layout
12127
12128 \begin_layout Standard
12129 Read access to this variable generates the assembly code:
12130 \end_layout
12131
12132 \begin_layout Verse
12133
12134 \family typewriter
12135 90s00r6F\InsetSpace ~
12136 \InsetSpace ~
12137 \InsetSpace ~
12138 mov dptr,#_test_code
12139 \newline
12140 E4\InsetSpace ~
12141 \InsetSpace ~
12142 \InsetSpace ~
12143 \InsetSpace ~
12144 \InsetSpace ~
12145 \InsetSpace ~
12146 \InsetSpace ~
12147 \InsetSpace ~
12148 \InsetSpace ~
12149 clr a
12150 \newline
12151 93\InsetSpace ~
12152 \InsetSpace ~
12153 \InsetSpace ~
12154 \InsetSpace ~
12155 \InsetSpace ~
12156 \InsetSpace ~
12157 \InsetSpace ~
12158 \InsetSpace ~
12159 \InsetSpace ~
12160 movc a,@a+dptr 
12161 \end_layout
12162
12163 \begin_layout Standard
12164
12165 \family typewriter
12166 char
12167 \family default
12168  indexed arrays of characters in code memory can be accessed efficiently:
12169 \end_layout
12170
12171 \begin_layout Verse
12172
12173 \family typewriter
12174 __code char test_array[] = {'c','h','e','a','p'}; 
12175 \end_layout
12176
12177 \begin_layout Standard
12178 Read access to this array using an 8-bit unsigned index generates the assembly
12179  code:
12180 \end_layout
12181
12182 \begin_layout Verse
12183
12184 \family typewriter
12185 E5*00\InsetSpace ~
12186 \InsetSpace ~
12187 \InsetSpace ~
12188 \InsetSpace ~
12189 \InsetSpace ~
12190 \InsetSpace ~
12191 mov a,_index 
12192 \end_layout
12193
12194 \begin_layout Verse
12195
12196 \family typewriter
12197 90s00r41\InsetSpace ~
12198 \InsetSpace ~
12199 \InsetSpace ~
12200 mov dptr,#_test_array
12201 \end_layout
12202
12203 \begin_layout Verse
12204
12205 \family typewriter
12206 93\InsetSpace ~
12207 \InsetSpace ~
12208 \InsetSpace ~
12209 \InsetSpace ~
12210 \InsetSpace ~
12211 \InsetSpace ~
12212 \InsetSpace ~
12213 \InsetSpace ~
12214 \InsetSpace ~
12215 movc a,@a+dptr 
12216 \end_layout
12217
12218 \begin_layout Subsubsection
12219 bit
12220 \begin_inset LatexCommand \index{bit}
12221
12222 \end_inset
12223
12224
12225 \begin_inset LatexCommand \index{\_\_bit}
12226
12227 \end_inset
12228
12229
12230 \end_layout
12231
12232 \begin_layout Standard
12233 This is a data-type and a storage class specifier.
12234  When a variable is declared as a bit, it is allocated into the bit addressable
12235  memory of 8051, e.g.:
12236 \end_layout
12237
12238 \begin_layout Verse
12239
12240 \family typewriter
12241 __bit test_bit;
12242 \end_layout
12243
12244 \begin_layout Standard
12245 Writing 1 to this variable generates the assembly code:
12246 \end_layout
12247
12248 \begin_layout Verse
12249
12250 \family typewriter
12251 D2*00\InsetSpace ~
12252 \InsetSpace ~
12253 \InsetSpace ~
12254 \InsetSpace ~
12255 \InsetSpace ~
12256 \InsetSpace ~
12257 \InsetSpace ~
12258 setb\InsetSpace ~
12259 _test_bit
12260 \end_layout
12261
12262 \begin_layout Standard
12263 The bit addressable memory consists of 128 bits which are located from 0x20
12264  to 0x2f in data memory.
12265  
12266 \newline
12267 Apart from this 8051 specific storage class most architectures support
12268  ANSI-C bitfields
12269 \begin_inset LatexCommand \index{bitfields}
12270
12271 \end_inset
12272
12273
12274 \begin_inset Foot
12275 status open
12276
12277 \begin_layout Standard
12278 Not really meant as examples, but nevertheless showing what bitfields are
12279  about: device/include/mc68hc908qy.h and support/regression/tests/bitfields.c
12280 \end_layout
12281
12282 \end_inset
12283
12284 .
12285  In accordance with ISO/IEC 9899 bits and bitfields without an explicit
12286  signed modifier are implemented as unsigned.
12287 \end_layout
12288
12289 \begin_layout Subsubsection
12290 sfr
12291 \begin_inset LatexCommand \index{sfr}
12292
12293 \end_inset
12294
12295
12296 \begin_inset LatexCommand \index{\_\_sfr}
12297
12298 \end_inset
12299
12300  / sfr16
12301 \begin_inset LatexCommand \index{sfr16}
12302
12303 \end_inset
12304
12305
12306 \begin_inset LatexCommand \index{\_\_sfr16}
12307
12308 \end_inset
12309
12310  / sfr32
12311 \begin_inset LatexCommand \index{sfr32}
12312
12313 \end_inset
12314
12315
12316 \begin_inset LatexCommand \index{\_\_sfr32}
12317
12318 \end_inset
12319
12320  / sbit
12321 \begin_inset LatexCommand \index{\_\_sbit}
12322
12323 \end_inset
12324
12325
12326 \begin_inset LatexCommand \index{sbit}
12327
12328 \end_inset
12329
12330
12331 \end_layout
12332
12333 \begin_layout Standard
12334 Like the bit keyword, 
12335 \emph on
12336 sfr / sfr16 / sfr32 / sbit 
12337 \emph default
12338 signify both a data-type and storage class, they are used to describe the
12339  
12340 \emph on
12341 s
12342 \emph default
12343 pecial 
12344 \emph on
12345 f
12346 \emph default
12347 unction 
12348 \emph on
12349 r
12350 \emph default
12351 egisters and 
12352 \emph on
12353 s
12354 \emph default
12355 pecial 
12356 \emph on
12357 bit
12358 \emph default
12359  variables of a 8051, eg:
12360 \end_layout
12361
12362 \begin_layout Verse
12363
12364 \family typewriter
12365 __sfr __at
12366 \begin_inset LatexCommand \index{at}
12367
12368 \end_inset
12369
12370
12371 \begin_inset LatexCommand \index{\_\_at}
12372
12373 \end_inset
12374
12375  (0x80) P0;\InsetSpace ~
12376  /* special function register P0 at location 0x80 */
12377 \newline
12378
12379 \newline
12380 /* 16 bit
12381  special function register combination for timer 0
12382 \newline
12383 \InsetSpace ~
12384 \InsetSpace ~
12385  with the high byte at
12386  location 0x8C and the low byte at location 0x8A */
12387 \newline
12388 __sfr16 __at (0x8C8A)
12389  TMR0;
12390 \newline
12391
12392 \newline
12393 __sbit __at
12394 \begin_inset LatexCommand \index{at}
12395
12396 \end_inset
12397
12398
12399 \begin_inset LatexCommand \index{\_\_at}
12400
12401 \end_inset
12402
12403  (0xd7) CY;\InsetSpace ~
12404  /* CY (Carry Flag
12405 \begin_inset LatexCommand \index{Flags}
12406
12407 \end_inset
12408
12409
12410 \begin_inset LatexCommand \index{Carry flag}
12411
12412 \end_inset
12413
12414 ) */
12415 \end_layout
12416
12417 \begin_layout Standard
12418 Special function registers which are located on an address dividable by
12419  8 are bit-addressable, an
12420 \emph on
12421  sbit
12422 \emph default
12423  addresses a specific bit within these sfr.
12424 \newline
12425 16 Bit and 32 bit special function
12426  register combinations which require a certain access order are better not
12427  declared using 
12428 \emph on
12429 sfr16
12430 \emph default
12431  or 
12432 \emph on
12433 sfr32.
12434
12435 \emph default
12436  Allthough SDCC usually accesses them Least Significant Byte (LSB) first,
12437  this is not guaranteed.
12438 \newline
12439
12440 \end_layout
12441
12442 \begin_layout Standard
12443 Please note, if you use a header file which was written for another compiler
12444  then the sfr / sfr16 / sfr32 / sbit Storage Class extensions will most
12445  likely be 
12446 \emph on
12447 not 
12448 \emph default
12449 compatible.
12450  Specifically the syntax 
12451 \family typewriter
12452 \InsetSpace ~
12453 sfr P0 = 0x80;\InsetSpace ~
12454
12455 \family default
12456  is compiled 
12457 \emph on
12458 without warning
12459 \emph default
12460  by SDCC to an assignment of 0x80 to a variable called P0 
12461 \family typewriter
12462
12463 \begin_inset Marginal
12464 status collapsed
12465
12466 \begin_layout Standard
12467
12468 \series bold
12469 \InsetSpace ~
12470 !
12471 \end_layout
12472
12473 \end_inset
12474
12475 .
12476  
12477 \family default
12478 Nevertheless it is possible to write header files
12479 \begin_inset LatexCommand \index{Header files}
12480
12481 \end_inset
12482
12483
12484 \begin_inset LatexCommand \index{Include files}
12485
12486 \end_inset
12487
12488  which can be shared among different compilers (see section 
12489 \begin_inset LatexCommand \ref{sec:Porting-code-to-other-compilers}
12490
12491 \end_inset
12492
12493 ).
12494  
12495 \end_layout
12496
12497 \begin_layout Subsubsection
12498 Pointers
12499 \begin_inset LatexCommand \index{Pointer}
12500
12501 \end_inset
12502
12503  to MCS51/DS390 specific memory spaces
12504 \end_layout
12505
12506 \begin_layout Standard
12507 SDCC allows (via language extensions) pointers to explicitly point to any
12508  of the memory spaces
12509 \begin_inset LatexCommand \index{Memory model}
12510
12511 \end_inset
12512
12513  of the 8051.
12514  In addition to the explicit pointers, the compiler uses (by default) generic
12515  pointers which can be used to point to any of the memory spaces.
12516 \newline
12517
12518 \newline
12519 Pointer
12520  declaration examples:
12521 \end_layout
12522
12523 \begin_layout Verse
12524
12525 \family typewriter
12526 /* pointer physically in internal ram pointing to object in external ram
12527  */ 
12528 \newline
12529 __xdata unsigned char * __data p;
12530 \newline
12531
12532 \newline
12533 /* pointer physically in external ram
12534  pointing to object in internal ram */ 
12535 \newline
12536 __data unsigned char * __xdata p;
12537 \newline
12538
12539 \newline
12540 /*
12541  pointer physically in code rom pointing to data in xdata space */ 
12542 \newline
12543 __xdata
12544  unsigned char * __code p;
12545 \newline
12546
12547 \newline
12548 /* pointer physically in code space pointing to
12549  data in code space */ 
12550 \newline
12551 __code unsigned char * __code p;
12552 \newline
12553
12554 \newline
12555 /* generic pointer
12556  physically located in xdata space */
12557 \newline
12558 unsigned char * __xdata p;
12559 \newline
12560
12561 \newline
12562 /* generic
12563  pointer physically located in default memory space */
12564 \newline
12565 unsigned char * p;
12566 \newline
12567
12568 \newline
12569 /*
12570  the following is a function pointer
12571 \begin_inset LatexCommand \index{function pointer}
12572
12573 \end_inset
12574
12575  physically located in data space */
12576 \newline
12577 char (* __data fp)(void);
12578 \end_layout
12579
12580 \begin_layout Standard
12581 Well you get the idea.
12582  
12583 \newline
12584
12585 \newline
12586 All unqualified pointers are treated as 3-byte (4-byte for the ds390) 
12587 \emph on
12588 generic
12589 \emph default
12590  pointers.
12591  
12592 \size small
12593
12594 \newline
12595
12596 \newline
12597
12598 \size default
12599 The highest order byte of the 
12600 \emph on
12601 generic
12602 \emph default
12603  pointers contains the data space information.
12604  Assembler support routines are called whenever data is stored or retrieved
12605  using 
12606 \emph on
12607 generic
12608 \emph default
12609  pointers.
12610  These are useful for developing reusable library
12611 \begin_inset LatexCommand \index{Libraries}
12612
12613 \end_inset
12614
12615  routines.
12616  Explicitly specifying the pointer
12617 \begin_inset LatexCommand \index{pointer}
12618
12619 \end_inset
12620
12621  type will generate the most efficient code.
12622 \end_layout
12623
12624 \begin_layout Subsubsection
12625 Notes on MCS51 memory
12626 \begin_inset LatexCommand \index{MCS51 memory}
12627
12628 \end_inset
12629
12630  layout
12631 \end_layout
12632
12633 \begin_layout Standard
12634 The 8051 family of microcontrollers have a minimum of 128 bytes of internal
12635  RAM memory which is structured as follows:
12636 \newline
12637
12638 \newline
12639 - Bytes 00-1F - 32 bytes to hold
12640  up to 4 banks of the registers R0 to R7, 
12641 \newline
12642 - Bytes 20-2F - 16 bytes to hold
12643  128 bit
12644 \begin_inset LatexCommand \index{bit}
12645
12646 \end_inset
12647
12648  variables and, 
12649 \newline
12650 - Bytes 30-7F - 80 bytes for general purpose use.
12651 \newline
12652
12653 \end_layout
12654
12655 \begin_layout Standard
12656 Additionally some members of the MCS51 family may have up to 128 bytes of
12657  additional, indirectly addressable, internal RAM memory (
12658 \emph on
12659 idata
12660 \emph default
12661
12662 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
12663
12664 \end_inset
12665
12666
12667 \begin_inset LatexCommand \index{\_\_idata (mcs51, ds390 storage class)}
12668
12669 \end_inset
12670
12671 ).
12672  Furthermore, some chips may have some built in external memory (
12673 \emph on
12674 xdata
12675 \emph default
12676
12677 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
12678
12679 \end_inset
12680
12681
12682 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
12683
12684 \end_inset
12685
12686 ) which should not be confused with the internal, directly addressable RAM
12687  memory (
12688 \emph on
12689 data
12690 \emph default
12691
12692 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
12693
12694 \end_inset
12695
12696
12697 \begin_inset LatexCommand \index{\_\_data (mcs51, ds390 storage class)}
12698
12699 \end_inset
12700
12701 ).
12702  Sometimes this built in 
12703 \emph on
12704 xdata
12705 \emph default
12706  memory has to be activated before using it (you can probably find this
12707  information on the datasheet of the microcontroller your are using, see
12708  also section 
12709 \begin_inset LatexCommand \ref{sub:Startup-Code}
12710
12711 \end_inset
12712
12713 \InsetSpace ~
12714 Startup-Code).
12715 \end_layout
12716
12717 \begin_layout Standard
12718 Normally SDCC will only use the first bank
12719 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
12720
12721 \end_inset
12722
12723  of registers (register bank 0), but it is possible to specify that other
12724  banks of registers (keyword 
12725 \emph on
12726 using
12727 \emph default
12728  
12729 \emph on
12730
12731 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
12732
12733 \end_inset
12734
12735
12736 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
12737
12738 \end_inset
12739
12740
12741 \emph default
12742 ) should be used for example in interrupt
12743 \begin_inset LatexCommand \index{interrupt}
12744
12745 \end_inset
12746
12747
12748 \begin_inset LatexCommand \index{\_\_interrupt}
12749
12750 \end_inset
12751
12752  routines.
12753  By default, the compiler will place the stack after the last byte of allocated
12754  memory for variables.
12755  For example, if the first 2 banks of registers are used, and only four
12756  bytes are used for 
12757 \emph on
12758 data
12759 \emph default
12760  variables, it will position the base of the internal stack at address 20
12761  (0x14).
12762  This implies that as the stack
12763 \begin_inset LatexCommand \index{stack}
12764
12765 \end_inset
12766
12767  grows, it will use up the remaining register banks, and the 16 bytes used
12768  by the 128 bit variables, and 80 bytes for general purpose use.
12769  If any bit variables are used, the data variables will be placed in unused
12770  register banks and after the byte holding the last bit variable.
12771  For example, if register banks 0 and 1 are used, and there are 9 bit variables
12772  (two bytes used), 
12773 \emph on
12774 data
12775 \emph default
12776  variables will be placed starting from address 0x10 to 0x20 and continue
12777  at address 0x22.
12778  You can also use -
12779 \begin_inset ERT
12780 status collapsed
12781
12782 \begin_layout Standard
12783
12784
12785 \backslash
12786 /
12787 \end_layout
12788
12789 \end_inset
12790
12791 -data-loc
12792 \begin_inset LatexCommand \index{-\/-data-loc <Value>}
12793
12794 \end_inset
12795
12796  to specify the start address of the 
12797 \emph on
12798 data
12799 \emph default
12800  and -
12801 \begin_inset ERT
12802 status collapsed
12803
12804 \begin_layout Standard
12805
12806
12807 \backslash
12808 /
12809 \end_layout
12810
12811 \end_inset
12812
12813 -iram-size
12814 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
12815
12816 \end_inset
12817
12818  to specify the size of the total internal RAM (
12819 \emph on
12820 data
12821 \emph default
12822 +
12823 \emph on
12824 idata
12825 \emph default
12826 ).
12827  
12828 \newline
12829
12830 \end_layout
12831
12832 \begin_layout Standard
12833 By default the 8051 linker will place the stack after the last byte of (i)data
12834  variables.
12835  Option -
12836 \begin_inset ERT
12837 status collapsed
12838
12839 \begin_layout Standard
12840
12841
12842 \backslash
12843 /
12844 \end_layout
12845
12846 \end_inset
12847
12848 -stack-loc
12849 \begin_inset LatexCommand \index{-\/-stack-loc <Value>}
12850
12851 \end_inset
12852
12853  allows you to specify the start of the stack, i.e.
12854  you could start it after any data in the general purpose area.
12855  If your microcontroller has additional indirectly addressable internal
12856  RAM (
12857 \emph on
12858 idata
12859 \emph default
12860 ) you can place the stack on it.
12861  You may also need to use -
12862 \begin_inset ERT
12863 status collapsed
12864
12865 \begin_layout Standard
12866
12867
12868 \backslash
12869 /
12870 \end_layout
12871
12872 \end_inset
12873
12874 -xdata-loc
12875 \begin_inset LatexCommand \index{-\/-xdata-loc<Value>}
12876
12877 \end_inset
12878
12879  to set the start address of the external RAM (
12880 \emph on
12881 xdata
12882 \emph default
12883 ) and -
12884 \begin_inset ERT
12885 status collapsed
12886
12887 \begin_layout Standard
12888
12889
12890 \backslash
12891 /
12892 \end_layout
12893
12894 \end_inset
12895
12896 -xram-size
12897 \begin_inset LatexCommand \index{-\/-xram-size <Value>}
12898
12899 \end_inset
12900
12901  to specify its size.
12902  Same goes for the code memory, using -
12903 \begin_inset ERT
12904 status collapsed
12905
12906 \begin_layout Standard
12907
12908
12909 \backslash
12910 /
12911 \end_layout
12912
12913 \end_inset
12914
12915 -code-loc
12916 \begin_inset LatexCommand \index{-\/-code-loc <Value>}
12917
12918 \end_inset
12919
12920  and -
12921 \begin_inset ERT
12922 status collapsed
12923
12924 \begin_layout Standard
12925
12926
12927 \backslash
12928 /
12929 \end_layout
12930
12931 \end_inset
12932
12933 -code-size
12934 \begin_inset LatexCommand \index{-\/-code-size <Value>}
12935
12936 \end_inset
12937
12938 .
12939  If in doubt, don't specify any options and see if the resulting memory
12940  layout is appropriate, then you can adjust it.
12941 \end_layout
12942
12943 \begin_layout Standard
12944 The linker generates two files with memory allocation information.
12945  The first, with extension .map
12946 \begin_inset LatexCommand \index{<file>.map}
12947
12948 \end_inset
12949
12950  shows all the variables and segments.
12951  The second with extension .mem
12952 \begin_inset LatexCommand \index{<file>.mem}
12953
12954 \end_inset
12955
12956  shows the final memory layout.
12957  The linker will complain either if memory segments overlap, there is not
12958  enough memory, or there is not enough space for stack.
12959  If you get any linking warnings and/or errors related to stack or segments
12960  allocation, take a look at either the .map or .mem files to find out what
12961  the problem is.
12962  The .mem file may even suggest a solution to the problem.
12963 \begin_inset VSpace bigskip
12964 \end_inset
12965
12966
12967 \end_layout
12968
12969 \begin_layout Subsection
12970 Z80/Z180 Storage Class
12971 \begin_inset LatexCommand \index{Z80!Storage class}
12972
12973 \end_inset
12974
12975  Language Extensions
12976 \end_layout
12977
12978 \begin_layout Subsubsection
12979 sfr
12980 \begin_inset LatexCommand \index{sfr}
12981
12982 \end_inset
12983
12984
12985 \begin_inset LatexCommand \index{\_\_sfr}
12986
12987 \end_inset
12988
12989  (in/out to 8-bit addresses)
12990 \end_layout
12991
12992 \begin_layout Standard
12993 The Z80
12994 \begin_inset LatexCommand \index{Z80}
12995
12996 \end_inset
12997
12998  family has separate address spaces for memory and 
12999 \emph on
13000 i
13001 \emph default
13002 nput/
13003 \emph on
13004 o
13005 \emph default
13006 utput memory.
13007  I/O memory
13008 \begin_inset LatexCommand \index{I/O memory (Z80, Z180)}
13009
13010 \end_inset
13011
13012
13013 \begin_inset LatexCommand \index{Z80!I/O memory}
13014
13015 \end_inset
13016
13017
13018 \begin_inset LatexCommand \index{Z180!I/O memory}
13019
13020 \end_inset
13021
13022  is accessed with special instructions, e.g.:
13023 \end_layout
13024
13025 \begin_layout Verse
13026
13027 \family typewriter
13028 sfr at 0x78 IoPort;\InsetSpace ~
13029 \InsetSpace ~
13030 /* define a var in I/O space at 78h called IoPort */
13031  
13032 \end_layout
13033
13034 \begin_layout Standard
13035 Writing 0x01 to this variable generates the assembly code:
13036 \end_layout
13037
13038 \begin_layout Verse
13039
13040 \family typewriter
13041 3E 01\InsetSpace ~
13042 \InsetSpace ~
13043 \InsetSpace ~
13044 \InsetSpace ~
13045 \InsetSpace ~
13046 \InsetSpace ~
13047 ld a,#0x01
13048 \newline
13049 D3 78\InsetSpace ~
13050 \InsetSpace ~
13051 \InsetSpace ~
13052 \InsetSpace ~
13053 \InsetSpace ~
13054 \InsetSpace ~
13055 out (_IoPort),a 
13056 \end_layout
13057
13058 \begin_layout Subsubsection
13059 banked sfr
13060 \begin_inset LatexCommand \index{sfr}
13061
13062 \end_inset
13063
13064
13065 \begin_inset LatexCommand \index{\_\_sfr}
13066
13067 \end_inset
13068
13069  (in/out to 16-bit addresses)
13070 \end_layout
13071
13072 \begin_layout Standard
13073 The keyword 
13074 \emph on
13075 banked
13076 \emph default
13077  is used to support 16 bit addresses in I/O memory e.g.:
13078 \end_layout
13079
13080 \begin_layout Verse
13081
13082 \family typewriter
13083 sfr banked at
13084 \begin_inset LatexCommand \index{at}
13085
13086 \end_inset
13087
13088
13089 \begin_inset LatexCommand \index{\_\_at}
13090
13091 \end_inset
13092
13093  0x123 IoPort; 
13094 \end_layout
13095
13096 \begin_layout Standard
13097 Writing 0x01 to this variable generates the assembly code:
13098 \end_layout
13099
13100 \begin_layout Verse
13101
13102 \family typewriter
13103 01 23 01\InsetSpace ~
13104 \InsetSpace ~
13105 \InsetSpace ~
13106 ld bc,#_IoPort
13107 \newline
13108 3E 01\InsetSpace ~
13109 \InsetSpace ~
13110 \InsetSpace ~
13111 \InsetSpace ~
13112 \InsetSpace ~
13113 \InsetSpace ~
13114 ld a,#0x01 
13115 \newline
13116 ED 79\InsetSpace ~
13117 \InsetSpace ~
13118 \InsetSpace ~
13119 \InsetSpace ~
13120 \InsetSpace ~
13121 \InsetSpace ~
13122 out (c),a 
13123 \end_layout
13124
13125 \begin_layout Subsubsection
13126 sfr
13127 \begin_inset LatexCommand \index{sfr}
13128
13129 \end_inset
13130
13131
13132 \begin_inset LatexCommand \index{\_\_sfr}
13133
13134 \end_inset
13135
13136  (in0/out0 to 8 bit addresses on Z180
13137 \begin_inset LatexCommand \index{Z180}
13138
13139 \end_inset
13140
13141 /HD64180
13142 \begin_inset LatexCommand \index{HD64180 (see Z180)}
13143
13144 \end_inset
13145
13146 )
13147 \end_layout
13148
13149 \begin_layout Standard
13150 The compiler option -
13151 \begin_inset ERT
13152 status collapsed
13153
13154 \begin_layout Standard
13155
13156
13157 \backslash
13158 /
13159 \end_layout
13160
13161 \end_inset
13162
13163 -portmode
13164 \begin_inset LatexCommand \index{Z180!Options!-\/-portmode}
13165
13166 \end_inset
13167
13168 =180 (80) and a compiler #pragma\InsetSpace ~
13169 portmode
13170 \begin_inset LatexCommand \index{Z180!Pragmas!\#pragma portmode}
13171
13172 \end_inset
13173
13174  z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructio
13175 ns 
13176 \family typewriter
13177 in0/out0
13178 \family default
13179  instead of 
13180 \family typewriter
13181 in/out
13182 \family default
13183 .
13184  If you include the file z180.h this will be set automatically.
13185 \begin_inset VSpace bigskip
13186 \end_inset
13187
13188
13189 \end_layout
13190
13191 \begin_layout Subsection
13192 HC08 Storage Class
13193 \begin_inset LatexCommand \index{HC08!Storage class}
13194
13195 \end_inset
13196
13197  Language Extensions
13198 \end_layout
13199
13200 \begin_layout Subsubsection
13201 data
13202 \begin_inset LatexCommand \index{data (hc08 storage class)}
13203
13204 \end_inset
13205
13206
13207 \begin_inset LatexCommand \index{\_\_data (hc08 storage class)}
13208
13209 \end_inset
13210
13211  
13212 \end_layout
13213
13214 \begin_layout Standard
13215 The data storage class declares a variable that resides in the first 256
13216  bytes of memory (the direct page).
13217  The HC08
13218 \begin_inset LatexCommand \index{HC08}
13219
13220 \end_inset
13221
13222  is most efficient at accessing variables (especially pointers) stored here.
13223 \end_layout
13224
13225 \begin_layout Subsubsection
13226 xdata
13227 \begin_inset LatexCommand \index{xdata (hc08 storage class)}
13228
13229 \end_inset
13230
13231
13232 \begin_inset LatexCommand \index{\_\_xdata (hc08 storage class)}
13233
13234 \end_inset
13235
13236  
13237 \end_layout
13238
13239 \begin_layout Standard
13240 The xdata storage class declares a variable that can reside anywhere in
13241  memory.
13242  This is the default if no storage class is specified.
13243  
13244 \begin_inset VSpace bigskip
13245 \end_inset
13246
13247
13248 \end_layout
13249
13250 \begin_layout Section
13251 Other SDCC language extensions
13252 \begin_inset LatexCommand \index{Other SDCC language extensions}
13253
13254 \end_inset
13255
13256
13257 \end_layout
13258
13259 \begin_layout Subsection
13260 Binary constants
13261 \end_layout
13262
13263 \begin_layout Standard
13264 SDCC supports the use of binary constants, such as 0b01100010.
13265  This feature is only enabled when the compiler is invoked using --std-sdccxx.
13266 \end_layout
13267
13268 \begin_layout Standard
13269 \begin_inset VSpace bigskip
13270 \end_inset
13271
13272
13273 \end_layout
13274
13275 \begin_layout Section
13276 Absolute Addressing
13277 \begin_inset LatexCommand \index{Absolute addressing}
13278
13279 \end_inset
13280
13281
13282 \end_layout
13283
13284 \begin_layout Standard
13285 Data items can be assigned an absolute address with the 
13286 \emph on
13287 at
13288 \begin_inset LatexCommand \index{at}
13289
13290 \end_inset
13291
13292
13293 \begin_inset LatexCommand \index{\_\_at}
13294
13295 \end_inset
13296
13297  <address>
13298 \emph default
13299  keyword, in addition to a storage class, e.g.:
13300 \end_layout
13301
13302 \begin_layout Verse
13303
13304 \family typewriter
13305 xdata
13306 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
13307
13308 \end_inset
13309
13310
13311 \begin_inset LatexCommand \index{\_\_xdata (mcs51, ds390 storage class)}
13312
13313 \end_inset
13314
13315  at
13316 \begin_inset LatexCommand \index{at}
13317
13318 \end_inset
13319
13320
13321 \begin_inset LatexCommand \index{\_\_at}
13322
13323 \end_inset
13324
13325  0x7ffe unsigned int chksum;
13326 \end_layout
13327
13328 \begin_layout Standard
13329 or, better conforming to ISO/IEC 9899 C:
13330 \end_layout
13331
13332 \begin_layout Verse
13333
13334 \family typewriter
13335 __xdata __at (0x7ffe) unsigned int chksum;
13336 \end_layout
13337
13338 \begin_layout Standard
13339 In the above example the variable chksum will be located at 0x7ffe and 0x7fff
13340  of the external ram.
13341  The compiler does 
13342 \emph on
13343 not
13344 \emph default
13345  reserve any space for variables declared in this way
13346 \begin_inset Marginal
13347 status collapsed
13348
13349 \begin_layout Standard
13350
13351 \series bold
13352 \InsetSpace ~
13353 !
13354 \end_layout
13355
13356 \end_inset
13357
13358  (they are implemented with an equate in the assembler).
13359  Thus it is left to the programmer to make sure there are no overlaps with
13360  other variables that are declared without the absolute address.
13361  The assembler listing file (.lst
13362 \begin_inset LatexCommand \index{<file>.lst}
13363
13364 \end_inset
13365
13366 ) and the linker output files (.rst
13367 \begin_inset LatexCommand \index{<file>.rst}
13368
13369 \end_inset
13370
13371 ) and (.map
13372 \begin_inset LatexCommand \index{<file>.map}
13373
13374 \end_inset
13375
13376 ) are good places to look for such overlaps.
13377 \end_layout
13378
13379 \begin_layout Standard
13380 If however you provide an initializer
13381 \begin_inset LatexCommand \index{Variable initialization}
13382
13383 \end_inset
13384
13385  actual memory allocation will take place and overlaps will be detected
13386  by the linker.
13387  E.g.:
13388 \end_layout
13389
13390 \begin_layout Verse
13391
13392 \family typewriter
13393 __code __at (0x7ff0) char Id[5] = 
13394 \begin_inset Quotes sld
13395 \end_inset
13396
13397 SDCC
13398 \begin_inset Quotes srd
13399 \end_inset
13400
13401 ;
13402 \end_layout
13403
13404 \begin_layout Standard
13405 In the above example the variable Id will be located from 0x7ff0 to 0x7ff4
13406  in code memory.
13407 \end_layout
13408
13409 \begin_layout Standard
13410 In case of memory mapped I/O devices the keyword 
13411 \emph on
13412 volatile
13413 \emph default
13414  has to be used to tell the compiler that accesses might not be removed:
13415 \end_layout
13416
13417 \begin_layout Verse
13418
13419 \family typewriter
13420 volatile
13421 \begin_inset LatexCommand \index{volatile}
13422
13423 \end_inset
13424
13425  __xdata
13426 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
13427
13428 \end_inset
13429
13430  __at
13431 \begin_inset LatexCommand \index{at}
13432
13433 \end_inset
13434
13435  (0x8000) unsigned char PORTA_8255;
13436 \end_layout
13437
13438 \begin_layout Standard
13439 For some architectures (mcs51) array accesses are more efficient if an (xdata/fa
13440 r) array
13441 \family typewriter
13442 \size footnotesize
13443
13444 \begin_inset LatexCommand \index{Aligned array}
13445
13446 \end_inset
13447
13448
13449 \family default
13450 \size default
13451  starts at a block (256 byte) boundary
13452 \begin_inset LatexCommand \index{block boundary}
13453
13454 \end_inset
13455
13456  (section 
13457 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
13458
13459 \end_inset
13460
13461  has an example).
13462 \newline
13463 Absolute addresses can be specified for variables in all
13464  storage classes, e.g.:
13465 \end_layout
13466
13467 \begin_layout Verse
13468
13469 \family typewriter
13470 __bit
13471 \begin_inset LatexCommand \index{bit}
13472
13473 \end_inset
13474
13475  __at
13476 \begin_inset LatexCommand \index{at}
13477
13478 \end_inset
13479
13480  (0x02) bvar;
13481 \end_layout
13482
13483 \begin_layout Standard
13484 The above example will allocate the variable at offset 0x02 in the bit-addressab
13485 le space.
13486  There is no real advantage to assigning absolute addresses to variables
13487  in this manner, unless you want strict control over all the variables allocated.
13488  One possible use would be to write hardware portable code.
13489  For example, if you have a routine that uses one or more of the microcontroller
13490  I/O pins, and such pins are different for two different hardwares, you
13491  can declare the I/O pins in your routine using:
13492 \end_layout
13493
13494 \begin_layout Verse
13495
13496 \family typewriter
13497 extern volatile
13498 \begin_inset LatexCommand \index{volatile}
13499
13500 \end_inset
13501
13502  __bit MOSI;\InsetSpace ~
13503 \InsetSpace ~
13504 \InsetSpace ~
13505 \InsetSpace ~
13506 /* master out, slave in */
13507 \newline
13508 extern volatile __bit MISO;\InsetSpace ~
13509 \InsetSpace ~
13510 \InsetSpace ~
13511 \InsetSpace ~
13512 /* master
13513  in, slave out */
13514 \newline
13515 extern volatile __bit MCLK;\InsetSpace ~
13516 \InsetSpace ~
13517 \InsetSpace ~
13518 \InsetSpace ~
13519 /* master clock */
13520 \newline
13521
13522 \newline
13523 /* Input and
13524  Output of a byte on a 3-wire serial bus.
13525 \newline
13526 \InsetSpace ~
13527 \InsetSpace ~
13528 \InsetSpace ~
13529 If needed adapt polarity of clock,
13530  polarity of data and bit order
13531 \newline
13532 \InsetSpace ~
13533 */
13534 \newline
13535 unsigned char spi_io(unsigned char out_byte)
13536  
13537 \newline
13538
13539 \newline
13540 \InsetSpace ~
13541 \InsetSpace ~
13542 \InsetSpace ~
13543 \InsetSpace ~
13544 unsigned char i=8;
13545 \newline
13546 \InsetSpace ~
13547 \InsetSpace ~
13548 \InsetSpace ~
13549 \InsetSpace ~
13550 do { 
13551 \newline
13552 \InsetSpace ~
13553 \InsetSpace ~
13554 \InsetSpace ~
13555 \InsetSpace ~
13556 \InsetSpace ~
13557 \InsetSpace ~
13558 \InsetSpace ~
13559 \InsetSpace ~
13560 MOSI = out_byte & 0x80; 
13561 \newline
13562 \InsetSpace ~
13563 \InsetSpace ~
13564 \InsetSpace ~
13565 \InsetSpace ~
13566 \InsetSpace ~
13567 \InsetSpace ~
13568 \InsetSpace ~
13569 \InsetSpace ~
13570 out_byte <<= 1;
13571 \newline
13572 \InsetSpace ~
13573 \InsetSpace ~
13574 \InsetSpace ~
13575 \InsetSpace ~
13576 \InsetSpace ~
13577 \InsetSpace ~
13578 \InsetSpace ~
13579 \InsetSpace ~
13580 MCLK =
13581  1; 
13582 \newline
13583 \InsetSpace ~
13584 \InsetSpace ~
13585 \InsetSpace ~
13586 \InsetSpace ~
13587 \InsetSpace ~
13588 \InsetSpace ~
13589 \InsetSpace ~
13590 \InsetSpace ~
13591 /* _asm nop _endasm; */\InsetSpace ~
13592 \InsetSpace ~
13593 \InsetSpace ~
13594 \InsetSpace ~
13595 \InsetSpace ~
13596 \InsetSpace ~
13597 \InsetSpace ~
13598 \InsetSpace ~
13599 /* for slow peripherals */
13600 \newline
13601 \InsetSpace ~
13602 \InsetSpace ~
13603 \InsetSpace ~
13604 \InsetSpace ~
13605 \InsetSpace ~
13606 \InsetSpace ~
13607 \InsetSpace ~
13608 \InsetSpace ~
13609 if(MISO) 
13610 \newline
13611 \InsetSpace ~
13612 \InsetSpace ~
13613 \InsetSpace ~
13614 \InsetSpace ~
13615 \InsetSpace ~
13616 \InsetSpace ~
13617 \InsetSpace ~
13618 \InsetSpace ~
13619 \InsetSpace ~
13620 \InsetSpace ~
13621 \InsetSpace ~
13622 \InsetSpace ~
13623 out_byte +=
13624  1; 
13625 \newline
13626 \InsetSpace ~
13627 \InsetSpace ~
13628 \InsetSpace ~
13629 \InsetSpace ~
13630 \InsetSpace ~
13631 \InsetSpace ~
13632 \InsetSpace ~
13633 \InsetSpace ~
13634 MCLK = 0; 
13635 \newline
13636 \InsetSpace ~
13637 \InsetSpace ~
13638 \InsetSpace ~
13639 \InsetSpace ~
13640 } while(--i);
13641 \newline
13642 \InsetSpace ~
13643 \InsetSpace ~
13644 \InsetSpace ~
13645 \InsetSpace ~
13646 return out_byte; 
13647 \newline
13648 }
13649 \end_layout
13650
13651 \begin_layout Standard
13652 Then, someplace in the code for the first hardware you would use
13653 \end_layout
13654
13655 \begin_layout Verse
13656
13657 \family typewriter
13658 __bit __at
13659 \begin_inset LatexCommand \index{at}
13660
13661 \end_inset
13662
13663
13664 \begin_inset LatexCommand \index{\_\_at}
13665
13666 \end_inset
13667
13668  (0x80) MOSI;\InsetSpace ~
13669 \InsetSpace ~
13670 \InsetSpace ~
13671 \InsetSpace ~
13672 /* I/O port 0, bit 0 */
13673 \newline
13674 __bit __at (0x81) MISO;\InsetSpace ~
13675 \InsetSpace ~
13676 \InsetSpace ~
13677 \InsetSpace ~
13678 /* I/O port 0,
13679  bit 1 */
13680 \newline
13681 __bit __at (0x82) MCLK;\InsetSpace ~
13682 \InsetSpace ~
13683 \InsetSpace ~
13684 \InsetSpace ~
13685 /* I/O port 0, bit 2 */
13686 \end_layout
13687
13688 \begin_layout Standard
13689 Similarly, for the second hardware you would use
13690 \end_layout
13691
13692 \begin_layout Verse
13693
13694 \family typewriter
13695 __bit __at (0x83) MOSI;\InsetSpace ~
13696 \InsetSpace ~
13697 \InsetSpace ~
13698 \InsetSpace ~
13699 /* I/O port 0, bit 3 */
13700 \newline
13701 __bit __at (0x91) MISO;\InsetSpace ~
13702 \InsetSpace ~
13703 \InsetSpace ~
13704 \InsetSpace ~
13705 /*
13706  I/O port 1, bit 1 */
13707 \newline
13708 __bit
13709 \begin_inset LatexCommand \index{bit}
13710
13711 \end_inset
13712
13713  __at (0x92) MCLK;\InsetSpace ~
13714 \InsetSpace ~
13715 \InsetSpace ~
13716 \InsetSpace ~
13717 /* I/O port 1, bit 2 */
13718 \end_layout
13719
13720 \begin_layout Standard
13721 and you can use the same hardware dependent routine without changes, as
13722  for example in a library.
13723  This is somehow similar to sbit, but only one absolute address has to be
13724  specified in the whole project.
13725 \begin_inset VSpace bigskip
13726 \end_inset
13727
13728
13729 \end_layout
13730
13731 \begin_layout Section
13732 Parameters
13733 \begin_inset LatexCommand \index{Parameters}
13734
13735 \end_inset
13736
13737
13738 \begin_inset LatexCommand \index{function parameter}
13739
13740 \end_inset
13741
13742  & Local Variables
13743 \begin_inset LatexCommand \index{local variables}
13744
13745 \end_inset
13746
13747
13748 \begin_inset LatexCommand \label{sec:Parameters-and-Local-Variables}
13749
13750 \end_inset
13751
13752
13753 \end_layout
13754
13755 \begin_layout Standard
13756 Automatic (local) variables and parameters to functions can either be placed
13757  on the stack or in data-space.
13758  The default action of the compiler is to place these variables in the internal
13759  RAM (for small model) or external RAM (for medium or large model).
13760  This in fact makes them similar to 
13761 \emph on
13762 static
13763 \begin_inset LatexCommand \index{static}
13764
13765 \end_inset
13766
13767
13768 \emph default
13769  so by default functions are non-reentrant
13770 \begin_inset LatexCommand \index{reentrant}
13771
13772 \end_inset
13773
13774 .
13775  
13776 \newline
13777
13778 \newline
13779 They can be placed on the stack
13780 \begin_inset LatexCommand \index{stack}
13781
13782 \end_inset
13783
13784  by using the
13785 \emph on
13786  -
13787 \begin_inset ERT
13788 status collapsed
13789
13790 \begin_layout Standard
13791
13792
13793 \backslash
13794 /
13795 \end_layout
13796
13797 \end_inset
13798
13799 -stack-auto
13800 \begin_inset LatexCommand \index{-\/-stack-auto}
13801
13802 \end_inset
13803
13804
13805 \emph default
13806  option, by using 
13807 \emph on
13808 #pragma\InsetSpace ~
13809 stackauto
13810 \emph default
13811
13812 \begin_inset LatexCommand \index{\#pragma stackauto}
13813
13814 \end_inset
13815
13816  or by using the 
13817 \emph on
13818 reentrant
13819 \begin_inset LatexCommand \index{reentrant}
13820
13821 \end_inset
13822
13823
13824 \emph default
13825  keyword in the function declaration, e.g.:
13826 \end_layout
13827
13828 \begin_layout Verse
13829
13830 \family typewriter
13831 unsigned char foo(char i) __reentrant 
13832 \newline
13833
13834 \newline
13835 \InsetSpace ~
13836 \InsetSpace ~
13837 \InsetSpace ~
13838 \InsetSpace ~
13839 ...
13840  
13841 \newline
13842 }
13843 \end_layout
13844
13845 \begin_layout Standard
13846 Since stack space on 8051 is limited, the 
13847 \emph on
13848 reentrant 
13849 \emph default
13850 keyword or the
13851 \emph on
13852  -
13853 \begin_inset ERT
13854 status collapsed
13855
13856 \begin_layout Standard
13857
13858
13859 \backslash
13860 /
13861 \end_layout
13862
13863 \end_inset
13864
13865 -stack-auto
13866 \emph default
13867  option should be used sparingly.
13868  Note that the reentrant keyword just means that the parameters & local
13869  variables will be allocated to the stack, it 
13870 \emph on
13871 does not
13872 \emph default
13873  mean that the function is register bank
13874 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
13875
13876 \end_inset
13877
13878  independent.
13879 \newline
13880
13881 \newline
13882 Local variables
13883 \begin_inset LatexCommand \index{local variables}
13884
13885 \end_inset
13886
13887  can be assigned storage classes and absolute
13888 \begin_inset LatexCommand \index{Absolute addressing}
13889
13890 \end_inset
13891
13892  addresses, e.g.: 
13893 \end_layout
13894
13895 \begin_layout Verse
13896
13897 \family typewriter
13898 unsigned char foo() 
13899 \newline
13900 {
13901 \newline
13902 \InsetSpace ~
13903 \InsetSpace ~
13904 \InsetSpace ~
13905 \InsetSpace ~
13906 __xdata unsigned char i;
13907 \newline
13908 \InsetSpace ~
13909 \InsetSpace ~
13910 \InsetSpace ~
13911 \InsetSpace ~
13912 __bit bvar;
13913 \newline
13914 \InsetSpace ~
13915 \InsetSpace ~
13916 \InsetSpace ~
13917 \InsetSpace ~
13918 __data __at
13919 \begin_inset LatexCommand \index{at}
13920
13921 \end_inset
13922
13923  (0x31) unsigned char j;
13924 \newline
13925 \InsetSpace ~
13926 \InsetSpace ~
13927 \InsetSpace ~
13928 \InsetSpace ~
13929 ...
13930  
13931 \newline
13932 }
13933 \end_layout
13934
13935 \begin_layout Standard
13936 In the above example the variable 
13937 \emph on
13938 i
13939 \emph default
13940  will be allocated in the external ram, 
13941 \emph on
13942 bvar
13943 \emph default
13944  in bit addressable space and
13945 \emph on
13946  j
13947 \emph default
13948  in internal ram.
13949  When compiled with 
13950 \emph on
13951 -
13952 \begin_inset ERT
13953 status collapsed
13954
13955 \begin_layout Standard
13956
13957
13958 \backslash
13959 /
13960 \end_layout
13961
13962 \end_inset
13963
13964 -stack-auto
13965 \emph default
13966  or when a function is declared as 
13967 \emph on
13968 reentrant
13969 \emph default
13970  this should only be done for static variables.
13971 \end_layout
13972
13973 \begin_layout Standard
13974 Parameters
13975 \begin_inset LatexCommand \index{function parameter}
13976
13977 \end_inset
13978
13979  however are not allowed any storage class
13980 \begin_inset LatexCommand \index{Storage class}
13981
13982 \end_inset
13983
13984 , (storage classes for parameters will be ignored), their allocation is
13985  governed by the memory model in use, and the reentrancy options.
13986 \end_layout
13987
13988 \begin_layout Standard
13989 It is however allowed to use bit parameters in reentrant functions and also
13990  non-static local bit variables are supported.
13991  Efficient use is limited to 8 semi-bitregisters in bit space.
13992  They are pushed and popped to stack
13993 \begin_inset LatexCommand \index{stack}
13994
13995 \end_inset
13996
13997  as a single byte just like the normal registers.
13998 \end_layout
13999
14000 \begin_layout Section
14001 Overlaying
14002 \begin_inset LatexCommand \label{sub:Overlaying}
14003
14004 \end_inset
14005
14006
14007 \begin_inset LatexCommand \index{Overlaying}
14008
14009 \end_inset
14010
14011
14012 \end_layout
14013
14014 \begin_layout Standard
14015 For non-reentrant
14016 \begin_inset LatexCommand \index{reentrant}
14017
14018 \end_inset
14019
14020  functions SDCC will try to reduce internal ram space usage by overlaying
14021  parameters and local variables of a function (if possible).
14022  Parameters and local variables
14023 \begin_inset LatexCommand \index{local variables}
14024
14025 \end_inset
14026
14027  of a function will be allocated to an overlayable segment if the function
14028  has 
14029 \emph on
14030 no other function calls and the function is non-reentrant and the memory
14031  model
14032 \begin_inset LatexCommand \index{Memory model}
14033
14034 \end_inset
14035
14036  is small.
14037
14038 \emph default
14039  If an explicit storage class
14040 \begin_inset LatexCommand \index{Storage class}
14041
14042 \end_inset
14043
14044  is specified for a local variable, it will NOT be overlayed.
14045 \end_layout
14046
14047 \begin_layout Standard
14048 Note that the compiler (not the linkage editor) makes the decision for overlayin
14049 g the data items.
14050  Functions that are called from an interrupt service routine
14051 \begin_inset Marginal
14052 status collapsed
14053
14054 \begin_layout Standard
14055
14056 \series bold
14057 !
14058 \end_layout
14059
14060 \end_inset
14061
14062  should be preceded by a #pragma\InsetSpace ~
14063 nooverlay
14064 \begin_inset LatexCommand \index{\#pragma nooverlay}
14065
14066 \end_inset
14067
14068  if they are not reentrant.
14069 \end_layout
14070
14071 \begin_layout Standard
14072 Also note that the compiler does not do any processing of inline assembler
14073  code, so the compiler might incorrectly assign local variables and parameters
14074  of a function into the overlay segment if the inline assembler code calls
14075  other c-functions that might use the overlay.
14076  In that case the #pragma\InsetSpace ~
14077 nooverlay should be used.
14078 \end_layout
14079
14080 \begin_layout Standard
14081 Parameters and local variables of functions that contain 16 or 32 bit multiplica
14082 tion
14083 \begin_inset LatexCommand \index{Multiplication}
14084
14085 \end_inset
14086
14087  or division
14088 \begin_inset LatexCommand \index{Division}
14089
14090 \end_inset
14091
14092  will NOT be overlayed since these are implemented using external functions,
14093  e.g.:
14094 \end_layout
14095
14096 \begin_layout Verse
14097
14098 \family typewriter
14099 #pragma save 
14100 \newline
14101 #pragma nooverlay
14102 \begin_inset LatexCommand \index{\#pragma nooverlay}
14103
14104 \end_inset
14105
14106  
14107 \newline
14108 void set_error(unsigned char errcd) 
14109 \newline
14110 {
14111 \newline
14112 \InsetSpace ~
14113 \InsetSpace ~
14114 \InsetSpace ~
14115 \InsetSpace ~
14116 P3 = errcd;
14117 \newline
14118
14119 \newline
14120 #pragma restore 
14121 \newline
14122
14123 \newline
14124 void
14125  some_isr () __interrupt
14126 \begin_inset LatexCommand \index{interrupt}
14127
14128 \end_inset
14129
14130  (2)
14131 \newline
14132 {
14133 \newline
14134 \InsetSpace ~
14135 \InsetSpace ~
14136 \InsetSpace ~
14137 \InsetSpace ~
14138 ...
14139 \newline
14140 \InsetSpace ~
14141 \InsetSpace ~
14142 \InsetSpace ~
14143 \InsetSpace ~
14144 set_error(10);
14145 \newline
14146 \InsetSpace ~
14147 \InsetSpace ~
14148 \InsetSpace ~
14149 \InsetSpace ~
14150 ...
14151  
14152 \newline
14153 }
14154 \end_layout
14155
14156 \begin_layout Standard
14157 In the above example the parameter 
14158 \emph on
14159 errcd
14160 \emph default
14161  for the function 
14162 \emph on
14163 set_error
14164 \emph default
14165  would be assigned to the overlayable segment if the #pragma\InsetSpace ~
14166 nooverlay was
14167  not present, this could cause unpredictable runtime behavior when called
14168  from an interrupt service routine.
14169  The #pragma\InsetSpace ~
14170 nooverlay ensures that the parameters and local variables for
14171  the function are NOT overlayed.
14172 \begin_inset VSpace bigskip
14173 \end_inset
14174
14175
14176 \end_layout
14177
14178 \begin_layout Section
14179 Interrupt Service Routines
14180 \begin_inset LatexCommand \label{sub:Interrupt-Service-Routines}
14181
14182 \end_inset
14183
14184
14185 \end_layout
14186
14187 \begin_layout Subsection
14188 General Information
14189 \end_layout
14190
14191 \begin_layout Standard
14192 SDCC allows 
14193 \emph on
14194 i
14195 \emph default
14196 nterrupt 
14197 \emph on
14198 s
14199 \emph default
14200 ervice 
14201 \emph on
14202 r
14203 \emph default
14204 outines to be coded in C, with some extended keywords.
14205 \end_layout
14206
14207 \begin_layout Verse
14208
14209 \family typewriter
14210 void timer_isr (void) __interrupt (1) __using (1) 
14211 \newline
14212
14213 \newline
14214 \InsetSpace ~
14215 \InsetSpace ~
14216 \InsetSpace ~
14217 \InsetSpace ~
14218 ...
14219  
14220 \newline
14221 }
14222 \end_layout
14223
14224 \begin_layout Standard
14225 The optional number following the 
14226 \emph on
14227 interrupt
14228 \begin_inset LatexCommand \index{interrupt}
14229
14230 \end_inset
14231
14232
14233 \begin_inset LatexCommand \index{\_\_interrupt}
14234
14235 \end_inset
14236
14237
14238 \emph default
14239  keyword is the interrupt number this routine will service.
14240  When present, the compiler will insert a call to this routine in the interrupt
14241  vector table
14242 \begin_inset LatexCommand \index{interrupt vector table}
14243
14244 \end_inset
14245
14246  for the interrupt number specified.
14247  If you have multiple source files in your project, interrupt service routines
14248  can be present in any of them, but a prototype of the isr MUST be present
14249  or included in the file that contains the function 
14250 \emph on
14251 main
14252 \emph default
14253 .
14254  The optional (8051 specific) keyword 
14255 \emph on
14256 using
14257 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
14258
14259 \end_inset
14260
14261
14262 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
14263
14264 \end_inset
14265
14266
14267 \emph default
14268  can be used to tell the compiler to use the specified register bank when
14269  generating code for this function.
14270  
14271 \newline
14272 Interrupt service routines open the door for some very interesting bugs:
14273 \end_layout
14274
14275 \begin_layout Subsubsection
14276 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-volatile}
14277
14278 \end_inset
14279
14280 Common interrupt pitfall: variable not declared 
14281 \emph on
14282 volatile
14283 \end_layout
14284
14285 \begin_layout Standard
14286 If an interrupt service routine changes variables which are accessed by
14287  other functions these variables have to be declared 
14288 \emph on
14289 volatile
14290 \emph default
14291
14292 \begin_inset LatexCommand \index{volatile}
14293
14294 \end_inset
14295
14296 .
14297  See 
14298 \begin_inset LatexCommand \url{http://en.wikipedia.org/wiki/Volatile_variable}
14299
14300 \end_inset
14301
14302  .
14303 \end_layout
14304
14305 \begin_layout Subsubsection
14306 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-atomic}
14307
14308 \end_inset
14309
14310 Common interrupt pitfall: 
14311 \emph on
14312 non-atomic access
14313 \end_layout
14314
14315 \begin_layout Standard
14316 If the access to these variables is not 
14317 \emph on
14318 atomic
14319 \begin_inset LatexCommand \index{atomic}
14320
14321 \end_inset
14322
14323
14324 \emph default
14325  (i.e.
14326  the processor needs more than one instruction for the access and could
14327  be interrupted while accessing the variable) the interrupt must be disabled
14328  during the access to avoid inconsistent data.
14329  
14330 \newline
14331 Access to 16 or 32 bit variables is obviously not atomic on 8 bit CPUs
14332  and should be protected by disabling interrupts.
14333  You're not automatically on the safe side if you use 8 bit variables though.
14334  We need an example here: f.e.
14335  on the 8051 the harmless looking 
14336 \begin_inset Quotes srd
14337 \end_inset
14338
14339
14340 \family typewriter
14341 flags\InsetSpace ~
14342 |=\InsetSpace ~
14343 0x80;
14344 \family default
14345
14346 \begin_inset Quotes sld
14347 \end_inset
14348
14349  is not atomic if 
14350 \family typewriter
14351 flags
14352 \family default
14353  resides in xdata.
14354  Setting 
14355 \begin_inset Quotes srd
14356 \end_inset
14357
14358
14359 \family typewriter
14360 flags\InsetSpace ~
14361 |=\InsetSpace ~
14362 0x40;
14363 \family default
14364
14365 \begin_inset Quotes sld
14366 \end_inset
14367
14368  from within an interrupt routine might get lost if the interrupt occurs
14369  at the wrong time.
14370  
14371 \begin_inset Quotes sld
14372 \end_inset
14373
14374
14375 \family typewriter
14376 counter\InsetSpace ~
14377 +=\InsetSpace ~
14378 8;
14379 \family default
14380
14381 \begin_inset Quotes srd
14382 \end_inset
14383
14384  is not atomic on the 8051 even if 
14385 \family typewriter
14386 counter
14387 \family default
14388  is located in data memory.
14389 \newline
14390 Bugs like these are hard to reproduce and can
14391  cause a lot of trouble.
14392  
14393 \end_layout
14394
14395 \begin_layout Subsubsection
14396 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-stack-overflow}
14397
14398 \end_inset
14399
14400 Common interrupt pitfall: 
14401 \emph on
14402 stack overflow
14403 \end_layout
14404
14405 \begin_layout Standard
14406 The return address and the registers used in the interrupt service routine
14407  are saved on the stack
14408 \begin_inset LatexCommand \index{stack}
14409
14410 \end_inset
14411
14412  so there must be sufficient stack space.
14413  If there isn't variables or registers (or even the return address itself)
14414  will be corrupted.
14415  This 
14416 \emph on
14417 stack overflow
14418 \emph default
14419
14420 \begin_inset LatexCommand \index{stack overflow}
14421
14422 \end_inset
14423
14424  is most likely to happen if the interrupt occurs during the 
14425 \begin_inset Quotes sld
14426 \end_inset
14427
14428 deepest
14429 \begin_inset Quotes srd
14430 \end_inset
14431
14432  subroutine when the stack is already in use for f.e.
14433  many return addresses.
14434 \end_layout
14435
14436 \begin_layout Subsubsection
14437 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-reentrant}
14438
14439 \end_inset
14440
14441 Common interrupt pitfall: 
14442 \emph on
14443 use of non-reentrant functions
14444 \end_layout
14445
14446 \begin_layout Standard
14447 A special note here, int (16 bit) and long (32 bit) integer division
14448 \begin_inset LatexCommand \index{Division}
14449
14450 \end_inset
14451
14452 , multiplication
14453 \begin_inset LatexCommand \index{Multiplication}
14454
14455 \end_inset
14456
14457  & modulus
14458 \begin_inset LatexCommand \index{Modulus}
14459
14460 \end_inset
14461
14462  and floating-point
14463 \begin_inset LatexCommand \index{Floating point support}
14464
14465 \end_inset
14466
14467  operations are implemented using external support routines.
14468  If an interrupt service routine needs to do any of these operations then
14469  the support routines (as mentioned in a following section) will have to
14470  be recompiled using the
14471 \emph on
14472  -
14473 \begin_inset ERT
14474 status collapsed
14475
14476 \begin_layout Standard
14477
14478
14479 \backslash
14480 /
14481 \end_layout
14482
14483 \end_inset
14484
14485 -stack-auto
14486 \begin_inset LatexCommand \index{-\/-stack-auto}
14487
14488 \end_inset
14489
14490
14491 \emph default
14492  option and the source file will need to be compiled using the 
14493 \emph on
14494 -
14495 \begin_inset ERT
14496 status collapsed
14497
14498 \begin_layout Standard
14499
14500
14501 \backslash
14502 /
14503 \end_layout
14504
14505 \end_inset
14506
14507 -int-long-reent
14508 \emph default
14509
14510 \begin_inset LatexCommand \index{-\/-int-long-reent}
14511
14512 \end_inset
14513
14514  compiler option.
14515  
14516 \newline
14517 Note, the type promotion
14518 \begin_inset LatexCommand \index{type promotion}
14519
14520 \end_inset
14521
14522  required by ANSI C can cause 16 bit routines to be used
14523 \begin_inset Marginal
14524 status collapsed
14525
14526 \begin_layout Standard
14527
14528 \series bold
14529 \InsetSpace ~
14530 !
14531 \end_layout
14532
14533 \end_inset
14534
14535  without the programmer being aware of it.
14536  See f.e.
14537  the cast 
14538 \family typewriter
14539 (unsigned char)(tail-1)
14540 \family default
14541  within the if clause in section 
14542 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
14543
14544 \end_inset
14545
14546 .
14547 \end_layout
14548
14549 \begin_layout Standard
14550 Calling other functions from an interrupt service routine is not recommended,
14551  avoid it if possible.
14552  Note that when some function is called from an interrupt service routine
14553  it should be preceded by a #pragma\InsetSpace ~
14554 nooverlay
14555 \begin_inset LatexCommand \index{\#pragma nooverlay}
14556
14557 \end_inset
14558
14559  if it is not reentrant.
14560  Furthermore nonreentrant functions should not be called from the main program
14561  while the interrupt service routine might be active.
14562  They also must not be called from low priority interrupt service routines
14563  while a high priority interrupt service routine might be active.
14564  You could use semaphores or make the function
14565 \emph on
14566  critical
14567 \emph default
14568  if all parameters are passed in registers.
14569 \newline
14570  Also see section 
14571 \begin_inset LatexCommand \ref{sub:Overlaying}
14572
14573 \end_inset
14574
14575 \InsetSpace ~
14576 about Overlaying and section 
14577 \begin_inset LatexCommand \ref{sub:Functions-using-private-banks}
14578
14579 \end_inset
14580
14581 \InsetSpace ~
14582 about Functions using private register banks.
14583 \begin_inset VSpace bigskip
14584 \end_inset
14585
14586
14587 \end_layout
14588
14589 \begin_layout Subsection
14590 MCS51/DS390 Interrupt Service Routines
14591 \end_layout
14592
14593 \begin_layout Standard
14594 Interrupt
14595 \begin_inset LatexCommand \index{interrupt}
14596
14597 \end_inset
14598
14599  numbers and the corresponding address & descriptions for the Standard 8051/8052
14600  are listed below.
14601  SDCC will automatically adjust the 
14602 \begin_inset LatexCommand \index{interrupt vector table}
14603
14604 \end_inset
14605
14606  to the maximum interrupt number specified.
14607 \newline
14608
14609 \end_layout
14610
14611 \begin_layout Standard
14612 \align center
14613 \begin_inset Tabular
14614 <lyxtabular version="3" rows="9" columns="3">
14615 <features>
14616 <column alignment="center" valignment="top" leftline="true" width="0in">
14617 <column alignment="left" valignment="top" leftline="true" width="0in">
14618 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0in">
14619 <row topline="true" bottomline="true">
14620 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14621 \begin_inset Text
14622
14623 \begin_layout Standard
14624 Interrupt #
14625 \end_layout
14626
14627 \end_inset
14628 </cell>
14629 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14630 \begin_inset Text
14631
14632 \begin_layout Standard
14633 Description
14634 \end_layout
14635
14636 \end_inset
14637 </cell>
14638 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14639 \begin_inset Text
14640
14641 \begin_layout Standard
14642 Vector Address
14643 \end_layout
14644
14645 \end_inset
14646 </cell>
14647 </row>
14648 <row topline="true">
14649 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14650 \begin_inset Text
14651
14652 \begin_layout Standard
14653 0
14654 \end_layout
14655
14656 \end_inset
14657 </cell>
14658 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14659 \begin_inset Text
14660
14661 \begin_layout Standard
14662 External 0
14663 \end_layout
14664
14665 \end_inset
14666 </cell>
14667 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14668 \begin_inset Text
14669
14670 \begin_layout Standard
14671 0x0003
14672 \end_layout
14673
14674 \end_inset
14675 </cell>
14676 </row>
14677 <row topline="true">
14678 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14679 \begin_inset Text
14680
14681 \begin_layout Standard
14682 1
14683 \end_layout
14684
14685 \end_inset
14686 </cell>
14687 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14688 \begin_inset Text
14689
14690 \begin_layout Standard
14691 Timer 0
14692 \end_layout
14693
14694 \end_inset
14695 </cell>
14696 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14697 \begin_inset Text
14698
14699 \begin_layout Standard
14700 0x000b
14701 \end_layout
14702
14703 \end_inset
14704 </cell>
14705 </row>
14706 <row topline="true">
14707 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14708 \begin_inset Text
14709
14710 \begin_layout Standard
14711 2
14712 \end_layout
14713
14714 \end_inset
14715 </cell>
14716 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14717 \begin_inset Text
14718
14719 \begin_layout Standard
14720 External 1
14721 \end_layout
14722
14723 \end_inset
14724 </cell>
14725 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14726 \begin_inset Text
14727
14728 \begin_layout Standard
14729 0x0013
14730 \end_layout
14731
14732 \end_inset
14733 </cell>
14734 </row>
14735 <row topline="true">
14736 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14737 \begin_inset Text
14738
14739 \begin_layout Standard
14740 3
14741 \end_layout
14742
14743 \end_inset
14744 </cell>
14745 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14746 \begin_inset Text
14747
14748 \begin_layout Standard
14749 Timer 1
14750 \end_layout
14751
14752 \end_inset
14753 </cell>
14754 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14755 \begin_inset Text
14756
14757 \begin_layout Standard
14758 0x001b
14759 \end_layout
14760
14761 \end_inset
14762 </cell>
14763 </row>
14764 <row topline="true">
14765 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14766 \begin_inset Text
14767
14768 \begin_layout Standard
14769 4
14770 \end_layout
14771
14772 \end_inset
14773 </cell>
14774 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14775 \begin_inset Text
14776
14777 \begin_layout Standard
14778 Serial
14779 \end_layout
14780
14781 \end_inset
14782 </cell>
14783 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14784 \begin_inset Text
14785
14786 \begin_layout Standard
14787 0x0023
14788 \end_layout
14789
14790 \end_inset
14791 </cell>
14792 </row>
14793 <row topline="true">
14794 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14795 \begin_inset Text
14796
14797 \begin_layout Standard
14798 5
14799 \end_layout
14800
14801 \end_inset
14802 </cell>
14803 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14804 \begin_inset Text
14805
14806 \begin_layout Standard
14807 Timer 2 (8052)
14808 \end_layout
14809
14810 \end_inset
14811 </cell>
14812 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14813 \begin_inset Text
14814
14815 \begin_layout Standard
14816 0x002b
14817 \end_layout
14818
14819 \end_inset
14820 </cell>
14821 </row>
14822 <row topline="true">
14823 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14824 \begin_inset Text
14825
14826 \begin_layout Standard
14827 ...
14828 \end_layout
14829
14830 \end_inset
14831 </cell>
14832 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14833 \begin_inset Text
14834
14835 \begin_layout Standard
14836
14837 \end_layout
14838
14839 \end_inset
14840 </cell>
14841 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14842 \begin_inset Text
14843
14844 \begin_layout Standard
14845 ...
14846 \end_layout
14847
14848 \end_inset
14849 </cell>
14850 </row>
14851 <row topline="true" bottomline="true">
14852 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14853 \begin_inset Text
14854
14855 \begin_layout Standard
14856 n
14857 \end_layout
14858
14859 \end_inset
14860 </cell>
14861 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14862 \begin_inset Text
14863
14864 \begin_layout Standard
14865
14866 \end_layout
14867
14868 \end_inset
14869 </cell>
14870 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14871 \begin_inset Text
14872
14873 \begin_layout Standard
14874 0x0003 + 8*n
14875 \end_layout
14876
14877 \end_inset
14878 </cell>
14879 </row>
14880 </lyxtabular>
14881
14882 \end_inset
14883
14884
14885 \newline
14886
14887 \end_layout
14888
14889 \begin_layout Standard
14890 If the interrupt service routine is defined without 
14891 \emph on
14892 using
14893 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
14894
14895 \end_inset
14896
14897
14898 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
14899
14900 \end_inset
14901
14902
14903 \emph default
14904  a register bank or with register bank 0 (
14905 \emph on
14906 using
14907 \emph default
14908  0), the compiler will save the registers used by itself on the stack upon
14909  entry and restore them at exit, however if such an interrupt service routine
14910  calls another function then the entire register bank will be saved on the
14911  stack.
14912  This scheme may be advantageous for small interrupt service routines which
14913  have low register usage.
14914 \end_layout
14915
14916 \begin_layout Standard
14917 If the interrupt service routine is defined to be using a specific register
14918  bank then only 
14919 \emph on
14920 a, b, dptr
14921 \emph default
14922  & psw are saved and restored, if such an interrupt service routine calls
14923  another function (using another register bank) then the entire register
14924  bank of the called function will be saved on the stack
14925 \begin_inset LatexCommand \index{stack}
14926
14927 \end_inset
14928
14929 .
14930  This scheme is recommended for larger interrupt service routines.
14931 \begin_inset VSpace bigskip
14932 \end_inset
14933
14934
14935 \end_layout
14936
14937 \begin_layout Subsection
14938 HC08
14939 \begin_inset LatexCommand \index{HC08}
14940
14941 \end_inset
14942
14943  Interrupt Service Routines
14944 \end_layout
14945
14946 \begin_layout Standard
14947 Since the number of interrupts
14948 \begin_inset LatexCommand \index{HC08!interrupt}
14949
14950 \end_inset
14951
14952  available is chip specific and the interrupt vector table always ends at
14953  the last byte of memory, the interrupt numbers corresponds to the interrupt
14954  vectors in reverse order of address.
14955  For example, interrupt 1 will use the interrupt vector at 0xfffc, interrupt
14956  2 will use the interrupt vector at 0xfffa, and so on.
14957  However, interrupt 0 (the reset vector at 0xfffe) is not redefinable in
14958  this way; instead see section 
14959 \begin_inset LatexCommand \ref{sub:Startup-Code}
14960
14961 \end_inset
14962
14963  for details on customizing startup.
14964 \begin_inset VSpace bigskip
14965 \end_inset
14966
14967
14968 \end_layout
14969
14970 \begin_layout Subsection
14971 Z80 Interrupt Service Routines
14972 \end_layout
14973
14974 \begin_layout Standard
14975 The Z80
14976 \begin_inset LatexCommand \index{Z80}
14977
14978 \end_inset
14979
14980  uses several different methods for determining the correct interrupt
14981 \begin_inset LatexCommand \index{Z80!interrupt}
14982
14983 \end_inset
14984
14985  vector depending on the hardware implementation.
14986  Therefore, SDCC ignores the optional interrupt number and does not attempt
14987  to generate an interrupt vector table.
14988 \end_layout
14989
14990 \begin_layout Standard
14991 By default, SDCC generates code for a maskable interrupt, which uses a RETI
14992  instruction to return from the interrupt.
14993  To write an interrupt handler for the non-maskable interrupt, which needs
14994  a RETN instruction instead, add the 
14995 \emph on
14996 critical
14997 \emph default
14998  keyword:
14999 \end_layout
15000
15001 \begin_layout Verse
15002
15003 \family typewriter
15004 void nmi_isr (void) critical interrupt
15005 \newline
15006
15007 \newline
15008 \InsetSpace ~
15009 \InsetSpace ~
15010 \InsetSpace ~
15011 \InsetSpace ~
15012 ...
15013  
15014 \newline
15015 }
15016 \end_layout
15017
15018 \begin_layout Standard
15019 However if you need to create a non-interruptable interrupt service routine
15020  you would also require the 
15021 \emph on
15022 critical
15023 \emph default
15024  keyword.
15025  To distinguish between this and an nmi_isr you must provide an interrupt
15026  number.
15027 \begin_inset VSpace bigskip
15028 \end_inset
15029
15030
15031 \end_layout
15032
15033 \begin_layout Section
15034 Enabling and Disabling Interrupts
15035 \end_layout
15036
15037 \begin_layout Subsection
15038 Critical Functions and Critical Statements
15039 \end_layout
15040
15041 \begin_layout Standard
15042 A special keyword may be associated with a block or a function declaring
15043  it as 
15044 \emph on
15045 critical
15046 \emph default
15047 .
15048  SDCC will generate code to disable all interrupts
15049 \begin_inset LatexCommand \index{interrupt}
15050
15051 \end_inset
15052
15053  upon entry to a critical function and restore the interrupt enable to the
15054  previous state before returning.
15055  Nesting critical functions will need one additional byte on the stack
15056 \begin_inset LatexCommand \index{stack}
15057
15058 \end_inset
15059
15060  for each call.
15061 \end_layout
15062
15063 \begin_layout Verse
15064
15065 \family typewriter
15066 int foo () __critical
15067 \begin_inset LatexCommand \index{critical}
15068
15069 \end_inset
15070
15071
15072 \begin_inset LatexCommand \index{\_\_critical}
15073
15074 \end_inset
15075
15076  
15077 \newline
15078
15079 \newline
15080 \InsetSpace ~
15081 \InsetSpace ~
15082 \InsetSpace ~
15083 \InsetSpace ~
15084 ...
15085  
15086 \newline
15087 \InsetSpace ~
15088 \InsetSpace ~
15089 \InsetSpace ~
15090 \InsetSpace ~
15091 ...
15092  
15093 \newline
15094 }
15095 \end_layout
15096
15097 \begin_layout Standard
15098 The critical attribute maybe used with other attributes like 
15099 \emph on
15100 reentrant.
15101 \emph default
15102
15103 \newline
15104 The keyword 
15105 \emph on
15106 critical
15107 \emph default
15108  may also be used to disable interrupts more locally:
15109 \end_layout
15110
15111 \begin_layout Verse
15112
15113 \family typewriter
15114 __critical{ i++; }
15115 \end_layout
15116
15117 \begin_layout Standard
15118 More than one statement could have been included in the block.
15119 \end_layout
15120
15121 \begin_layout Subsection
15122 Enabling and Disabling Interrupts directly
15123 \end_layout
15124
15125 \begin_layout Standard
15126 Interrupts
15127 \begin_inset LatexCommand \index{interrupt}
15128
15129 \end_inset
15130
15131  can also be disabled and enabled directly (8051):
15132 \end_layout
15133
15134 \begin_layout Verse
15135
15136 \family typewriter
15137 EA = 0;\InsetSpace ~
15138 \InsetSpace ~
15139 \InsetSpace ~
15140 \InsetSpace ~
15141 \InsetSpace ~
15142 \InsetSpace ~
15143 \InsetSpace ~
15144 \InsetSpace ~
15145 \InsetSpace ~
15146 \InsetSpace ~
15147 \InsetSpace ~
15148 \InsetSpace ~
15149 or:\InsetSpace ~
15150 \InsetSpace ~
15151 \InsetSpace ~
15152 \InsetSpace ~
15153 \InsetSpace ~
15154 \InsetSpace ~
15155 \InsetSpace ~
15156 \InsetSpace ~
15157 \InsetSpace ~
15158 \InsetSpace ~
15159 \InsetSpace ~
15160 EA_SAVE = EA;
15161 \end_layout
15162
15163 \begin_layout Verse
15164
15165 \family typewriter
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 \InsetSpace ~
15193 \InsetSpace ~
15194 \InsetSpace ~
15195 \InsetSpace ~
15196 EA = 0;
15197 \end_layout
15198
15199 \begin_layout Verse
15200
15201 \family typewriter
15202 EA = 1;\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 \InsetSpace ~
15225 \InsetSpace ~
15226 \InsetSpace ~
15227 \InsetSpace ~
15228 ...
15229 \end_layout
15230
15231 \begin_layout Verse
15232
15233 \family typewriter
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 \InsetSpace ~
15264 \InsetSpace ~
15265 \InsetSpace ~
15266 \InsetSpace ~
15267 EA = EA_SAVE;
15268 \end_layout
15269
15270 \begin_layout Standard
15271 On other architectures which have seperate opcodes for enabling and disabling
15272  interrupts you might want to make use of defines with inline assembly
15273 \begin_inset LatexCommand \index{Assembler routines}
15274
15275 \end_inset
15276
15277  (HC08
15278 \begin_inset LatexCommand \index{HC08!interrupt}
15279
15280 \end_inset
15281
15282 ):
15283 \end_layout
15284
15285 \begin_layout Verse
15286
15287 \family typewriter
15288 #define CLI _asm
15289 \begin_inset LatexCommand \index{\_asm}
15290
15291 \end_inset
15292
15293 \InsetSpace ~
15294 \InsetSpace ~
15295 cli\InsetSpace ~
15296 \InsetSpace ~
15297 _endasm
15298 \begin_inset LatexCommand \index{\_endasm}
15299
15300 \end_inset
15301
15302
15303 \end_layout
15304
15305 \begin_layout Verse
15306
15307 \family typewriter
15308 #define SEI _asm\InsetSpace ~
15309 \InsetSpace ~
15310 sei\InsetSpace ~
15311 \InsetSpace ~
15312 _endasm; 
15313 \end_layout
15314
15315 \begin_layout Verse
15316
15317 \family typewriter
15318 ...
15319 \end_layout
15320
15321 \begin_layout Standard
15322 Note: it is sometimes sufficient to disable only a specific interrupt source
15323  like f.e.
15324  a timer or serial interrupt by manipulating an 
15325 \emph on
15326 interrupt mask
15327 \begin_inset LatexCommand \index{interrupt mask}
15328
15329 \end_inset
15330
15331
15332 \emph default
15333  register.
15334  
15335 \end_layout
15336
15337 \begin_layout Standard
15338 Usually the time during which interrupts are disabled should be kept as
15339  short as possible.
15340  This minimizes both 
15341 \emph on
15342 interrupt latency
15343 \emph default
15344
15345 \begin_inset LatexCommand \index{interrupt latency}
15346
15347 \end_inset
15348
15349  (the time between the occurrence of the interrupt and the execution of
15350  the first code in the interrupt routine) and 
15351 \emph on
15352 interrupt jitter
15353 \emph default
15354
15355 \begin_inset LatexCommand \index{interrupt jitter}
15356
15357 \end_inset
15358
15359  (the difference between the shortest and the longest interrupt latency).
15360  These really are something different, f.e.
15361  a serial interrupt has to be served before its buffer overruns so it cares
15362  for the maximum interrupt latency, whereas it does not care about jitter.
15363  On a loudspeaker driven via a digital to analog converter which is fed
15364  by an interrupt a latency of a few milliseconds might be tolerable, whereas
15365  a much smaller jitter will be very audible.
15366 \end_layout
15367
15368 \begin_layout Standard
15369 You can reenable interrupts within an interrupt routine and on some architecture
15370 s you can make use of two (or more) levels of 
15371 \emph on
15372 interrupt priorities
15373 \emph default
15374
15375 \begin_inset LatexCommand \index{interrupt priority}
15376
15377 \end_inset
15378
15379 .
15380  On some architectures which don't support interrupt priorities these can
15381  be implemented by manipulating the interrupt mask and reenabling interrupts
15382  within the interrupt routine.
15383  Check there is sufficient space on the stack
15384 \begin_inset LatexCommand \index{stack}
15385
15386 \end_inset
15387
15388  and don't add complexity unless you have to.
15389  
15390 \end_layout
15391
15392 \begin_layout Subsection
15393 Semaphore
15394 \begin_inset LatexCommand \index{semaphore}
15395
15396 \end_inset
15397
15398  locking (mcs51/ds390)
15399 \end_layout
15400
15401 \begin_layout Standard
15402 Some architectures (mcs51/ds390) have an atomic
15403 \begin_inset LatexCommand \index{atomic}
15404
15405 \end_inset
15406
15407  bit test and
15408 \emph on
15409  
15410 \emph default
15411 clear
15412 \emph on
15413  
15414 \emph default
15415 instruction.
15416  These type of instructions are typically used in preemptive multitasking
15417  systems, where a routine f.e.
15418  claims the use of a data structure ('acquires a lock
15419 \begin_inset LatexCommand \index{lock}
15420
15421 \end_inset
15422
15423  on it'), makes some modifications and then releases the lock when the data
15424  structure is consistent again.
15425  The instruction may also be used if interrupt and non-interrupt code have
15426  to compete for a resource.
15427  With the atomic bit test and clear instruction interrupts
15428 \begin_inset LatexCommand \index{interrupt}
15429
15430 \end_inset
15431
15432  don't have to be disabled for the locking operation.
15433  
15434 \end_layout
15435
15436 \begin_layout Standard
15437 SDCC generates this instruction if the source follows this pattern:
15438 \end_layout
15439
15440 \begin_layout Verse
15441
15442 \family typewriter
15443 volatile
15444 \begin_inset LatexCommand \index{volatile}
15445
15446 \end_inset
15447
15448  bit resource_is_free; 
15449 \newline
15450
15451 \newline
15452 if (resource_is_free) 
15453 \newline
15454 \InsetSpace ~
15455 \InsetSpace ~
15456
15457 \newline
15458 \InsetSpace ~
15459 \InsetSpace ~
15460 \InsetSpace ~
15461 \InsetSpace ~
15462 resource_is_free=0; 
15463 \newline
15464 \InsetSpace ~
15465 \InsetSpace ~
15466 \InsetSpace ~
15467 \InsetSpace ~
15468 ...
15469  
15470 \newline
15471 \InsetSpace ~
15472 \InsetSpace ~
15473 \InsetSpace ~
15474 \InsetSpace ~
15475 resource_is_free=1;
15476 \newline
15477 \InsetSpace ~
15478 \InsetSpace ~
15479
15480 \end_layout
15481
15482 \begin_layout Standard
15483 Note, mcs51 and ds390 support only an atomic
15484 \begin_inset LatexCommand \index{atomic}
15485
15486 \end_inset
15487
15488  bit test and 
15489 \emph on
15490 clear
15491 \emph default
15492  instruction (as opposed to atomic bit test and 
15493 \emph on
15494 set).
15495 \end_layout
15496
15497 \begin_layout Section
15498 Functions using private register banks
15499 \begin_inset LatexCommand \label{sub:Functions-using-private-banks}
15500
15501 \end_inset
15502
15503  (mcs51/ds390)
15504 \end_layout
15505
15506 \begin_layout Standard
15507 Some architectures have support for quickly changing register sets.
15508  SDCC supports this feature with the 
15509 \emph on
15510 using
15511 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
15512
15513 \end_inset
15514
15515
15516 \begin_inset LatexCommand \index{\_\_using (mcs51, ds390 register bank)}
15517
15518 \end_inset
15519
15520
15521 \emph default
15522  attribute (which tells the compiler to use a register bank
15523 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
15524
15525 \end_inset
15526
15527  other than the default bank zero).
15528  It should only be applied to 
15529 \emph on
15530 interrupt
15531 \begin_inset LatexCommand \index{interrupt}
15532
15533 \end_inset
15534
15535
15536 \emph default
15537  functions (see footnote below).
15538  This will in most circumstances make the generated ISR code more efficient
15539  since it will not have to save registers on the stack.
15540 \end_layout
15541
15542 \begin_layout Standard
15543 The 
15544 \emph on
15545 using
15546 \emph default
15547  attribute will have no effect on the generated code for a 
15548 \emph on
15549 non-interrupt
15550 \emph default
15551  function (but may occasionally be useful anyway
15552 \begin_inset Foot
15553 status open
15554
15555 \begin_layout Standard
15556 possible exception: if a function is called ONLY from 'interrupt' functions
15557  using a particular bank, it can be declared with the same 'using' attribute
15558  as the calling 'interrupt' functions.
15559  For instance, if you have several ISRs using bank one, and all of them
15560  call memcpy(), it might make sense to create a specialized version of memcpy()
15561  'using 1', since this would prevent the ISR from having to save bank zero
15562  to the stack on entry and switch to bank zero before calling the function
15563 \end_layout
15564
15565 \end_inset
15566
15567 ).
15568 \newline
15569
15570 \emph on
15571 (pending: Note, nowadays the 
15572 \emph default
15573 using
15574 \emph on
15575  attribute has an effect on
15576 \emph default
15577  
15578 \emph on
15579 the generated code for a 
15580 \emph default
15581 non-interrupt
15582 \emph on
15583  function
15584 \emph default
15585 .
15586 \emph on
15587 )
15588 \end_layout
15589
15590 \begin_layout Standard
15591 An 
15592 \emph on
15593 interrupt
15594 \emph default
15595  function using a non-zero bank will assume that it can trash that register
15596  bank, and will not save it.
15597  Since high-priority interrupts
15598 \begin_inset LatexCommand \index{interrupts}
15599
15600 \end_inset
15601
15602
15603 \begin_inset LatexCommand \index{interrupt priority}
15604
15605 \end_inset
15606
15607  can interrupt low-priority ones on the 8051 and friends, this means that
15608  if a high-priority ISR 
15609 \emph on
15610 using
15611 \emph default
15612  a particular bank occurs while processing a low-priority ISR 
15613 \emph on
15614 using
15615 \emph default
15616  the same bank, terrible and bad things can happen.
15617  To prevent this, no single register bank should be 
15618 \emph on
15619 used
15620 \emph default
15621  by both a high priority and a low priority ISR.
15622  This is probably most easily done by having all high priority ISRs use
15623  one bank and all low priority ISRs use another.
15624  If you have an ISR which can change priority at runtime, you're on your
15625  own: I suggest using the default bank zero and taking the small performance
15626  hit.
15627 \end_layout
15628
15629 \begin_layout Standard
15630 It is most efficient if your ISR calls no other functions.
15631  If your ISR must call other functions, it is most efficient if those functions
15632  use the same bank as the ISR (see note 1 below); the next best is if the
15633  called functions use bank zero.
15634  It is very inefficient to call a function using a different, non-zero bank
15635  from an ISR.
15636  
15637 \begin_inset VSpace bigskip
15638 \end_inset
15639
15640
15641 \end_layout
15642
15643 \begin_layout Section
15644 Startup Code
15645 \begin_inset LatexCommand \label{sub:Startup-Code}
15646
15647 \end_inset
15648
15649
15650 \begin_inset LatexCommand \index{Startup code}
15651
15652 \end_inset
15653
15654
15655 \end_layout
15656
15657 \begin_layout Subsection
15658 MCS51/DS390 Startup Code
15659 \end_layout
15660
15661 \begin_layout Standard
15662 The compiler triggers the linker to link certain initialization modules
15663  from the runtime library
15664 \begin_inset LatexCommand \index{Runtime library}
15665
15666 \end_inset
15667
15668  called crt<something>.
15669  Only the necessary ones are linked, for instance crtxstack.asm (GSINIT1,
15670  GSINIT5) is not linked unless the -
15671 \series bold
15672
15673 \begin_inset ERT
15674 status open
15675
15676 \begin_layout Standard
15677
15678
15679 \backslash
15680 /
15681 \end_layout
15682
15683 \end_inset
15684
15685
15686 \series default
15687 -xstack option is used.
15688  These modules are highly entangled by the use of special segments/areas,
15689  but a common layout is shown below:
15690 \end_layout
15691
15692 \begin_layout Verse
15693
15694 \family typewriter
15695 \series bold
15696 \size footnotesize
15697 (main.asm)
15698 \end_layout
15699
15700 \begin_layout Verse
15701
15702 \family typewriter
15703 \size footnotesize
15704 \InsetSpace ~
15705 \InsetSpace ~
15706 \InsetSpace ~
15707 \InsetSpace ~
15708 \InsetSpace ~
15709 \InsetSpace ~
15710 \InsetSpace ~
15711 \InsetSpace ~
15712 .area HOME (CODE)
15713 \newline
15714 __interrupt_vect:
15715 \newline
15716 \InsetSpace ~
15717 \InsetSpace ~
15718 \InsetSpace ~
15719 \InsetSpace ~
15720 \InsetSpace ~
15721 \InsetSpace ~
15722 \InsetSpace ~
15723 \InsetSpace ~
15724 ljmp __sdcc_gsinit_startup
15725 \end_layout
15726
15727 \begin_layout Verse
15728
15729 \family typewriter
15730 \series bold
15731 \size footnotesize
15732 (crtstart.asm)
15733 \end_layout
15734
15735 \begin_layout Verse
15736
15737 \family typewriter
15738 \size footnotesize
15739 \InsetSpace ~
15740 \InsetSpace ~
15741 \InsetSpace ~
15742 \InsetSpace ~
15743 \InsetSpace ~
15744 \InsetSpace ~
15745 \InsetSpace ~
15746 \InsetSpace ~
15747 .area GSINIT0 (CODE)
15748 \newline
15749 __sdcc_gsinit_startup::
15750 \newline
15751 \InsetSpace ~
15752 \InsetSpace ~
15753 \InsetSpace ~
15754 \InsetSpace ~
15755 \InsetSpace ~
15756 \InsetSpace ~
15757 \InsetSpace ~
15758 \InsetSpace ~
15759 mov sp,#__start__stack - 1
15760 \end_layout
15761
15762 \begin_layout Verse
15763
15764 \family typewriter
15765 \series bold
15766 \size footnotesize
15767 (crtxstack.asm)
15768 \end_layout
15769
15770 \begin_layout Verse
15771
15772 \family typewriter
15773 \size footnotesize
15774 \InsetSpace ~
15775 \InsetSpace ~
15776 \InsetSpace ~
15777 \InsetSpace ~
15778 \InsetSpace ~
15779 \InsetSpace ~
15780 \InsetSpace ~
15781 \InsetSpace ~
15782 .area GSINIT1 (CODE)
15783 \newline
15784 __sdcc_init_xstack::
15785 \newline
15786 ; Need to initialize in GSINIT1 in
15787  case the user's __sdcc_external_startup uses the xstack.
15788 \newline
15789 \InsetSpace ~
15790 \InsetSpace ~
15791 \InsetSpace ~
15792 \InsetSpace ~
15793 \InsetSpace ~
15794 \InsetSpace ~
15795 \InsetSpace ~
15796 \InsetSpace ~
15797 mov __XPAGE,#(__start__x
15798 stack >> 8)
15799 \newline
15800 \InsetSpace ~
15801 \InsetSpace ~
15802 \InsetSpace ~
15803 \InsetSpace ~
15804 \InsetSpace ~
15805 \InsetSpace ~
15806 \InsetSpace ~
15807 \InsetSpace ~
15808 mov _spx,#__start__xstack
15809 \end_layout
15810
15811 \begin_layout Verse
15812
15813 \family typewriter
15814 \series bold
15815 \size footnotesize
15816 (crtstart.asm)
15817 \end_layout
15818
15819 \begin_layout Verse
15820
15821 \family typewriter
15822 \size footnotesize
15823 \InsetSpace ~
15824 \InsetSpace ~
15825 \InsetSpace ~
15826 \InsetSpace ~
15827 \InsetSpace ~
15828 \InsetSpace ~
15829 \InsetSpace ~
15830 \InsetSpace ~
15831 .area GSINIT2 (CODE)
15832 \newline
15833 \InsetSpace ~
15834 \InsetSpace ~
15835 \InsetSpace ~
15836 \InsetSpace ~
15837 \InsetSpace ~
15838 \InsetSpace ~
15839 \InsetSpace ~
15840 \InsetSpace ~
15841 lcall __sdcc_external_startup
15842 \newline
15843 \InsetSpace ~
15844 \InsetSpace ~
15845 \InsetSpace ~
15846 \InsetSpace ~
15847 \InsetSpace ~
15848 \InsetSpace ~
15849 \InsetSpace ~
15850 \InsetSpace ~
15851 mov a,dpl
15852 \newline
15853 \InsetSpace ~
15854 \InsetSpace ~
15855 \InsetSpace ~
15856 \InsetSpace ~
15857 \InsetSpace ~
15858 \InsetSpace ~
15859 \InsetSpace ~
15860 \InsetSpace ~
15861 jz __sdcc_init_data
15862 \newline
15863 \InsetSpace ~
15864 \InsetSpace ~
15865 \InsetSpace ~
15866 \InsetSpace ~
15867 \InsetSpace ~
15868 \InsetSpace ~
15869 \InsetSpace ~
15870 \InsetSpace ~
15871 ljmp
15872  __sdcc_program_startup
15873 \newline
15874 __sdcc_init_data:
15875 \end_layout
15876
15877 \begin_layout Verse
15878
15879 \family typewriter
15880 \series bold
15881 \size footnotesize
15882 (crtxinit.asm)
15883 \end_layout
15884
15885 \begin_layout Verse
15886
15887 \family typewriter
15888 \size footnotesize
15889 \InsetSpace ~
15890 \InsetSpace ~
15891 \InsetSpace ~
15892 \InsetSpace ~
15893 \InsetSpace ~
15894 \InsetSpace ~
15895 \InsetSpace ~
15896 \InsetSpace ~
15897 .area GSINIT3 (CODE)
15898 \newline
15899 __mcs51_genXINIT::
15900 \newline
15901 \InsetSpace ~
15902 \InsetSpace ~
15903 \InsetSpace ~
15904 \InsetSpace ~
15905 \InsetSpace ~
15906 \InsetSpace ~
15907 \InsetSpace ~
15908 \InsetSpace ~
15909 mov r1,#l_XINIT
15910 \newline
15911 \InsetSpace ~
15912 \InsetSpace ~
15913 \InsetSpace ~
15914 \InsetSpace ~
15915 \InsetSpace ~
15916 \InsetSpace ~
15917 \InsetSpace ~
15918 \InsetSpace ~
15919 mov a,r1
15920 \newline
15921 \InsetSpace ~
15922 \InsetSpace ~
15923 \InsetSpace ~
15924 \InsetSpace ~
15925 \InsetSpace ~
15926 \InsetSpace ~
15927 \InsetSpace ~
15928 \InsetSpace ~
15929 orl a,#(l_XINIT
15930  >> 8)
15931 \newline
15932 \InsetSpace ~
15933 \InsetSpace ~
15934 \InsetSpace ~
15935 \InsetSpace ~
15936 \InsetSpace ~
15937 \InsetSpace ~
15938 \InsetSpace ~
15939 \InsetSpace ~
15940 jz 00003$
15941 \newline
15942 \InsetSpace ~
15943 \InsetSpace ~
15944 \InsetSpace ~
15945 \InsetSpace ~
15946 \InsetSpace ~
15947 \InsetSpace ~
15948 \InsetSpace ~
15949 \InsetSpace ~
15950 mov r2,#((l_XINIT+255) >> 8)
15951 \newline
15952 \InsetSpace ~
15953 \InsetSpace ~
15954 \InsetSpace ~
15955 \InsetSpace ~
15956 \InsetSpace ~
15957 \InsetSpace ~
15958 \InsetSpace ~
15959 \InsetSpace ~
15960 mov dptr,#s_XINIT
15961 \newline
15962 \InsetSpace ~
15963 \InsetSpace ~
15964 \InsetSpace ~
15965 \InsetSpace ~
15966 \InsetSpace ~
15967 \InsetSpace ~
15968 \InsetSpace ~
15969 \InsetSpace ~
15970 mov r0,#s_XISEG
15971 \newline
15972 \InsetSpace ~
15973 \InsetSpace ~
15974 \InsetSpace ~
15975 \InsetSpace ~
15976 \InsetSpace ~
15977 \InsetSpace ~
15978 \InsetSpace ~
15979 \InsetSpace ~
15980 mov
15981  __XPAGE,#(s_XISEG >> 8)
15982 \newline
15983 00001$:\InsetSpace ~
15984 clr a
15985 \newline
15986 \InsetSpace ~
15987 \InsetSpace ~
15988 \InsetSpace ~
15989 \InsetSpace ~
15990 \InsetSpace ~
15991 \InsetSpace ~
15992 \InsetSpace ~
15993 \InsetSpace ~
15994 movc a,@a+dptr
15995 \newline
15996 \InsetSpace ~
15997 \InsetSpace ~
15998 \InsetSpace ~
15999 \InsetSpace ~
16000 \InsetSpace ~
16001 \InsetSpace ~
16002 \InsetSpace ~
16003 \InsetSpace ~
16004 movx @r0,a
16005 \newline
16006 \InsetSpace ~
16007 \InsetSpace ~
16008 \InsetSpace ~
16009 \InsetSpace ~
16010 \InsetSpace ~
16011 \InsetSpace ~
16012 \InsetSpace ~
16013 \InsetSpace ~
16014 inc dptr
16015 \newline
16016 \InsetSpace ~
16017 \InsetSpace ~
16018 \InsetSpace ~
16019 \InsetSpace ~
16020 \InsetSpace ~
16021 \InsetSpace ~
16022 \InsetSpace ~
16023 \InsetSpace ~
16024 inc
16025  r0
16026 \newline
16027 \InsetSpace ~
16028 \InsetSpace ~
16029 \InsetSpace ~
16030 \InsetSpace ~
16031 \InsetSpace ~
16032 \InsetSpace ~
16033 \InsetSpace ~
16034 \InsetSpace ~
16035 cjne r0,#0,00002$
16036 \newline
16037 \InsetSpace ~
16038 \InsetSpace ~
16039 \InsetSpace ~
16040 \InsetSpace ~
16041 \InsetSpace ~
16042 \InsetSpace ~
16043 \InsetSpace ~
16044 \InsetSpace ~
16045 inc __XPAGE
16046 \newline
16047 00002$:\InsetSpace ~
16048 djnz r1,00001$
16049 \newline
16050 \InsetSpace ~
16051 \InsetSpace ~
16052 \InsetSpace ~
16053 \InsetSpace ~
16054 \InsetSpace ~
16055 \InsetSpace ~
16056 \InsetSpace ~
16057 \InsetSpace ~
16058 djnz r2,00001$
16059 \newline
16060 \InsetSpace ~
16061 \InsetSpace ~
16062 \InsetSpace ~
16063 \InsetSpace ~
16064 \InsetSpace ~
16065 \InsetSpace ~
16066 \InsetSpace ~
16067 \InsetSpace ~
16068 mov __XPAGE,#0
16069 xFF
16070 \newline
16071 00003$:
16072 \end_layout
16073
16074 \begin_layout Verse
16075
16076 \family typewriter
16077 \series bold
16078 \size footnotesize
16079 (crtclear.asm)
16080 \end_layout
16081
16082 \begin_layout Verse
16083
16084 \family typewriter
16085 \size footnotesize
16086 \InsetSpace ~
16087 \InsetSpace ~
16088 \InsetSpace ~
16089 \InsetSpace ~
16090 \InsetSpace ~
16091 \InsetSpace ~
16092 \InsetSpace ~
16093 \InsetSpace ~
16094 .area GSINIT4 (CODE)
16095 \newline
16096 __mcs51_genRAMCLEAR::
16097 \newline
16098 \InsetSpace ~
16099 \InsetSpace ~
16100 \InsetSpace ~
16101 \InsetSpace ~
16102 \InsetSpace ~
16103 \InsetSpace ~
16104 \InsetSpace ~
16105 \InsetSpace ~
16106 clr a
16107 \newline
16108 \InsetSpace ~
16109 \InsetSpace ~
16110 \InsetSpace ~
16111 \InsetSpace ~
16112 \InsetSpace ~
16113 \InsetSpace ~
16114 \InsetSpace ~
16115 \InsetSpace ~
16116 mov r0,#(l_IRAM-1)
16117 \newline
16118 00004$:\InsetSpace ~
16119 mov
16120  @r0,a
16121 \newline
16122 \InsetSpace ~
16123 \InsetSpace ~
16124 \InsetSpace ~
16125 \InsetSpace ~
16126 \InsetSpace ~
16127 \InsetSpace ~
16128 \InsetSpace ~
16129 \InsetSpace ~
16130 djnz r0,00004$
16131 \newline
16132 ; _mcs51_genRAMCLEAR() end
16133 \end_layout
16134
16135 \begin_layout Verse
16136
16137 \family typewriter
16138 \series bold
16139 \size footnotesize
16140 (crtxclear.asm)
16141 \end_layout
16142
16143 \begin_layout Verse
16144
16145 \family typewriter
16146 \size footnotesize
16147 \InsetSpace ~
16148 \InsetSpace ~
16149 \InsetSpace ~
16150 \InsetSpace ~
16151 \InsetSpace ~
16152 \InsetSpace ~
16153 \InsetSpace ~
16154 \InsetSpace ~
16155 .area GSINIT4 (CODE)
16156 \newline
16157 __mcs51_genXRAMCLEAR::
16158 \newline
16159 \InsetSpace ~
16160 \InsetSpace ~
16161 \InsetSpace ~
16162 \InsetSpace ~
16163 \InsetSpace ~
16164 \InsetSpace ~
16165 \InsetSpace ~
16166 \InsetSpace ~
16167 mov r0,#l_PSEG
16168 \newline
16169 \InsetSpace ~
16170 \InsetSpace ~
16171 \InsetSpace ~
16172 \InsetSpace ~
16173 \InsetSpace ~
16174 \InsetSpace ~
16175 \InsetSpace ~
16176 \InsetSpace ~
16177 mov a,r0
16178 \newline
16179 \InsetSpace ~
16180 \InsetSpace ~
16181 \InsetSpace ~
16182 \InsetSpace ~
16183 \InsetSpace ~
16184 \InsetSpace ~
16185 \InsetSpace ~
16186 \InsetSpace ~
16187 orl a,#(l_PSEG
16188  >> 8)
16189 \newline
16190 \InsetSpace ~
16191 \InsetSpace ~
16192 \InsetSpace ~
16193 \InsetSpace ~
16194 \InsetSpace ~
16195 \InsetSpace ~
16196 \InsetSpace ~
16197 \InsetSpace ~
16198 jz 00006$
16199 \newline
16200 \InsetSpace ~
16201 \InsetSpace ~
16202 \InsetSpace ~
16203 \InsetSpace ~
16204 \InsetSpace ~
16205 \InsetSpace ~
16206 \InsetSpace ~
16207 \InsetSpace ~
16208 mov r1,#s_PSEG
16209 \newline
16210 \InsetSpace ~
16211 \InsetSpace ~
16212 \InsetSpace ~
16213 \InsetSpace ~
16214 \InsetSpace ~
16215 \InsetSpace ~
16216 \InsetSpace ~
16217 \InsetSpace ~
16218 mov __XPAGE,#(s_PSEG >> 8)
16219 \newline
16220 \InsetSpace ~
16221 \InsetSpace ~
16222 \InsetSpace ~
16223 \InsetSpace ~
16224 \InsetSpace ~
16225 \InsetSpace ~
16226 \InsetSpace ~
16227 \InsetSpace ~
16228 clr a
16229 \newline
16230 00005$:\InsetSpace ~
16231 movx
16232  @r1,a
16233 \newline
16234 \InsetSpace ~
16235 \InsetSpace ~
16236 \InsetSpace ~
16237 \InsetSpace ~
16238 \InsetSpace ~
16239 \InsetSpace ~
16240 \InsetSpace ~
16241 \InsetSpace ~
16242 inc r1
16243 \newline
16244 \InsetSpace ~
16245 \InsetSpace ~
16246 \InsetSpace ~
16247 \InsetSpace ~
16248 \InsetSpace ~
16249 \InsetSpace ~
16250 \InsetSpace ~
16251 \InsetSpace ~
16252 djnz r0,00005$
16253 \newline
16254 00006$:
16255 \newline
16256 \InsetSpace ~
16257 \InsetSpace ~
16258 \InsetSpace ~
16259 \InsetSpace ~
16260 \InsetSpace ~
16261 \InsetSpace ~
16262 \InsetSpace ~
16263 \InsetSpace ~
16264 mov r0,#l_XSEG
16265 \newline
16266 \InsetSpace ~
16267 \InsetSpace ~
16268 \InsetSpace ~
16269 \InsetSpace ~
16270 \InsetSpace ~
16271 \InsetSpace ~
16272 \InsetSpace ~
16273 \InsetSpace ~
16274 mov a,r0
16275 \newline
16276 \InsetSpace ~
16277 \InsetSpace ~
16278 \InsetSpace ~
16279 \InsetSpace ~
16280 \InsetSpace ~
16281 \InsetSpace ~
16282 \InsetSpace ~
16283 \InsetSpace ~
16284 orl a,#(l_XSEG >>
16285  8)
16286 \newline
16287 \InsetSpace ~
16288 \InsetSpace ~
16289 \InsetSpace ~
16290 \InsetSpace ~
16291 \InsetSpace ~
16292 \InsetSpace ~
16293 \InsetSpace ~
16294 \InsetSpace ~
16295 jz 00008$
16296 \newline
16297 \InsetSpace ~
16298 \InsetSpace ~
16299 \InsetSpace ~
16300 \InsetSpace ~
16301 \InsetSpace ~
16302 \InsetSpace ~
16303 \InsetSpace ~
16304 \InsetSpace ~
16305 mov r1,#((l_XSEG + 255) >> 8)
16306 \newline
16307 \InsetSpace ~
16308 \InsetSpace ~
16309 \InsetSpace ~
16310 \InsetSpace ~
16311 \InsetSpace ~
16312 \InsetSpace ~
16313 \InsetSpace ~
16314 \InsetSpace ~
16315 mov dptr,#s_XSEG
16316 \newline
16317 \InsetSpace ~
16318 \InsetSpace ~
16319 \InsetSpace ~
16320 \InsetSpace ~
16321 \InsetSpace ~
16322 \InsetSpace ~
16323 \InsetSpace ~
16324 \InsetSpace ~
16325 clr a
16326 \newline
16327 00007$:\InsetSpace ~
16328 movx
16329  @dptr,a
16330 \newline
16331 \InsetSpace ~
16332 \InsetSpace ~
16333 \InsetSpace ~
16334 \InsetSpace ~
16335 \InsetSpace ~
16336 \InsetSpace ~
16337 \InsetSpace ~
16338 \InsetSpace ~
16339 inc dptr
16340 \newline
16341 \InsetSpace ~
16342 \InsetSpace ~
16343 \InsetSpace ~
16344 \InsetSpace ~
16345 \InsetSpace ~
16346 \InsetSpace ~
16347 \InsetSpace ~
16348 \InsetSpace ~
16349 djnz r0,00007$
16350 \newline
16351 \InsetSpace ~
16352 \InsetSpace ~
16353 \InsetSpace ~
16354 \InsetSpace ~
16355 \InsetSpace ~
16356 \InsetSpace ~
16357 \InsetSpace ~
16358 \InsetSpace ~
16359 djnz r1,00007$
16360 \newline
16361 00008$:
16362 \end_layout
16363
16364 \begin_layout Verse
16365
16366 \family typewriter
16367 \series bold
16368 \size footnotesize
16369 (crtxstack.asm)
16370 \end_layout
16371
16372 \begin_layout Verse
16373
16374 \family typewriter
16375 \size footnotesize
16376 \InsetSpace ~
16377 \InsetSpace ~
16378 \InsetSpace ~
16379 \InsetSpace ~
16380 \InsetSpace ~
16381 \InsetSpace ~
16382 \InsetSpace ~
16383 \InsetSpace ~
16384 .area GSINIT5 (CODE)
16385 \newline
16386 ; Need to initialize in GSINIT5 because __mcs51_genXINIT
16387  modifies __XPAGE
16388 \newline
16389 ; and __mcs51_genRAMCLEAR modifies _spx.
16390 \newline
16391 \InsetSpace ~
16392 \InsetSpace ~
16393 \InsetSpace ~
16394 \InsetSpace ~
16395 \InsetSpace ~
16396 \InsetSpace ~
16397 \InsetSpace ~
16398 \InsetSpace ~
16399 mov __XPAGE,#(__start__x
16400 stack >> 8)
16401 \newline
16402 \InsetSpace ~
16403 \InsetSpace ~
16404 \InsetSpace ~
16405 \InsetSpace ~
16406 \InsetSpace ~
16407 \InsetSpace ~
16408 \InsetSpace ~
16409 \InsetSpace ~
16410 mov _spx,#__start__xstack
16411 \end_layout
16412
16413 \begin_layout Verse
16414
16415 \family typewriter
16416 \series bold
16417 \size footnotesize
16418 (application modules)
16419 \end_layout
16420
16421 \begin_layout Verse
16422
16423 \family typewriter
16424 \size footnotesize
16425 \InsetSpace ~
16426 \InsetSpace ~
16427 \InsetSpace ~
16428 \InsetSpace ~
16429 \InsetSpace ~
16430 \InsetSpace ~
16431 \InsetSpace ~
16432 \InsetSpace ~
16433 .area GSINIT (CODE)
16434 \end_layout
16435
16436 \begin_layout Verse
16437
16438 \family typewriter
16439 \series bold
16440 \size footnotesize
16441 (main.asm)
16442 \end_layout
16443
16444 \begin_layout Verse
16445
16446 \family typewriter
16447 \size footnotesize
16448 \InsetSpace ~
16449 \InsetSpace ~
16450 \InsetSpace ~
16451 \InsetSpace ~
16452 \InsetSpace ~
16453 \InsetSpace ~
16454 \InsetSpace ~
16455 \InsetSpace ~
16456 .area GSFINAL (CODE)
16457 \newline
16458 \InsetSpace ~
16459 \InsetSpace ~
16460 \InsetSpace ~
16461 \InsetSpace ~
16462 \InsetSpace ~
16463 \InsetSpace ~
16464 \InsetSpace ~
16465 \InsetSpace ~
16466 ljmp __sdcc_program_startup
16467 \newline
16468 ;---------------------------------
16469 -----------------------
16470 \newline
16471 ; Home
16472 \newline
16473 ;--------------------------------------------------
16474 ------
16475 \newline
16476 \InsetSpace ~
16477 \InsetSpace ~
16478 \InsetSpace ~
16479 \InsetSpace ~
16480 \InsetSpace ~
16481 \InsetSpace ~
16482 \InsetSpace ~
16483 \InsetSpace ~
16484 .area HOME (CODE)
16485 \newline
16486 \InsetSpace ~
16487 \InsetSpace ~
16488 \InsetSpace ~
16489 \InsetSpace ~
16490 \InsetSpace ~
16491 \InsetSpace ~
16492 \InsetSpace ~
16493 \InsetSpace ~
16494 .area CSEG (CODE)
16495 \newline
16496 __sdcc_program_startup:
16497 \newline
16498 \InsetSpace ~
16499 \InsetSpace ~
16500 \InsetSpace ~
16501 \InsetSpace ~
16502 \InsetSpace ~
16503 \InsetSpace ~
16504 \InsetSpace ~
16505 \InsetSpace ~
16506 lcall _main
16507 \newline
16508 ;
16509  return from main will lock up
16510 \newline
16511 \InsetSpace ~
16512 \InsetSpace ~
16513 \InsetSpace ~
16514 \InsetSpace ~
16515 \InsetSpace ~
16516 \InsetSpace ~
16517 \InsetSpace ~
16518 \InsetSpace ~
16519 sjmp .
16520 \end_layout
16521
16522 \begin_layout Standard
16523 One of these modules (crtstart.asm) contains a call to the C routine 
16524 \emph on
16525 _sdcc_external_startup()
16526 \begin_inset LatexCommand \index{\_sdcc\_external\_startup()}
16527
16528 \end_inset
16529
16530
16531 \series bold
16532 \emph default
16533  
16534 \series default
16535 at the start of the CODE area.
16536  This routine is also in the runtime library
16537 \begin_inset LatexCommand \index{Runtime library}
16538
16539 \end_inset
16540
16541  and returns 0 by default.
16542  If this routine returns a non-zero value, the static & global variable
16543  initialization will be skipped and the function main will be invoked.
16544  Otherwise static & global variables will be initialized before the function
16545  main is invoked.
16546  You could add an 
16547 \emph on
16548 _sdcc_external_startup()
16549 \emph default
16550  routine to your program to override the default if you need to setup hardware
16551  or perform some other critical operation prior to static & global variable
16552  initialization
16553 \begin_inset LatexCommand \index{Variable initialization}
16554
16555 \end_inset
16556
16557 .
16558  On some mcs51 variants xdata
16559 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
16560
16561 \end_inset
16562
16563  memory has to be explicitly enabled before it can be accessed or if the
16564  watchdog
16565 \begin_inset LatexCommand \index{watchdog}
16566
16567 \end_inset
16568
16569  needs to be disabled, this is the place to do it.
16570  The startup code clears all internal data memory, 256 bytes by default,
16571  but from 0 to n-1 if 
16572 \emph on
16573 -
16574 \begin_inset ERT
16575 status collapsed
16576
16577 \begin_layout Standard
16578
16579
16580 \backslash
16581 /
16582 \end_layout
16583
16584 \end_inset
16585
16586 -iram-size
16587 \begin_inset LatexCommand \index{-\/-iram-size <Value>}
16588
16589 \end_inset
16590
16591 n
16592 \emph default
16593  is used.
16594  (recommended for Chipcon CC1010).
16595 \end_layout
16596
16597 \begin_layout Standard
16598 See also the compiler options 
16599 \emph on
16600 -
16601 \begin_inset ERT
16602 status collapsed
16603
16604 \begin_layout Standard
16605
16606
16607 \backslash
16608 /
16609 \end_layout
16610
16611 \end_inset
16612
16613 -no-xinit
16614 \emph default
16615 -
16616 \emph on
16617 opt
16618 \emph default
16619
16620 \begin_inset LatexCommand \index{-\/-no-xinit-opt}
16621
16622 \end_inset
16623
16624
16625 \emph on
16626 -
16627 \begin_inset ERT
16628 status collapsed
16629
16630 \begin_layout Standard
16631
16632
16633 \backslash
16634 /
16635 \end_layout
16636
16637 \end_inset
16638
16639 -main-return
16640 \emph default
16641
16642 \begin_inset LatexCommand \index{-\/-main-return}
16643
16644 \end_inset
16645
16646  and section 
16647 \begin_inset LatexCommand \ref{sub:MCS51-variants}
16648
16649 \end_inset
16650
16651  about MCS51-variants.
16652 \newline
16653
16654 \end_layout
16655
16656 \begin_layout Standard
16657 While these initialization modules are meant as generic startup code there
16658  might be the need for customization.
16659  Let's assume the return value of 
16660 \emph on
16661 _sdcc_external_startup()
16662 \emph default
16663  in 
16664 \emph on
16665 crtstart.asm
16666 \emph default
16667  should not be checked (or 
16668 \emph on
16669 _sdcc_external_startup()
16670 \emph default
16671  should not be called at all).
16672  The recommended way would be to copy 
16673 \emph on
16674 crtstart.asm
16675 \emph default
16676  (f.e.
16677  from 
16678 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/device/lib/mcs51/crtstart.asm}
16679
16680 \end_inset
16681
16682 ) into the source directory, adapt it there, then assemble it with 
16683 \emph on
16684 asx8051 -plosgff
16685 \begin_inset Foot
16686 status open
16687
16688 \begin_layout Standard
16689 \begin_inset Quotes sld
16690 \end_inset
16691
16692 -plosgff
16693 \begin_inset Quotes srd
16694 \end_inset
16695
16696  are the assembler options used in 
16697 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/lib/mcs51/Makefile.in?view=markup }
16698
16699 \end_inset
16700
16701
16702 \end_layout
16703
16704 \end_inset
16705
16706  crtstart.asm
16707 \emph default
16708  and when linking your project explicitely specify 
16709 \emph on
16710 crtstart.rel
16711 \emph default
16712 .
16713  As a bonus a listing of the relocated object file 
16714 \emph on
16715 crtstart.rst
16716 \emph default
16717  is generated.
16718 \end_layout
16719
16720 \begin_layout Standard
16721 \begin_inset VSpace bigskip
16722 \end_inset
16723
16724
16725 \end_layout
16726
16727 \begin_layout Subsection
16728 HC08 Startup Code
16729 \end_layout
16730
16731 \begin_layout Standard
16732 The HC08
16733 \begin_inset LatexCommand \index{HC08}
16734
16735 \end_inset
16736
16737  startup code follows the same scheme as the MCS51 startup code.
16738 \begin_inset VSpace bigskip
16739 \end_inset
16740
16741
16742 \end_layout
16743
16744 \begin_layout Subsection
16745 Z80 Startup Code
16746 \end_layout
16747
16748 \begin_layout Standard
16749 On the Z80
16750 \begin_inset LatexCommand \index{Z80}
16751
16752 \end_inset
16753
16754  the startup code is inserted by linking with crt0.o which is generated from
16755  sdcc/device/lib/z80/crt0.s.
16756  If you need a different startup code you can use the compiler option 
16757 \emph on
16758 -
16759 \series bold
16760 \emph default
16761
16762 \begin_inset ERT
16763 status collapsed
16764
16765 \begin_layout Standard
16766
16767
16768 \backslash
16769 /
16770 \end_layout
16771
16772 \end_inset
16773
16774
16775 \series default
16776 \emph on
16777 -no-std-crt0
16778 \emph default
16779
16780 \begin_inset LatexCommand \index{-\/-no-std-crt0}
16781
16782 \end_inset
16783
16784  and provide your own crt0.o.
16785  
16786 \begin_inset VSpace bigskip
16787 \end_inset
16788
16789
16790 \end_layout
16791
16792 \begin_layout Section
16793 Inline Assembler Code
16794 \begin_inset LatexCommand \index{Assembler routines}
16795
16796 \end_inset
16797
16798
16799 \end_layout
16800
16801 \begin_layout Subsection
16802 A Step by Step Introduction
16803 \begin_inset LatexCommand \label{sub:A-Step-by Assembler Introduction}
16804
16805 \end_inset
16806
16807
16808 \end_layout
16809
16810 \begin_layout Standard
16811 Starting from a small snippet of c-code this example shows for the MCS51
16812  how to use inline assembly, access variables, a function parameter and
16813  an array in xdata memory.
16814  The example uses an MCS51 here but is easily adapted for other architectures.
16815  This is a buffer routine which should be optimized:
16816 \end_layout
16817
16818 \begin_layout Verse
16819
16820 \family typewriter
16821 \size footnotesize
16822 unsigned char __far
16823 \begin_inset LatexCommand \index{far (storage class)}
16824
16825 \end_inset
16826
16827
16828 \begin_inset LatexCommand \index{\_\_far (storage class)}
16829
16830 \end_inset
16831
16832  __at
16833 \begin_inset LatexCommand \index{at}
16834
16835 \end_inset
16836
16837
16838 \begin_inset LatexCommand \index{\_\_at}
16839
16840 \end_inset
16841
16842 (0x7f00) buf[0x100];
16843 \begin_inset LatexCommand \index{Aligned array}
16844
16845 \end_inset
16846
16847
16848 \newline
16849 unsigned char head, tail;\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 \InsetSpace ~
16863 \InsetSpace ~
16864 \InsetSpace ~
16865 \InsetSpace ~
16866 /* if interrupts
16867 \begin_inset LatexCommand \index{interrupt}
16868
16869 \end_inset
16870
16871  are involved see
16872 \newline
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 \InsetSpace ~
16915 \InsetSpace ~
16916 \InsetSpace ~
16917 \InsetSpace ~
16918 section 
16919 \begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
16920
16921 \end_inset
16922
16923  about
16924 \series bold
16925  volatile
16926 \series default
16927  */
16928 \newline
16929
16930 \newline
16931 void to_buffer( unsigned char c ) 
16932 \newline
16933 {
16934 \newline
16935 \InsetSpace ~
16936 \InsetSpace ~
16937 \InsetSpace ~
16938 \InsetSpace ~
16939 if( head != (unsigned char)(tail-1)
16940  )\InsetSpace ~
16941 /* cast 
16942 \series bold
16943 needed
16944 \series default
16945  to avoid promotion
16946 \begin_inset LatexCommand \index{promotion to signed int}
16947
16948 \end_inset
16949
16950
16951 \begin_inset LatexCommand \index{type promotion}
16952
16953 \end_inset
16954
16955  to integer */
16956 \begin_inset Marginal
16957 status collapsed
16958
16959 \begin_layout Standard
16960
16961 \series bold
16962 \InsetSpace ~
16963 !
16964 \end_layout
16965
16966 \end_inset
16967
16968
16969 \newline
16970 \InsetSpace ~
16971 \InsetSpace ~
16972 \InsetSpace ~
16973 \InsetSpace ~
16974 \InsetSpace ~
16975 \InsetSpace ~
16976 \InsetSpace ~
16977 \InsetSpace ~
16978 buf[ head++ ] = c;\InsetSpace ~
16979 \InsetSpace ~
16980 \InsetSpace ~
16981 \InsetSpace ~
16982 \InsetSpace ~
16983 \InsetSpace ~
16984 \InsetSpace ~
16985 \InsetSpace ~
16986 \InsetSpace ~
16987 \InsetSpace ~
16988 \InsetSpace ~
16989 \InsetSpace ~
16990 \InsetSpace ~
16991 \InsetSpace ~
16992 \InsetSpace ~
16993 \InsetSpace ~
16994 /* access to a 256 byte aligned array */
16995 \newline
16996
16997 \end_layout
16998
16999 \begin_layout Standard
17000 If the code snippet (assume it is saved in buffer.c) is compiled with SDCC
17001  then a corresponding buffer.asm file is generated.
17002  We define a new function 
17003 \family typewriter
17004 to_buffer_asm()
17005 \family default
17006  in file buffer.c in which we cut and paste the generated code, removing
17007  unwanted comments and some ':'.
17008  Then add 
17009 \begin_inset Quotes sld
17010 \end_inset
17011
17012
17013 \series bold
17014 _asm
17015 \series default
17016
17017 \begin_inset Quotes srd
17018 \end_inset
17019
17020  and 
17021 \begin_inset Quotes sld
17022 \end_inset
17023
17024
17025 \series bold
17026 _endasm;
17027 \series default
17028
17029 \begin_inset Quotes srd
17030 \end_inset
17031
17032
17033 \begin_inset Foot
17034 status open
17035
17036 \begin_layout Standard
17037 Note, that the single underscore form (_asm and _endasm) are not C99-compatible,
17038  and for C-99 compatibility, the double-underscore form (__asm and __endasm)
17039  has to be used.
17040  The latter is also used in the library functions.
17041 \end_layout
17042
17043 \end_inset
17044
17045  to the beginning and the end of the function body:
17046 \end_layout
17047
17048 \begin_layout Verse
17049
17050 \family typewriter
17051 \size footnotesize
17052 /* With a cut and paste from the .asm file, we have something to start with.
17053 \newline
17054 \InsetSpace ~
17055 \InsetSpace ~
17056 \InsetSpace ~
17057 The
17058  function is not yet OK! (registers aren't saved) */ 
17059 \newline
17060 void to_buffer_asm(
17061  unsigned char c ) 
17062 \newline
17063
17064 \newline
17065 \InsetSpace ~
17066 \InsetSpace ~
17067 \InsetSpace ~
17068 \InsetSpace ~
17069 _asm
17070 \begin_inset LatexCommand \index{\_asm}
17071
17072 \end_inset
17073
17074
17075 \begin_inset LatexCommand \index{\_\_asm}
17076
17077 \end_inset
17078
17079
17080 \newline
17081 \InsetSpace ~
17082 \InsetSpace ~
17083 \InsetSpace ~
17084 \InsetSpace ~
17085 mov\InsetSpace ~
17086 \InsetSpace ~
17087 r2,dpl 
17088 \newline
17089 ;buffer.c if( head != (unsigned char)(tail-1) ) \InsetSpace ~
17090 /* cast 
17091 \series bold
17092 needed
17093 \series default
17094  to avoid promotion
17095 \begin_inset LatexCommand \index{promotion to signed int}
17096
17097 \end_inset
17098
17099
17100 \begin_inset LatexCommand \index{type promotion}
17101
17102 \end_inset
17103
17104  to integer */
17105 \newline
17106 \InsetSpace ~
17107 \InsetSpace ~
17108 \InsetSpace ~
17109 \InsetSpace ~
17110 mov\InsetSpace ~
17111 \InsetSpace ~
17112 a,_tail 
17113 \newline
17114 \InsetSpace ~
17115 \InsetSpace ~
17116 \InsetSpace ~
17117 \InsetSpace ~
17118 dec\InsetSpace ~
17119 \InsetSpace ~
17120
17121 \newline
17122 \InsetSpace ~
17123 \InsetSpace ~
17124 \InsetSpace ~
17125 \InsetSpace ~
17126 mov\InsetSpace ~
17127 \InsetSpace ~
17128 r3,a 
17129 \newline
17130 \InsetSpace ~
17131 \InsetSpace ~
17132 \InsetSpace ~
17133 \InsetSpace ~
17134 mov\InsetSpace ~
17135 \InsetSpace ~
17136 a,_head 
17137 \newline
17138 \InsetSpace ~
17139 \InsetSpace ~
17140 \InsetSpace ~
17141 \InsetSpace ~
17142 cjne a,ar3,00106$ 
17143 \newline
17144 \InsetSpace ~
17145 \InsetSpace ~
17146 \InsetSpace ~
17147 \InsetSpace ~
17148 ret
17149 \newline
17150 00106$:
17151  
17152 \newline
17153 ;buffer.c buf[ head++ ] = c; /* access to a 256 byte aligned array */
17154 \begin_inset LatexCommand \index{Aligned array}
17155
17156 \end_inset
17157
17158
17159 \newline
17160 \InsetSpace ~
17161 \InsetSpace ~
17162 \InsetSpace ~
17163 \InsetSpace ~
17164 mov\InsetSpace ~
17165 \InsetSpace ~
17166 r3,_head 
17167 \newline
17168 \InsetSpace ~
17169 \InsetSpace ~
17170 \InsetSpace ~
17171 \InsetSpace ~
17172 inc\InsetSpace ~
17173 \InsetSpace ~
17174 _head 
17175 \newline
17176 \InsetSpace ~
17177 \InsetSpace ~
17178 \InsetSpace ~
17179 \InsetSpace ~
17180 mov\InsetSpace ~
17181 \InsetSpace ~
17182 dpl,r3 
17183 \newline
17184 \InsetSpace ~
17185 \InsetSpace ~
17186 \InsetSpace ~
17187 \InsetSpace ~
17188 mov\InsetSpace ~
17189 \InsetSpace ~
17190 dph,#(_buf >> 8) 
17191 \newline
17192 \InsetSpace ~
17193 \InsetSpace ~
17194 \InsetSpace ~
17195 \InsetSpace ~
17196 mov\InsetSpace ~
17197 \InsetSpace ~
17198 a,r2 
17199 \newline
17200 \InsetSpace ~
17201 \InsetSpace ~
17202 \InsetSpace ~
17203 \InsetSpace ~
17204 movx @dptr,a
17205  
17206 \newline
17207 00103$: 
17208 \newline
17209 \InsetSpace ~
17210 \InsetSpace ~
17211 \InsetSpace ~
17212 \InsetSpace ~
17213 ret
17214 \newline
17215 \InsetSpace ~
17216 \InsetSpace ~
17217 \InsetSpace ~
17218 \InsetSpace ~
17219 _endasm
17220 \begin_inset LatexCommand \index{\_endasm}
17221
17222 \end_inset
17223
17224
17225 \begin_inset LatexCommand \index{\_\_endasm}
17226
17227 \end_inset
17228
17229 ;
17230 \newline
17231
17232 \end_layout
17233
17234 \begin_layout Standard
17235 The new file buffer.c should compile with only one warning about the unreferenced
17236  function argument 'c'.
17237  Now we hand-optimize the assembly code and insert an #define USE_ASSEMBLY
17238  (1) and finally have:
17239 \end_layout
17240
17241 \begin_layout Verse
17242
17243 \family typewriter
17244 \size footnotesize
17245 unsigned char __far __at(0x7f00) buf[0x100];
17246 \newline
17247 unsigned char head, tail;
17248 \newline
17249 #define
17250  USE_ASSEMBLY (1)
17251 \newline
17252
17253 \newline
17254 #if !USE_ASSEMBLY
17255 \newline
17256
17257 \newline
17258 void to_buffer( unsigned char c )
17259 \newline
17260 {
17261 \newline
17262 \InsetSpace ~
17263 \InsetSpace ~
17264 \InsetSpace ~
17265 \InsetSpace ~
17266 if(
17267  head != (unsigned char)(tail-1) )
17268 \newline
17269 \InsetSpace ~
17270 \InsetSpace ~
17271 \InsetSpace ~
17272 \InsetSpace ~
17273 \InsetSpace ~
17274 \InsetSpace ~
17275 \InsetSpace ~
17276 \InsetSpace ~
17277 buf[ head++ ] = c;
17278 \newline
17279 }
17280 \newline
17281
17282 \newline
17283 #else
17284 \newline
17285
17286 \newline
17287 void to_buffer(
17288  unsigned char c )
17289 \newline
17290 {
17291 \newline
17292 \InsetSpace ~
17293 \InsetSpace ~
17294 \InsetSpace ~
17295 \InsetSpace ~
17296 c; // to avoid warning: unreferenced function argument
17297 \newline
17298 \InsetSpace ~
17299 \InsetSpace ~
17300 \InsetSpace ~
17301 \InsetSpace ~
17302 _asm
17303 \begin_inset LatexCommand \index{\_asm}
17304
17305 \end_inset
17306
17307
17308 \begin_inset LatexCommand \index{\_\_asm}
17309
17310 \end_inset
17311
17312
17313 \newline
17314 \InsetSpace ~
17315 \InsetSpace ~
17316 \InsetSpace ~
17317 \InsetSpace ~
17318 \InsetSpace ~
17319 \InsetSpace ~
17320 \InsetSpace ~
17321 \InsetSpace ~
17322 ; save used registers here.
17323  
17324 \newline
17325 \InsetSpace ~
17326 \InsetSpace ~
17327 \InsetSpace ~
17328 \InsetSpace ~
17329 \InsetSpace ~
17330 \InsetSpace ~
17331 \InsetSpace ~
17332 \InsetSpace ~
17333 ; If we were still using r2,r3 we would have to push them here.
17334  
17335 \newline
17336 ; if( head != (unsigned char)(tail-1) )
17337 \newline
17338 \InsetSpace ~
17339 \InsetSpace ~
17340 \InsetSpace ~
17341 \InsetSpace ~
17342 \InsetSpace ~
17343 \InsetSpace ~
17344 \InsetSpace ~
17345 \InsetSpace ~
17346 mov\InsetSpace ~
17347  a,_tail
17348 \newline
17349 \InsetSpace ~
17350 \InsetSpace ~
17351 \InsetSpace ~
17352 \InsetSpace ~
17353 \InsetSpace ~
17354 \InsetSpace ~
17355 \InsetSpace ~
17356 \InsetSpace ~
17357 dec\InsetSpace ~
17358  a
17359 \newline
17360 \InsetSpace ~
17361 \InsetSpace ~
17362 \InsetSpace ~
17363 \InsetSpace ~
17364 \InsetSpace ~
17365 \InsetSpace ~
17366 \InsetSpace ~
17367 \InsetSpace ~
17368 xrl\InsetSpace ~
17369  a,_head
17370 \newline
17371 \InsetSpace ~
17372 \InsetSpace ~
17373 \InsetSpace ~
17374 \InsetSpace ~
17375 \InsetSpace ~
17376 \InsetSpace ~
17377 \InsetSpace ~
17378 \InsetSpace ~
17379 ; we
17380  could do an ANL a,#0x0f here to use a smaller buffer (see below)
17381 \newline
17382 \InsetSpace ~
17383 \InsetSpace ~
17384 \InsetSpace ~
17385 \InsetSpace ~
17386 \InsetSpace ~
17387 \InsetSpace ~
17388 \InsetSpace ~
17389 \InsetSpace ~
17390 jz\InsetSpace ~
17391 \InsetSpace ~
17392  t_b_end$
17393 \newline
17394 \InsetSpace ~
17395 \InsetSpace ~
17396 \InsetSpace ~
17397 \InsetSpace ~
17398 \InsetSpace ~
17399 \InsetSpace ~
17400 \InsetSpace ~
17401 \InsetSpace ~
17402 ;
17403 \newline
17404 ;
17405  buf[ head++ ] = c;
17406 \newline
17407 \InsetSpace ~
17408 \InsetSpace ~
17409 \InsetSpace ~
17410 \InsetSpace ~
17411 \InsetSpace ~
17412 \InsetSpace ~
17413 \InsetSpace ~
17414 \InsetSpace ~
17415 mov\InsetSpace ~
17416  a,dpl \InsetSpace ~
17417 \InsetSpace ~
17418 \InsetSpace ~
17419 \InsetSpace ~
17420 \InsetSpace ~
17421 \InsetSpace ~
17422 \InsetSpace ~
17423 ; dpl holds lower byte of function argument
17424 \newline
17425 \InsetSpace ~
17426 \InsetSpace ~
17427 \InsetSpace ~
17428 \InsetSpace ~
17429 \InsetSpace ~
17430 \InsetSpace ~
17431 \InsetSpace ~
17432 \InsetSpace ~
17433 mov\InsetSpace ~
17434
17435  dpl,_head \InsetSpace ~
17436 \InsetSpace ~
17437 \InsetSpace ~
17438 ; buf is 0x100 byte aligned so head can be used directly
17439 \newline
17440 \InsetSpace ~
17441 \InsetSpace ~
17442 \InsetSpace ~
17443 \InsetSpace ~
17444 \InsetSpace ~
17445 \InsetSpace ~
17446 \InsetSpace ~
17447 \InsetSpace ~
17448 mov\InsetSpace ~
17449  dph,#(_bu
17450 f>>8)
17451 \newline
17452 \InsetSpace ~
17453 \InsetSpace ~
17454 \InsetSpace ~
17455 \InsetSpace ~
17456 \InsetSpace ~
17457 \InsetSpace ~
17458 \InsetSpace ~
17459 \InsetSpace ~
17460 movx @dptr,a
17461 \newline
17462 \InsetSpace ~
17463 \InsetSpace ~
17464 \InsetSpace ~
17465 \InsetSpace ~
17466 \InsetSpace ~
17467 \InsetSpace ~
17468 \InsetSpace ~
17469 \InsetSpace ~
17470 inc \InsetSpace ~
17471 _head
17472 \newline
17473 \InsetSpace ~
17474 \InsetSpace ~
17475 \InsetSpace ~
17476 \InsetSpace ~
17477 \InsetSpace ~
17478 \InsetSpace ~
17479 \InsetSpace ~
17480 \InsetSpace ~
17481 ; we could do an ANL _head,#0x0f here to use a
17482  smaller buffer (see above)
17483 \newline
17484 t_b_end$:
17485 \newline
17486 \InsetSpace ~
17487 \InsetSpace ~
17488 \InsetSpace ~
17489 \InsetSpace ~
17490 \InsetSpace ~
17491 \InsetSpace ~
17492 \InsetSpace ~
17493 \InsetSpace ~
17494 ; restore used registers here 
17495 \newline
17496 \InsetSpace ~
17497 \InsetSpace ~
17498 \InsetSpace ~
17499 \InsetSpace ~
17500 _endasm
17501 \begin_inset LatexCommand \index{\_endasm}
17502
17503 \end_inset
17504
17505
17506 \begin_inset LatexCommand \index{\_\_endasm}
17507
17508 \end_inset
17509
17510 ;
17511 \newline
17512 }
17513 \newline
17514 #endif
17515 \end_layout
17516
17517 \begin_layout Standard
17518 The inline assembler code can contain any valid code understood by the assembler
17519 , this includes any assembler directives and comment lines.
17520  The assembler does not like some characters like ':' or ''' in comments.
17521  You'll find an 100+ pages assembler manual in sdcc/as/doc/asxhtm.html
17522 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
17523
17524 \end_inset
17525
17526
17527 \begin_inset LatexCommand \index{Assembler documentation}
17528
17529 \end_inset
17530
17531  or online at 
17532 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
17533
17534 \end_inset
17535
17536 \InsetSpace ~
17537 .
17538 \end_layout
17539
17540 \begin_layout Standard
17541 The compiler does not do any validation of the code within the 
17542 \family typewriter
17543 _asm
17544 \begin_inset LatexCommand \index{\_asm}
17545
17546 \end_inset
17547
17548
17549 \begin_inset LatexCommand \index{\_\_asm}
17550
17551 \end_inset
17552
17553  ...
17554  _endasm
17555 \size footnotesize
17556
17557 \begin_inset LatexCommand \index{\_endasm}
17558
17559 \end_inset
17560
17561
17562 \begin_inset LatexCommand \index{\_\_endasm}
17563
17564 \end_inset
17565
17566
17567 \size default
17568 ;
17569 \family default
17570  keyword pair.
17571  Specifically it will not know which registers are used and thus register
17572  pushing/popping
17573 \begin_inset LatexCommand \index{push/pop}
17574
17575 \end_inset
17576
17577  has to be done manually.
17578  
17579 \end_layout
17580
17581 \begin_layout Standard
17582 It is recommended that each assembly instruction (including labels) be placed
17583  in a separate line (as the example shows).
17584  When the -
17585 \begin_inset ERT
17586 status collapsed
17587
17588 \begin_layout Standard
17589
17590
17591 \backslash
17592 /
17593 \end_layout
17594
17595 \end_inset
17596
17597 -
17598 \emph on
17599 peep-asm
17600 \begin_inset LatexCommand \index{-\/-peep-asm}
17601
17602 \end_inset
17603
17604
17605 \emph default
17606  command line option is used, the inline assembler code will be passed through
17607  the peephole optimizer
17608 \begin_inset LatexCommand \index{Peephole optimizer}
17609
17610 \end_inset
17611
17612 .
17613  There are only a few (if any) cases where this option makes sense, it might
17614  cause some unexpected changes in the inline assembler code.
17615  Please go through the peephole optimizer rules defined in file 
17616 \emph on
17617 SDCCpeeph.def
17618 \emph default
17619  before using this option.
17620 \end_layout
17621
17622 \begin_layout Subsection
17623 Naked Functions
17624 \begin_inset LatexCommand \label{sub:Naked-Functions}
17625
17626 \end_inset
17627
17628
17629 \begin_inset LatexCommand \index{Naked functions}
17630
17631 \end_inset
17632
17633
17634 \end_layout
17635
17636 \begin_layout Standard
17637 A special keyword may be associated with a function declaring it as 
17638 \emph on
17639 _naked
17640 \begin_inset LatexCommand \index{\_naked}
17641
17642 \end_inset
17643
17644
17645 \begin_inset LatexCommand \index{\_\_naked}
17646
17647 \end_inset
17648
17649 .
17650  
17651 \emph default
17652 The 
17653 \emph on
17654 _naked
17655 \emph default
17656  function modifier attribute prevents the compiler from generating prologue
17657 \begin_inset LatexCommand \index{function prologue}
17658
17659 \end_inset
17660
17661  and epilogue
17662 \begin_inset LatexCommand \index{function epilogue}
17663
17664 \end_inset
17665
17666  code for that function.
17667  This means that the user is entirely responsible for such things as saving
17668  any registers that may need to be preserved, selecting the proper register
17669  bank, generating the 
17670 \emph on
17671 return
17672 \emph default
17673  instruction at the end, etc.
17674  Practically, this means that the contents of the function must be written
17675  in inline assembler.
17676  This is particularly useful for interrupt functions, which can have a large
17677  (and often unnecessary) prologue/epilogue.
17678  For example, compare the code generated by these two functions:
17679 \end_layout
17680
17681 \begin_layout Verse
17682
17683 \family typewriter
17684 volatile
17685 \begin_inset LatexCommand \index{volatile}
17686
17687 \end_inset
17688
17689  data unsigned char counter;
17690 \newline
17691
17692 \newline
17693 void simpleInterrupt(void) __interrupt
17694 \begin_inset LatexCommand \index{interrupt}
17695
17696 \end_inset
17697
17698
17699 \begin_inset LatexCommand \index{\_\_interrupt}
17700
17701 \end_inset
17702
17703  (1)
17704 \newline
17705 {
17706 \newline
17707 \InsetSpace ~
17708 \InsetSpace ~
17709 \InsetSpace ~
17710 \InsetSpace ~
17711 counter++;
17712 \newline
17713 }
17714 \newline
17715
17716 \newline
17717 void nakedInterrupt(void) __interrupt (2) __naked
17718 \newline
17719 {
17720 \newline
17721 \InsetSpace ~
17722 \InsetSpace ~
17723 \InsetSpace ~
17724 \InsetSpace ~
17725 _asm
17726 \begin_inset LatexCommand \index{\_asm}
17727
17728 \end_inset
17729
17730
17731 \begin_inset LatexCommand \index{\_\_asm}
17732
17733 \end_inset
17734
17735
17736 \newline
17737 \InsetSpace ~
17738 \InsetSpace ~
17739 \InsetSpace ~
17740 \InsetSpace ~
17741 \InsetSpace ~
17742 \InsetSpace ~
17743 inc\InsetSpace ~
17744 \InsetSpace ~
17745 \InsetSpace ~
17746 \InsetSpace ~
17747 \InsetSpace ~
17748 _counter ; does not change flags, no need to save psw
17749 \newline
17750 \InsetSpace ~
17751 \InsetSpace ~
17752 \InsetSpace ~
17753 \InsetSpace ~
17754 \InsetSpace ~
17755 \InsetSpace ~
17756 reti\InsetSpace ~
17757 \InsetSpace ~
17758 \InsetSpace ~
17759 \InsetSpace ~
17760 ; MUST explicitly
17761  include ret or reti in _naked function.
17762 \newline
17763 \InsetSpace ~
17764 \InsetSpace ~
17765 \InsetSpace ~
17766 \InsetSpace ~
17767 _endasm
17768 \begin_inset LatexCommand \index{\_endasm}
17769
17770 \end_inset
17771
17772
17773 \begin_inset LatexCommand \index{\_\_endasm}
17774
17775 \end_inset
17776
17777 ;
17778 \newline
17779 }
17780 \end_layout
17781
17782 \begin_layout Standard
17783 For an 8051 target, the generated simpleInterrupt looks like:
17784 \end_layout
17785
17786 \begin_layout Verse
17787
17788 \family typewriter
17789 Note, this is an 
17790 \emph on
17791 outdated
17792 \emph default
17793  example, recent versions of SDCC generate
17794 \newline
17795 the 
17796 \emph on
17797 same
17798 \emph default
17799  code for simpleInterrupt() and nakedInterrupt()!
17800 \newline
17801
17802 \newline
17803 _simpleInterrupt:
17804 \newline
17805 \InsetSpace ~
17806 \InsetSpace ~
17807 \InsetSpace ~
17808 \InsetSpace ~
17809 push\InsetSpace ~
17810 \InsetSpace ~
17811 \InsetSpace ~
17812 \InsetSpace ~
17813 acc
17814 \newline
17815 \InsetSpace ~
17816 \InsetSpace ~
17817 \InsetSpace ~
17818 \InsetSpace ~
17819 push\InsetSpace ~
17820 \InsetSpace ~
17821 \InsetSpace ~
17822 \InsetSpace ~
17823 b
17824 \newline
17825 \InsetSpace ~
17826 \InsetSpace ~
17827 \InsetSpace ~
17828 \InsetSpace ~
17829 pu
17830 sh\InsetSpace ~
17831 \InsetSpace ~
17832 \InsetSpace ~
17833 \InsetSpace ~
17834 dpl
17835 \newline
17836 \InsetSpace ~
17837 \InsetSpace ~
17838 \InsetSpace ~
17839 \InsetSpace ~
17840 push\InsetSpace ~
17841 \InsetSpace ~
17842 \InsetSpace ~
17843 \InsetSpace ~
17844 dph
17845 \newline
17846 \InsetSpace ~
17847 \InsetSpace ~
17848 \InsetSpace ~
17849 \InsetSpace ~
17850 push\InsetSpace ~
17851 \InsetSpace ~
17852 \InsetSpace ~
17853 \InsetSpace ~
17854 psw
17855 \newline
17856 \InsetSpace ~
17857 \InsetSpace ~
17858 \InsetSpace ~
17859 \InsetSpace ~
17860 mov\InsetSpace ~
17861 \InsetSpace ~
17862 \InsetSpace ~
17863 \InsetSpace ~
17864 \InsetSpace ~
17865 psw,#0x00
17866 \newline
17867 \InsetSpace ~
17868 \InsetSpace ~
17869 \InsetSpace ~
17870 \InsetSpace ~
17871 inc\InsetSpace ~
17872 \InsetSpace ~
17873 \InsetSpace ~
17874 \InsetSpace ~
17875 \InsetSpace ~
17876 _counter
17877 \newline
17878 \InsetSpace ~
17879 \InsetSpace ~
17880 \InsetSpace ~
17881 \InsetSpace ~
17882 pop\InsetSpace ~
17883 \InsetSpace ~
17884 \InsetSpace ~
17885 \InsetSpace ~
17886 \InsetSpace ~
17887 psw
17888 \newline
17889 \InsetSpace ~
17890 \InsetSpace ~
17891 \InsetSpace ~
17892 \InsetSpace ~
17893 pop\InsetSpace ~
17894 \InsetSpace ~
17895 \InsetSpace ~
17896 \InsetSpace ~
17897 \InsetSpace ~
17898 dph
17899 \newline
17900 \InsetSpace ~
17901 \InsetSpace ~
17902 \InsetSpace ~
17903 \InsetSpace ~
17904 pop\InsetSpace ~
17905 \InsetSpace ~
17906 \InsetSpace ~
17907 \InsetSpace ~
17908 \InsetSpace ~
17909 dpl
17910 \newline
17911 \InsetSpace ~
17912 \InsetSpace ~
17913 \InsetSpace ~
17914 \InsetSpace ~
17915 pop\InsetSpace ~
17916 \InsetSpace ~
17917 \InsetSpace ~
17918 \InsetSpace ~
17919 \InsetSpace ~
17920 b
17921 \newline
17922 \InsetSpace ~
17923 \InsetSpace ~
17924 \InsetSpace ~
17925 \InsetSpace ~
17926 pop\InsetSpace ~
17927 \InsetSpace ~
17928 \InsetSpace ~
17929 \InsetSpace ~
17930 \InsetSpace ~
17931 acc
17932 \newline
17933 \InsetSpace ~
17934 \InsetSpace ~
17935 \InsetSpace ~
17936 \InsetSpace ~
17937 reti
17938 \end_layout
17939
17940 \begin_layout Standard
17941 whereas nakedInterrupt looks like:
17942 \end_layout
17943
17944 \begin_layout Verse
17945
17946 \family typewriter
17947 _nakedInterrupt:
17948 \newline
17949 \InsetSpace ~
17950 \InsetSpace ~
17951 \InsetSpace ~
17952 \InsetSpace ~
17953 inc\InsetSpace ~
17954 \InsetSpace ~
17955 \InsetSpace ~
17956 \InsetSpace ~
17957 _counter ; does not change flags, no need to save psw
17958 \newline
17959 \InsetSpace ~
17960 \InsetSpace ~
17961 \InsetSpace ~
17962 \InsetSpace ~
17963 reti\InsetSpace ~
17964 \InsetSpace ~
17965 \InsetSpace ~
17966 \InsetSpace ~
17967 \InsetSpace ~
17968 \InsetSpace ~
17969 \InsetSpace ~
17970 \InsetSpace ~
17971 \InsetSpace ~
17972 \InsetSpace ~
17973 \InsetSpace ~
17974 \InsetSpace ~
17975 ;
17976  MUST explicitly include ret or reti in _naked function
17977 \end_layout
17978
17979 \begin_layout Standard
17980 The related directive #pragma exclude
17981 \begin_inset LatexCommand \index{\#pragma exclude}
17982
17983 \end_inset
17984
17985  allows a more fine grained control over pushing & popping
17986 \begin_inset LatexCommand \index{push/pop}
17987
17988 \end_inset
17989
17990  the registers.
17991 \end_layout
17992
17993 \begin_layout Standard
17994 While there is nothing preventing you from writing C code inside a 
17995 \family typewriter
17996 _naked
17997 \family default
17998  function, there are many ways to shoot yourself in the foot doing this,
17999  and it is recommended that you stick to inline assembler.
18000 \end_layout
18001
18002 \begin_layout Subsection
18003 Use of Labels within Inline Assembler
18004 \end_layout
18005
18006 \begin_layout Standard
18007 SDCC allows the use of in-line assembler with a few restrictions regarding
18008  labels.
18009  All labels defined within inline assembler code have to be of the form
18010  
18011 \emph on
18012 nnnnn$
18013 \emph default
18014  where nnnnn is a number less than 100 (which implies a limit of utmost
18015  100 inline assembler labels 
18016 \emph on
18017 per function
18018 \emph default
18019 \noun on
18020 )
18021 \noun default
18022 .
18023 \begin_inset Foot
18024 status open
18025
18026 \begin_layout Standard
18027 This is a slightly more stringent rule than absolutely necessary, but stays
18028  always on the safe side.
18029  Labels in the form of nnnnn$ are local labels in the assembler, locality
18030  of which is confined within two labels of the standard form.
18031  The compiler uses the same form for labels within a function (but starting
18032  from nnnnn=00100); and places always a standard label at the beginning
18033  of a function, thus limiting the locality of labels within the scope of
18034  the function.
18035  So, if the inline assembler part would be embedded into C-code, an improperly
18036  placed non-local label in the assembler would break up the reference space
18037  for labels created by the compiler for the C-code, leading to an assembling
18038  error.
18039 \end_layout
18040
18041 \begin_layout Standard
18042 The numeric part of local labels does not need to have 5 digits (although
18043  this is the form of labels output by the compiler), any valid integer will
18044  do.
18045  Please refer to the assemblers documentation for further details.
18046 \end_layout
18047
18048 \end_inset
18049
18050  
18051 \end_layout
18052
18053 \begin_layout Verse
18054
18055 \family typewriter
18056 _asm
18057 \begin_inset LatexCommand \index{\_asm}
18058
18059 \end_inset
18060
18061
18062 \begin_inset LatexCommand \index{\_\_asm}
18063
18064 \end_inset
18065
18066  
18067 \newline
18068 \InsetSpace ~
18069 \InsetSpace ~
18070 \InsetSpace ~
18071 \InsetSpace ~
18072 mov\InsetSpace ~
18073 \InsetSpace ~
18074 \InsetSpace ~
18075 \InsetSpace ~
18076 \InsetSpace ~
18077 b,#10 
18078 \newline
18079 00001$: 
18080 \newline
18081 \InsetSpace ~
18082 \InsetSpace ~
18083 \InsetSpace ~
18084 \InsetSpace ~
18085 djnz\InsetSpace ~
18086 \InsetSpace ~
18087 \InsetSpace ~
18088 \InsetSpace ~
18089 b,00001$ 
18090 \newline
18091 _endasm
18092 \begin_inset LatexCommand \index{\_endasm}
18093
18094 \end_inset
18095
18096
18097 \begin_inset LatexCommand \index{\_\_endasm}
18098
18099 \end_inset
18100
18101  ;
18102 \end_layout
18103
18104 \begin_layout Standard
18105 Inline assembler code cannot reference any C-labels, however it can reference
18106  labels
18107 \begin_inset LatexCommand \index{Labels}
18108
18109 \end_inset
18110
18111  defined by the inline assembler, e.g.:
18112 \end_layout
18113
18114 \begin_layout Verse
18115
18116 \family typewriter
18117 foo() { 
18118 \newline
18119 \InsetSpace ~
18120 \InsetSpace ~
18121 \InsetSpace ~
18122 \InsetSpace ~
18123 /* some c code */ 
18124 \newline
18125 \InsetSpace ~
18126 \InsetSpace ~
18127 \InsetSpace ~
18128 \InsetSpace ~
18129 _asm 
18130 \newline
18131 \InsetSpace ~
18132 \InsetSpace ~
18133 \InsetSpace ~
18134 \InsetSpace ~
18135 \InsetSpace ~
18136 \InsetSpace ~
18137 ; some assembler code 
18138 \newline
18139 \InsetSpace ~
18140 \InsetSpace ~
18141 \InsetSpace ~
18142 \InsetSpace ~
18143 \InsetSpace ~
18144 \InsetSpace ~
18145 ljmp 0003$ 
18146 \newline
18147 \InsetSpace ~
18148 \InsetSpace ~
18149 \InsetSpace ~
18150 \InsetSpace ~
18151 _endasm;
18152  
18153 \newline
18154 \InsetSpace ~
18155 \InsetSpace ~
18156 \InsetSpace ~
18157 \InsetSpace ~
18158 /* some more c code */ 
18159 \newline
18160 clabel:\InsetSpace ~
18161 \InsetSpace ~
18162 /* inline assembler cannot reference this
18163  label */ 
18164 \begin_inset Foot
18165 status open
18166
18167 \begin_layout Standard
18168 Here, the C-label 
18169 \family typewriter
18170 clabel
18171 \family default
18172  is translated by the compiler into a local label, so the locality of labels
18173  within the function is not broken.
18174 \end_layout
18175
18176 \end_inset
18177
18178
18179 \newline
18180 \InsetSpace ~
18181 \InsetSpace ~
18182 \InsetSpace ~
18183 \InsetSpace ~
18184 _asm
18185 \newline
18186 \InsetSpace ~
18187 \InsetSpace ~
18188 \InsetSpace ~
18189 \InsetSpace ~
18190 0003$: ;label (can be referenced by inline assembler only) 
18191 \newline
18192 \InsetSpace ~
18193 \InsetSpace ~
18194 \InsetSpace ~
18195 \InsetSpace ~
18196 _endasm
18197 \begin_inset LatexCommand \index{\_endasm}
18198
18199 \end_inset
18200
18201
18202 \begin_inset LatexCommand \index{\_\_endasm}
18203
18204 \end_inset
18205
18206  ; 
18207 \newline
18208 \InsetSpace ~
18209 \InsetSpace ~
18210 \InsetSpace ~
18211 \InsetSpace ~
18212 /* some more c code */
18213 \newline
18214 }
18215 \end_layout
18216
18217 \begin_layout Standard
18218 In other words inline assembly code can access labels defined in inline
18219  assembly within the scope of the function.
18220  The same goes the other way, i.e.
18221  labels defines in inline assembly can not be accessed by C statements.
18222 \end_layout
18223
18224 \begin_layout Section
18225 Interfacing with Assembler Code
18226 \begin_inset LatexCommand \index{Assembler routines}
18227
18228 \end_inset
18229
18230
18231 \end_layout
18232
18233 \begin_layout Subsection
18234 Global Registers used for Parameter Passing
18235 \begin_inset LatexCommand \index{Parameter passing}
18236
18237 \end_inset
18238
18239
18240 \end_layout
18241
18242 \begin_layout Standard
18243 The compiler always uses the global registers 
18244 \emph on
18245 DPL, DPH
18246 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
18247
18248 \end_inset
18249
18250
18251 \begin_inset LatexCommand \index{DPTR}
18252
18253 \end_inset
18254
18255 , B
18256 \begin_inset LatexCommand \index{B (mcs51, ds390 register)}
18257
18258 \end_inset
18259
18260  
18261 \emph default
18262 and
18263 \emph on
18264  ACC
18265 \begin_inset LatexCommand \index{ACC (mcs51, ds390 register)}
18266
18267 \end_inset
18268
18269
18270 \emph default
18271  to pass the first (non-bit) parameter to a function, and also to pass the
18272  return value 
18273 \begin_inset LatexCommand \index{return value}
18274
18275 \end_inset
18276
18277 of function; according to the following scheme: one byte return value in
18278  
18279 \emph on
18280 DPL
18281 \emph default
18282 , two byte value in 
18283 \emph on
18284 DPL
18285 \emph default
18286  (LSB) and 
18287 \emph on
18288 DPH
18289 \emph default
18290  (MSB).
18291  three byte values (generic pointers) in 
18292 \emph on
18293 DPH
18294 \emph default
18295
18296 \emph on
18297 DPL
18298 \emph default
18299  and 
18300 \emph on
18301 B
18302 \emph default
18303 , and four byte values in 
18304 \emph on
18305 DPH
18306 \emph default
18307
18308 \emph on
18309 DPL
18310 \emph default
18311 ,
18312 \emph on
18313  B
18314 \emph default
18315  and 
18316 \emph on
18317 ACC
18318 \emph default
18319 .
18320  Generic pointers
18321 \begin_inset LatexCommand \index{generic pointer}
18322
18323 \end_inset
18324
18325  contain type of accessed memory in 
18326 \emph on
18327 B
18328 \emph default
18329
18330 \series bold
18331 0x00
18332 \series default
18333  -- xdata/far, 
18334 \series bold
18335 0x40
18336 \series default
18337  -- idata/near -- , 
18338 \series bold
18339 0x60
18340 \series default
18341  -- pdata, 
18342 \series bold
18343 0x80
18344 \series default
18345  -- code
18346 \begin_inset Note Note
18347 status collapsed
18348
18349 \begin_layout Standard
18350 This might not be the case of certain memory models (medium???)
18351 \end_layout
18352
18353 \end_inset
18354
18355 .
18356 \end_layout
18357
18358 \begin_layout Standard
18359 The second parameter onwards is either allocated on the stack (for reentrant
18360  routines or if -
18361 \begin_inset ERT
18362 status collapsed
18363
18364 \begin_layout Standard
18365
18366
18367 \backslash
18368 /
18369 \end_layout
18370
18371 \end_inset
18372
18373 -stack-auto is used) or in data/xdata memory (depending on the memory model).
18374 \end_layout
18375
18376 \begin_layout Standard
18377 Bit parameters are passed in a virtual register called 'bits' in bit-addressable
18378  space for reentrant functions or allocated directly in bit memory otherwise.
18379 \end_layout
18380
18381 \begin_layout Standard
18382 Functions (with two or more parameters or bit parameters) that are called
18383  through function pointers
18384 \begin_inset LatexCommand \index{function pointers}
18385
18386 \end_inset
18387
18388  must therefor be reentrant so the compiler knows how to pass the parameters.
18389 \end_layout
18390
18391 \begin_layout Subsection
18392 Registers usage
18393 \end_layout
18394
18395 \begin_layout Standard
18396 Unless the called function is declared as 
18397 \family typewriter
18398 _naked
18399 \family default
18400
18401 \begin_inset LatexCommand \index{naked}
18402
18403 \end_inset
18404
18405 , or the -
18406 \begin_inset ERT
18407 status collapsed
18408
18409 \begin_layout Standard
18410
18411
18412 \backslash
18413 /
18414 \end_layout
18415
18416 \end_inset
18417
18418 -callee-saves
18419 \begin_inset LatexCommand \index{-\/-callee-saves}
18420
18421 \end_inset
18422
18423 /-
18424 \begin_inset ERT
18425 status collapsed
18426
18427 \begin_layout Standard
18428
18429
18430 \backslash
18431 /
18432 \end_layout
18433
18434 \end_inset
18435
18436 -all-callee-saves command line option or the corresponding callee_saves
18437  pragma are used, the caller will save the registers (
18438 \emph on
18439 R0-R7
18440 \emph default
18441 ) around the call, so the called function can destroy they content freely.
18442 \end_layout
18443
18444 \begin_layout Standard
18445 If the called function is not declared as 
18446 \family typewriter
18447 _naked
18448 \family default
18449 , the caller will swap register banks around the call, if caller and callee
18450  use different register banks (having them defined by the 
18451 \family typewriter
18452 _using
18453 \family default
18454  modifier).
18455  
18456 \end_layout
18457
18458 \begin_layout Standard
18459 The called function can also use 
18460 \emph on
18461 DPL
18462 \emph default
18463
18464 \emph on
18465 DPH
18466 \emph default
18467
18468 \emph on
18469 B
18470 \emph default
18471  and 
18472 \emph on
18473 ACC
18474 \emph default
18475  observing that they are used for parameter/return value passing.
18476 \end_layout
18477
18478 \begin_layout Subsection
18479 Assembler Routine (non-reentrant)
18480 \end_layout
18481
18482 \begin_layout Standard
18483 In the following example
18484 \begin_inset LatexCommand \index{reentrant}
18485
18486 \end_inset
18487
18488
18489 \begin_inset LatexCommand \index{Assembler routines (non-reentrant)}
18490
18491 \end_inset
18492
18493  the function c_func calls an assembler routine asm_func, which takes two
18494  parameters
18495 \begin_inset LatexCommand \index{function parameter}
18496
18497 \end_inset
18498
18499 .
18500 \end_layout
18501
18502 \begin_layout Verse
18503
18504 \family typewriter
18505 extern int asm_func(unsigned char, unsigned char);
18506 \newline
18507
18508 \newline
18509 int c_func (unsigned char
18510  i, unsigned char j)
18511 \newline
18512 {
18513 \newline
18514 \InsetSpace ~
18515 \InsetSpace ~
18516 \InsetSpace ~
18517 \InsetSpace ~
18518 return asm_func(i,j);
18519 \newline
18520 }
18521 \newline
18522
18523 \newline
18524 int main()
18525 \newline
18526 {
18527 \newline
18528 \InsetSpace ~
18529 \InsetSpace ~
18530 \InsetSpace ~
18531 \InsetSpace ~
18532 return c_func(10,9);
18533 \newline
18534 }
18535 \end_layout
18536
18537 \begin_layout Standard
18538 The corresponding assembler function is:
18539 \end_layout
18540
18541 \begin_layout Verse
18542
18543 \family typewriter
18544 .globl _asm_func_PARM_2 
18545 \newline
18546 \InsetSpace ~
18547 \InsetSpace ~
18548 \InsetSpace ~
18549 \InsetSpace ~
18550 \InsetSpace ~
18551 \InsetSpace ~
18552 \InsetSpace ~
18553 \InsetSpace ~
18554 .globl _asm_func 
18555 \newline
18556 \InsetSpace ~
18557 \InsetSpace ~
18558 \InsetSpace ~
18559 \InsetSpace ~
18560 \InsetSpace ~
18561 \InsetSpace ~
18562 \InsetSpace ~
18563 \InsetSpace ~
18564 .area OSEG 
18565 \newline
18566 _asm_func_PARM_2:
18567 \newline
18568 \InsetSpace ~
18569 \InsetSpace ~
18570 \InsetSpace ~
18571 \InsetSpace ~
18572 \InsetSpace ~
18573 \InsetSpace ~
18574 \InsetSpace ~
18575 \InsetSpace ~
18576 .ds   
18577  1 
18578 \newline
18579 \InsetSpace ~
18580 \InsetSpace ~
18581 \InsetSpace ~
18582 \InsetSpace ~
18583 \InsetSpace ~
18584 \InsetSpace ~
18585 \InsetSpace ~
18586 \InsetSpace ~
18587 .area CSEG 
18588 \newline
18589 _asm_func: 
18590 \newline
18591 \InsetSpace ~
18592 \InsetSpace ~
18593 \InsetSpace ~
18594 \InsetSpace ~
18595 \InsetSpace ~
18596 \InsetSpace ~
18597 \InsetSpace ~
18598 \InsetSpace ~
18599 mov\InsetSpace ~
18600 \InsetSpace ~
18601 \InsetSpace ~
18602 \InsetSpace ~
18603 a,dpl 
18604 \newline
18605 \InsetSpace ~
18606 \InsetSpace ~
18607 \InsetSpace ~
18608 \InsetSpace ~
18609 \InsetSpace ~
18610 \InsetSpace ~
18611 \InsetSpace ~
18612 \InsetSpace ~
18613 add\InsetSpace ~
18614 \InsetSpace ~
18615 \InsetSpace ~
18616 \InsetSpace ~
18617 a,_asm_func_PARM_2 
18618 \newline
18619 \InsetSpace ~
18620 \InsetSpace ~
18621 \InsetSpace ~
18622 \InsetSpace ~
18623 \InsetSpace ~
18624 \InsetSpace ~
18625 \InsetSpace ~
18626 \InsetSpace ~
18627 mov\InsetSpace ~
18628 \InsetSpace ~
18629 \InsetSpace ~
18630 \InsetSpace ~
18631 dpl,a 
18632 \newline
18633 \InsetSpace ~
18634 \InsetSpace ~
18635 \InsetSpace ~
18636 \InsetSpace ~
18637 \InsetSpace ~
18638 \InsetSpace ~
18639 \InsetSpace ~
18640 \InsetSpace ~
18641 mov\InsetSpace ~
18642 \InsetSpace ~
18643 \InsetSpace ~
18644 \InsetSpace ~
18645 dph
18646 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
18647
18648 \end_inset
18649
18650 ,#0x00 
18651 \newline
18652 \InsetSpace ~
18653 \InsetSpace ~
18654 \InsetSpace ~
18655 \InsetSpace ~
18656 \InsetSpace ~
18657 \InsetSpace ~
18658 \InsetSpace ~
18659 \InsetSpace ~
18660 ret
18661 \end_layout
18662
18663 \begin_layout Standard
18664 The parameter naming convention is _<function_name>_PARM_<n>, where n is
18665  the parameter number starting from 1, and counting from the left.
18666  The first parameter is passed in 
18667 \emph on
18668 DPH
18669 \emph default
18670
18671 \emph on
18672 DPL
18673 \emph default
18674
18675 \emph on
18676 B
18677 \emph default
18678  and 
18679 \emph on
18680 ACC
18681 \emph default
18682  according to the description above.
18683  The variable name for the second parameter will be _<function_name>_PARM_2.
18684 \newline
18685
18686 \newline
18687 Assem
18688 ble the assembler routine with the following command:
18689 \newline
18690
18691 \newline
18692
18693 \family sans
18694 \series bold
18695 asx8051 -losg asmfunc.asm
18696 \newline
18697
18698 \newline
18699
18700 \family default
18701 \series default
18702 Then compile and link the assembler routine to the C source file with the
18703  following command:
18704 \newline
18705
18706 \newline
18707
18708 \family sans
18709 \series bold
18710 sdcc cfunc.c asmfunc.rel
18711 \end_layout
18712
18713 \begin_layout Subsection
18714 Assembler Routine (reentrant)
18715 \end_layout
18716
18717 \begin_layout Standard
18718 In this case
18719 \begin_inset LatexCommand \index{reentrant}
18720
18721 \end_inset
18722
18723
18724 \begin_inset LatexCommand \index{Assembler routines (reentrant)}
18725
18726 \end_inset
18727
18728  the second parameter
18729 \begin_inset LatexCommand \index{function parameter}
18730
18731 \end_inset
18732
18733  onwards will be passed on the stack, the parameters are pushed from right
18734  to left i.e.
18735  before the call the second leftmost parameter will be on the top of the
18736  stack (the leftmost parameter is passed in registers).
18737  Here is an example:
18738 \end_layout
18739
18740 \begin_layout Verse
18741
18742 \family typewriter
18743 extern int asm_func(unsigned char, unsigned char, unsigned char) reentrant;
18744 \newline
18745
18746 \newline
18747 int
18748  c_func (unsigned char i, unsigned char j, unsigned char k) reentrant 
18749 \newline
18750 {
18751  
18752 \newline
18753 \InsetSpace ~
18754 \InsetSpace ~
18755 \InsetSpace ~
18756 \InsetSpace ~
18757 return asm_func(i,j,k); 
18758 \newline
18759
18760 \newline
18761
18762 \newline
18763 int main() 
18764 \newline
18765
18766 \newline
18767 \InsetSpace ~
18768 \InsetSpace ~
18769 \InsetSpace ~
18770 \InsetSpace ~
18771 return c_func(10,9,8); 
18772 \newline
18773 }
18774 \end_layout
18775
18776 \begin_layout Standard
18777 The corresponding (unoptimized) assembler routine is:
18778 \end_layout
18779
18780 \begin_layout Verse
18781
18782 \family typewriter
18783 .globl _asm_func 
18784 \newline
18785 _asm_func: 
18786 \newline
18787 \InsetSpace ~
18788 \InsetSpace ~
18789 \InsetSpace ~
18790 \InsetSpace ~
18791 push\InsetSpace ~
18792 _bp 
18793 \newline
18794 \InsetSpace ~
18795 \InsetSpace ~
18796 \InsetSpace ~
18797 \InsetSpace ~
18798 mov\InsetSpace ~
18799 \InsetSpace ~
18800 _bp,sp\InsetSpace ~
18801 \InsetSpace ~
18802 \InsetSpace ~
18803 \InsetSpace ~
18804 \InsetSpace ~
18805 \InsetSpace ~
18806 ;stack contains: _bp, return
18807  address, second parameter, third parameter
18808 \newline
18809 \InsetSpace ~
18810 \InsetSpace ~
18811 \InsetSpace ~
18812 \InsetSpace ~
18813 mov\InsetSpace ~
18814 \InsetSpace ~
18815 r2,dpl
18816 \newline
18817 \InsetSpace ~
18818 \InsetSpace ~
18819 \InsetSpace ~
18820 \InsetSpace ~
18821 mov\InsetSpace ~
18822 \InsetSpace ~
18823 a,_bp
18824 \newline
18825 \InsetSpace ~
18826 \InsetSpace ~
18827 \InsetSpace ~
18828 \InsetSpace ~
18829 add\InsetSpace ~
18830 \InsetSpace ~
18831 a,#0xfd\InsetSpace ~
18832 \InsetSpace ~
18833 \InsetSpace ~
18834 \InsetSpace ~
18835 \InsetSpace ~
18836 ;calculate
18837  pointer to the second parameter
18838 \newline
18839 \InsetSpace ~
18840 \InsetSpace ~
18841 \InsetSpace ~
18842 \InsetSpace ~
18843 mov\InsetSpace ~
18844 \InsetSpace ~
18845 r0,a 
18846 \newline
18847 \InsetSpace ~
18848 \InsetSpace ~
18849 \InsetSpace ~
18850 \InsetSpace ~
18851 mov\InsetSpace ~
18852 \InsetSpace ~
18853 a,_bp 
18854 \newline
18855 \InsetSpace ~
18856 \InsetSpace ~
18857 \InsetSpace ~
18858 \InsetSpace ~
18859 add\InsetSpace ~
18860 \InsetSpace ~
18861 a,#0xfc\InsetSpace ~
18862 \InsetSpace ~
18863 \InsetSpace ~
18864 \InsetSpace ~
18865 \InsetSpace ~
18866 ;calculate pointer
18867  to the rightmost parameter
18868 \newline
18869 \InsetSpace ~
18870 \InsetSpace ~
18871 \InsetSpace ~
18872 \InsetSpace ~
18873 mov\InsetSpace ~
18874 \InsetSpace ~
18875 r1,a 
18876 \newline
18877 \InsetSpace ~
18878 \InsetSpace ~
18879 \InsetSpace ~
18880 \InsetSpace ~
18881 mov\InsetSpace ~
18882 \InsetSpace ~
18883 a,@r0
18884 \newline
18885 \InsetSpace ~
18886 \InsetSpace ~
18887 \InsetSpace ~
18888 \InsetSpace ~
18889 add\InsetSpace ~
18890 \InsetSpace ~
18891 a,@r1
18892 \newline
18893 \InsetSpace ~
18894 \InsetSpace ~
18895 \InsetSpace ~
18896 \InsetSpace ~
18897 add\InsetSpace ~
18898 \InsetSpace ~
18899 a,r2\InsetSpace ~
18900 \InsetSpace ~
18901 \InsetSpace ~
18902 \InsetSpace ~
18903 \InsetSpace ~
18904 \InsetSpace ~
18905 \InsetSpace ~
18906 \InsetSpace ~
18907 ;calculate the
18908  result (= sum of all three parameters)
18909 \newline
18910 \InsetSpace ~
18911 \InsetSpace ~
18912 \InsetSpace ~
18913 \InsetSpace ~
18914 mov\InsetSpace ~
18915 \InsetSpace ~
18916 dpl,a\InsetSpace ~
18917 \InsetSpace ~
18918 \InsetSpace ~
18919 \InsetSpace ~
18920 \InsetSpace ~
18921 \InsetSpace ~
18922 \InsetSpace ~
18923 ;return value goes into dptr
18924  (cast into int)
18925 \newline
18926 \InsetSpace ~
18927 \InsetSpace ~
18928 \InsetSpace ~
18929 \InsetSpace ~
18930 mov\InsetSpace ~
18931 \InsetSpace ~
18932 dph,#0x00 
18933 \newline
18934 \InsetSpace ~
18935 \InsetSpace ~
18936 \InsetSpace ~
18937 \InsetSpace ~
18938 mov\InsetSpace ~
18939 \InsetSpace ~
18940 sp,_bp 
18941 \newline
18942 \InsetSpace ~
18943 \InsetSpace ~
18944 \InsetSpace ~
18945 \InsetSpace ~
18946 pop\InsetSpace ~
18947 \InsetSpace ~
18948 _bp 
18949 \newline
18950 \InsetSpace ~
18951 \InsetSpace ~
18952 \InsetSpace ~
18953 \InsetSpace ~
18954 ret
18955 \end_layout
18956
18957 \begin_layout Standard
18958 The compiling and linking procedure remains the same, however note the extra
18959  entry & exit linkage required for the assembler code, _bp is the stack
18960  frame pointer and is used to compute the offset into the stack for parameters
18961  and local variables.
18962 \begin_inset VSpace bigskip
18963 \end_inset
18964
18965
18966 \end_layout
18967
18968 \begin_layout Section
18969 int (16 bit)
18970 \begin_inset LatexCommand \index{int (16 bit)}
18971
18972 \end_inset
18973
18974  and long (32 bit)
18975 \begin_inset LatexCommand \index{long (32 bit)}
18976
18977 \end_inset
18978
18979  Support
18980 \end_layout
18981
18982 \begin_layout Standard
18983 For signed & unsigned int (16 bit) and long (32 bit) variables, division,
18984  multiplication and modulus operations are implemented by support routines.
18985  These support routines are all developed in ANSI-C to facilitate porting
18986  to other MCUs, although some model specific assembler optimizations are
18987  used.
18988  The following files contain the described routines, all of them can be
18989  found in <installdir>/share/sdcc/lib.
18990 \newline
18991
18992 \end_layout
18993
18994 \begin_layout Standard
18995 \align center
18996 \begin_inset Tabular
18997 <lyxtabular version="3" rows="11" columns="2">
18998 <features>
18999 <column alignment="left" valignment="top" leftline="true" width="0">
19000 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
19001 <row topline="true" bottomline="true">
19002 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19003 \begin_inset Text
19004
19005 \begin_layout Standard
19006
19007 \series bold
19008 Function
19009 \end_layout
19010
19011 \end_inset
19012 </cell>
19013 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19014 \begin_inset Text
19015
19016 \begin_layout Standard
19017
19018 \series bold
19019 Description
19020 \end_layout
19021
19022 \end_inset
19023 </cell>
19024 </row>
19025 <row topline="true">
19026 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19027 \begin_inset Text
19028
19029 \begin_layout Standard
19030 _mulint.c 
19031 \end_layout
19032
19033 \end_inset
19034 </cell>
19035 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19036 \begin_inset Text
19037
19038 \begin_layout Standard
19039 16 bit multiplication
19040 \end_layout
19041
19042 \end_inset
19043 </cell>
19044 </row>
19045 <row topline="true">
19046 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19047 \begin_inset Text
19048
19049 \begin_layout Standard
19050 _divsint.c 
19051 \end_layout
19052
19053 \end_inset
19054 </cell>
19055 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19056 \begin_inset Text
19057
19058 \begin_layout Standard
19059  signed 16 bit division (calls _divuint)
19060 \end_layout
19061
19062 \end_inset
19063 </cell>
19064 </row>
19065 <row topline="true">
19066 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19067 \begin_inset Text
19068
19069 \begin_layout Standard
19070 _divuint.c 
19071 \end_layout
19072
19073 \end_inset
19074 </cell>
19075 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19076 \begin_inset Text
19077
19078 \begin_layout Standard
19079  unsigned 16 bit division
19080 \end_layout
19081
19082 \end_inset
19083 </cell>
19084 </row>
19085 <row topline="true">
19086 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19087 \begin_inset Text
19088
19089 \begin_layout Standard
19090 _modsint.c
19091 \end_layout
19092
19093 \end_inset
19094 </cell>
19095 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19096 \begin_inset Text
19097
19098 \begin_layout Standard
19099 signed 16 bit modulus (calls _moduint)
19100 \end_layout
19101
19102 \end_inset
19103 </cell>
19104 </row>
19105 <row topline="true">
19106 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19107 \begin_inset Text
19108
19109 \begin_layout Standard
19110 _moduint.c
19111 \end_layout
19112
19113 \end_inset
19114 </cell>
19115 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19116 \begin_inset Text
19117
19118 \begin_layout Standard
19119 unsigned 16 bit modulus
19120 \end_layout
19121
19122 \end_inset
19123 </cell>
19124 </row>
19125 <row topline="true">
19126 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19127 \begin_inset Text
19128
19129 \begin_layout Standard
19130 _mullong.c
19131 \end_layout
19132
19133 \end_inset
19134 </cell>
19135 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19136 \begin_inset Text
19137
19138 \begin_layout Standard
19139 32 bit multiplication
19140 \end_layout
19141
19142 \end_inset
19143 </cell>
19144 </row>
19145 <row topline="true">
19146 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19147 \begin_inset Text
19148
19149 \begin_layout Standard
19150 _divslong.c 
19151 \end_layout
19152
19153 \end_inset
19154 </cell>
19155 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19156 \begin_inset Text
19157
19158 \begin_layout Standard
19159  signed 32 division (calls _divulong)
19160 \end_layout
19161
19162 \end_inset
19163 </cell>
19164 </row>
19165 <row topline="true">
19166 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19167 \begin_inset Text
19168
19169 \begin_layout Standard
19170 _divulong.c 
19171 \end_layout
19172
19173 \end_inset
19174 </cell>
19175 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19176 \begin_inset Text
19177
19178 \begin_layout Standard
19179 unsigned 32 division
19180 \end_layout
19181
19182 \end_inset
19183 </cell>
19184 </row>
19185 <row topline="true">
19186 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19187 \begin_inset Text
19188
19189 \begin_layout Standard
19190 _modslong.c
19191 \end_layout
19192
19193 \end_inset
19194 </cell>
19195 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19196 \begin_inset Text
19197
19198 \begin_layout Standard
19199  signed 32 bit modulus (calls _modulong)
19200 \end_layout
19201
19202 \end_inset
19203 </cell>
19204 </row>
19205 <row topline="true" bottomline="true">
19206 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19207 \begin_inset Text
19208
19209 \begin_layout Standard
19210 _modulong.c
19211 \end_layout
19212
19213 \end_inset
19214 </cell>
19215 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19216 \begin_inset Text
19217
19218 \begin_layout Standard
19219 unsigned 32 bit modulus
19220 \end_layout
19221
19222 \end_inset
19223 </cell>
19224 </row>
19225 </lyxtabular>
19226
19227 \end_inset
19228
19229
19230 \newline
19231
19232 \end_layout
19233
19234 \begin_layout Standard
19235 Since they are compiled as 
19236 \emph on
19237 non-reentrant
19238 \emph default
19239
19240 \begin_inset LatexCommand \index{reentrant}
19241
19242 \end_inset
19243
19244 , interrupt
19245 \begin_inset LatexCommand \index{interrupt}
19246
19247 \end_inset
19248
19249  service routines should not do any of the above operations.
19250  If this is unavoidable then the above routines will need to be compiled
19251  with the 
19252 \emph on
19253 -
19254 \begin_inset ERT
19255 status collapsed
19256
19257 \begin_layout Standard
19258
19259
19260 \backslash
19261 /
19262 \end_layout
19263
19264 \end_inset
19265
19266 -stack-auto
19267 \begin_inset LatexCommand \index{-\/-stack-auto}
19268
19269 \end_inset
19270
19271
19272 \emph default
19273  option, after which the source program will have to be compiled with 
19274 \emph on
19275 -
19276 \begin_inset ERT
19277 status collapsed
19278
19279 \begin_layout Standard
19280
19281
19282 \backslash
19283 /
19284 \end_layout
19285
19286 \end_inset
19287
19288 -int-long-reent
19289 \begin_inset LatexCommand \index{-\/-int-long-reent}
19290
19291 \end_inset
19292
19293
19294 \emph default
19295  option.
19296  Notice that you don't have to call these routines directly.
19297  The compiler will use them automatically every time an integer operation
19298  is required.
19299 \end_layout
19300
19301 \begin_layout Section
19302 Floating Point Support
19303 \begin_inset LatexCommand \index{Floating point support}
19304
19305 \end_inset
19306
19307
19308 \end_layout
19309
19310 \begin_layout Standard
19311 SDCC supports IEEE (single precision 4 bytes) floating point numbers.
19312  The floating point support routines are derived from gcc's floatlib.c and
19313  consist of the following routines:
19314 \newline
19315
19316 \end_layout
19317
19318 \begin_layout Standard
19319 \align center
19320
19321 \size footnotesize
19322 \begin_inset Tabular
19323 <lyxtabular version="3" rows="17" columns="2">
19324 <features>
19325 <column alignment="left" valignment="top" leftline="true" width="0">
19326 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
19327 <row topline="true" bottomline="true">
19328 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19329 \begin_inset Text
19330
19331 \begin_layout Standard
19332
19333 \family roman
19334 \series medium
19335 \shape up
19336 \size normal
19337 \emph off
19338 \bar no
19339 \noun off
19340 \color none
19341 Function 
19342 \end_layout
19343
19344 \end_inset
19345 </cell>
19346 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19347 \begin_inset Text
19348
19349 \begin_layout Standard
19350 Description
19351 \end_layout
19352
19353 \end_inset
19354 </cell>
19355 </row>
19356 <row topline="true">
19357 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19358 \begin_inset Text
19359
19360 \begin_layout Standard
19361
19362 \family roman
19363 \series medium
19364 \shape up
19365 \size normal
19366 \emph off
19367 \bar no
19368 \noun off
19369 \color none
19370 _fsadd.c
19371 \end_layout
19372
19373 \end_inset
19374 </cell>
19375 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19376 \begin_inset Text
19377
19378 \begin_layout Standard
19379
19380 \family roman
19381 \series medium
19382 \shape up
19383 \size normal
19384 \emph off
19385 \bar no
19386 \noun off
19387 \color none
19388 add floating point numbers
19389 \end_layout
19390
19391 \end_inset
19392 </cell>
19393 </row>
19394 <row topline="true">
19395 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19396 \begin_inset Text
19397
19398 \begin_layout Standard
19399
19400 \family roman
19401 \series medium
19402 \shape up
19403 \size normal
19404 \emph off
19405 \bar no
19406 \noun off
19407 \color none
19408 _fssub.c 
19409 \end_layout
19410
19411 \end_inset
19412 </cell>
19413 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19414 \begin_inset Text
19415
19416 \begin_layout Standard
19417
19418 \family roman
19419 \series medium
19420 \shape up
19421 \size normal
19422 \emph off
19423 \bar no
19424 \noun off
19425 \color none
19426 subtract floating point numbers 
19427 \end_layout
19428
19429 \end_inset
19430 </cell>
19431 </row>
19432 <row topline="true">
19433 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19434 \begin_inset Text
19435
19436 \begin_layout Standard
19437
19438 \family roman
19439 \series medium
19440 \shape up
19441 \size normal
19442 \emph off
19443 \bar no
19444 \noun off
19445 \color none
19446 _fsdiv.c 
19447 \end_layout
19448
19449 \end_inset
19450 </cell>
19451 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19452 \begin_inset Text
19453
19454 \begin_layout Standard
19455
19456 \family roman
19457 \series medium
19458 \shape up
19459 \size normal
19460 \emph off
19461 \bar no
19462 \noun off
19463 \color none
19464 divide floating point numbers 
19465 \end_layout
19466
19467 \end_inset
19468 </cell>
19469 </row>
19470 <row topline="true">
19471 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19472 \begin_inset Text
19473
19474 \begin_layout Standard
19475
19476 \family roman
19477 \series medium
19478 \shape up
19479 \size normal
19480 \emph off
19481 \bar no
19482 \noun off
19483 \color none
19484 _fsmul.c 
19485 \end_layout
19486
19487 \end_inset
19488 </cell>
19489 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19490 \begin_inset Text
19491
19492 \begin_layout Standard
19493
19494 \family roman
19495 \series medium
19496 \shape up
19497 \size normal
19498 \emph off
19499 \bar no
19500 \noun off
19501 \color none
19502 multiply floating point numbers 
19503 \end_layout
19504
19505 \end_inset
19506 </cell>
19507 </row>
19508 <row topline="true">
19509 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19510 \begin_inset Text
19511
19512 \begin_layout Standard
19513
19514 \family roman
19515 \series medium
19516 \shape up
19517 \size normal
19518 \emph off
19519 \bar no
19520 \noun off
19521 \color none
19522 _fs2uchar.c
19523 \end_layout
19524
19525 \end_inset
19526 </cell>
19527 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19528 \begin_inset Text
19529
19530 \begin_layout Standard
19531
19532 \family roman
19533 \series medium
19534 \shape up
19535 \size normal
19536 \emph off
19537 \bar no
19538 \noun off
19539 \color none
19540 convert floating point to unsigned char
19541 \end_layout
19542
19543 \end_inset
19544 </cell>
19545 </row>
19546 <row topline="true">
19547 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19548 \begin_inset Text
19549
19550 \begin_layout Standard
19551
19552 \family roman
19553 \series medium
19554 \shape up
19555 \size normal
19556 \emph off
19557 \bar no
19558 \noun off
19559 \color none
19560 _fs2char.c
19561 \end_layout
19562
19563 \end_inset
19564 </cell>
19565 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19566 \begin_inset Text
19567
19568 \begin_layout Standard
19569
19570 \family roman
19571 \series medium
19572 \shape up
19573 \size normal
19574 \emph off
19575 \bar no
19576 \noun off
19577 \color none
19578 convert floating point to signed char
19579 \end_layout
19580
19581 \end_inset
19582 </cell>
19583 </row>
19584 <row topline="true">
19585 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19586 \begin_inset Text
19587
19588 \begin_layout Standard
19589
19590 \family roman
19591 \series medium
19592 \shape up
19593 \size normal
19594 \emph off
19595 \bar no
19596 \noun off
19597 \color none
19598 _fs2uint.c
19599 \end_layout
19600
19601 \end_inset
19602 </cell>
19603 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19604 \begin_inset Text
19605
19606 \begin_layout Standard
19607
19608 \family roman
19609 \series medium
19610 \shape up
19611 \size normal
19612 \emph off
19613 \bar no
19614 \noun off
19615 \color none
19616 convert floating point to unsigned int
19617 \end_layout
19618
19619 \end_inset
19620 </cell>
19621 </row>
19622 <row topline="true">
19623 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19624 \begin_inset Text
19625
19626 \begin_layout Standard
19627
19628 \family roman
19629 \series medium
19630 \shape up
19631 \size normal
19632 \emph off
19633 \bar no
19634 \noun off
19635 \color none
19636 _fs2int.c
19637 \end_layout
19638
19639 \end_inset
19640 </cell>
19641 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19642 \begin_inset Text
19643
19644 \begin_layout Standard
19645
19646 \family roman
19647 \series medium
19648 \shape up
19649 \size normal
19650 \emph off
19651 \bar no
19652 \noun off
19653 \color none
19654 convert floating point to signed int
19655 \end_layout
19656
19657 \end_inset
19658 </cell>
19659 </row>
19660 <row topline="true">
19661 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19662 \begin_inset Text
19663
19664 \begin_layout Standard
19665
19666 \family roman
19667 \series medium
19668 \shape up
19669 \size normal
19670 \emph off
19671 \bar no
19672 \noun off
19673 \color none
19674 _fs2ulong.
19675 \family default
19676 \series default
19677 \shape default
19678 \size default
19679 \emph default
19680 \bar default
19681 \noun default
19682 c
19683 \end_layout
19684
19685 \end_inset
19686 </cell>
19687 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19688 \begin_inset Text
19689
19690 \begin_layout Standard
19691
19692 \family roman
19693 \series medium
19694 \shape up
19695 \size normal
19696 \emph off
19697 \bar no
19698 \noun off
19699 \color none
19700 convert floating point to unsigned long
19701 \end_layout
19702
19703 \end_inset
19704 </cell>
19705 </row>
19706 <row topline="true">
19707 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19708 \begin_inset Text
19709
19710 \begin_layout Standard
19711
19712 \family roman
19713 \series medium
19714 \shape up
19715 \size normal
19716 \emph off
19717 \bar no
19718 \noun off
19719 \color none
19720 _fs2long.c
19721 \end_layout
19722
19723 \end_inset
19724 </cell>
19725 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19726 \begin_inset Text
19727
19728 \begin_layout Standard
19729
19730 \family roman
19731 \series medium
19732 \shape up
19733 \size normal
19734 \emph off
19735 \bar no
19736 \noun off
19737 \color none
19738 convert floating point to signed long
19739 \end_layout
19740
19741 \end_inset
19742 </cell>
19743 </row>
19744 <row topline="true">
19745 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19746 \begin_inset Text
19747
19748 \begin_layout Standard
19749
19750 \family roman
19751 \series medium
19752 \shape up
19753 \size normal
19754 \emph off
19755 \bar no
19756 \noun off
19757 \color none
19758 _uchar2fs.c
19759 \end_layout
19760
19761 \end_inset
19762 </cell>
19763 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19764 \begin_inset Text
19765
19766 \begin_layout Standard
19767
19768 \family roman
19769 \series medium
19770 \shape up
19771 \size normal
19772 \emph off
19773 \bar no
19774 \noun off
19775 \color none
19776 convert unsigned char to floating point
19777 \end_layout
19778
19779 \end_inset
19780 </cell>
19781 </row>
19782 <row topline="true">
19783 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19784 \begin_inset Text
19785
19786 \begin_layout Standard
19787
19788 \family roman
19789 \series medium
19790 \shape up
19791 \size normal
19792 \emph off
19793 \bar no
19794 \noun off
19795 \color none
19796 _char2fs.c
19797 \end_layout
19798
19799 \end_inset
19800 </cell>
19801 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19802 \begin_inset Text
19803
19804 \begin_layout Standard
19805
19806 \family roman
19807 \series medium
19808 \shape up
19809 \size normal
19810 \emph off
19811 \bar no
19812 \noun off
19813 \color none
19814 convert char to floating point number
19815 \end_layout
19816
19817 \end_inset
19818 </cell>
19819 </row>
19820 <row topline="true">
19821 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19822 \begin_inset Text
19823
19824 \begin_layout Standard
19825
19826 \family roman
19827 \series medium
19828 \shape up
19829 \size normal
19830 \emph off
19831 \bar no
19832 \noun off
19833 \color none
19834 _uint2fs.c
19835 \end_layout
19836
19837 \end_inset
19838 </cell>
19839 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19840 \begin_inset Text
19841
19842 \begin_layout Standard
19843
19844 \family roman
19845 \series medium
19846 \shape up
19847 \size normal
19848 \emph off
19849 \bar no
19850 \noun off
19851 \color none
19852 convert unsigned int to floating point
19853 \end_layout
19854
19855 \end_inset
19856 </cell>
19857 </row>
19858 <row topline="true">
19859 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19860 \begin_inset Text
19861
19862 \begin_layout Standard
19863
19864 \family roman
19865 \series medium
19866 \shape up
19867 \size normal
19868 \emph off
19869 \bar no
19870 \noun off
19871 \color none
19872 _int2fs.c
19873 \end_layout
19874
19875 \end_inset
19876 </cell>
19877 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19878 \begin_inset Text
19879
19880 \begin_layout Standard
19881
19882 \family roman
19883 \series medium
19884 \shape up
19885 \size normal
19886 \emph off
19887 \bar no
19888 \noun off
19889 \color none
19890 convert int to floating point numbers
19891 \end_layout
19892
19893 \end_inset
19894 </cell>
19895 </row>
19896 <row topline="true">
19897 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19898 \begin_inset Text
19899
19900 \begin_layout Standard
19901
19902 \family roman
19903 \series medium
19904 \shape up
19905 \size normal
19906 \emph off
19907 \bar no
19908 \noun off
19909 \color none
19910 _ulong2fs.c
19911 \end_layout
19912
19913 \end_inset
19914 </cell>
19915 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19916 \begin_inset Text
19917
19918 \begin_layout Standard
19919
19920 \family roman
19921 \series medium
19922 \shape up
19923 \size normal
19924 \emph off
19925 \bar no
19926 \noun off
19927 \color none
19928 convert unsigned long to floating point number
19929 \end_layout
19930
19931 \end_inset
19932 </cell>
19933 </row>
19934 <row topline="true" bottomline="true">
19935 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19936 \begin_inset Text
19937
19938 \begin_layout Standard
19939
19940 \family roman
19941 \series medium
19942 \shape up
19943 \size normal
19944 \emph off
19945 \bar no
19946 \noun off
19947 \color none
19948 _long2fs.c
19949 \end_layout
19950
19951 \end_inset
19952 </cell>
19953 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19954 \begin_inset Text
19955
19956 \begin_layout Standard
19957
19958 \family roman
19959 \series medium
19960 \shape up
19961 \size normal
19962 \emph off
19963 \bar no
19964 \noun off
19965 \color none
19966 convert long to floating point number
19967 \end_layout
19968
19969 \end_inset
19970 </cell>
19971 </row>
19972 </lyxtabular>
19973
19974 \end_inset
19975
19976
19977 \newline
19978
19979 \end_layout
19980
19981 \begin_layout Standard
19982 These support routines are developed in ANSI-C so there is room for space
19983  and speed improvement
19984 \begin_inset Foot
19985 status open
19986
19987 \begin_layout Standard
19988 These floating point routines (
19989 \emph on
19990 not
19991 \emph default
19992  sinf(), cosf(), ...) for the mcs51 are implemented in assembler.
19993  
19994 \end_layout
19995
19996 \end_inset
19997
19998 .
19999  Note if all these routines are used simultaneously the data space might
20000  overflow.
20001  For serious floating point usage the large model might be needed.
20002  Also notice that you don't have to call this routines directly.
20003  The compiler will use them automatically every time a floating point operation
20004  is required.
20005 \begin_inset VSpace bigskip
20006 \end_inset
20007
20008
20009 \end_layout
20010
20011 \begin_layout Section
20012 Library Routines
20013 \begin_inset LatexCommand \index{Libraries}
20014
20015 \end_inset
20016
20017
20018 \end_layout
20019
20020 \begin_layout Standard
20021
20022 \emph on
20023 <pending: this is messy and incomplete - a little more information is in
20024  sdcc/doc/libdoc.txt
20025 \emph default
20026  >
20027 \end_layout
20028
20029 \begin_layout Subsection
20030 Compiler support routines (_gptrget, _mulint etc.)
20031 \end_layout
20032
20033 \begin_layout Subsection
20034 Stdclib functions (puts, printf, strcat etc.)
20035 \end_layout
20036
20037 \begin_layout Subsubsection
20038 <stdio.h>
20039 \end_layout
20040
20041 \begin_layout Paragraph
20042 getchar(), putchar()
20043 \end_layout
20044
20045 \begin_layout Standard
20046 \begin_inset LatexCommand \index{<stdio.h>}
20047
20048 \end_inset
20049
20050 As usual on embedded systems you have to provide your own 
20051 \family typewriter
20052 getchar()
20053 \begin_inset LatexCommand \index{getchar()}
20054
20055 \end_inset
20056
20057  
20058 \family default
20059 and 
20060 \family typewriter
20061 putchar()
20062 \begin_inset LatexCommand \index{putchar()}
20063
20064 \end_inset
20065
20066
20067 \family default
20068  routines.
20069  SDCC does not know whether the system connects to a serial line with or
20070  without handshake, LCD, keyboard or other device.
20071  And whether a 
20072 \family typewriter
20073 lf
20074 \family default
20075  to 
20076 \family typewriter
20077 crlf
20078 \family default
20079  conversion within 
20080 \family typewriter
20081 putchar()
20082 \family default
20083  is intended.
20084  You'll find examples for serial routines f.e.
20085  in sdcc/device/lib.
20086  For the mcs51 this minimalistic polling 
20087 \family typewriter
20088 putchar()
20089 \family default
20090  routine might be a start:
20091 \end_layout
20092
20093 \begin_layout Verse
20094
20095 \family typewriter
20096 void putchar (char c) { 
20097 \newline
20098 \InsetSpace ~
20099 \InsetSpace ~
20100 \InsetSpace ~
20101 \InsetSpace ~
20102 while (!TI)\InsetSpace ~
20103 \InsetSpace ~
20104 \InsetSpace ~
20105  /* assumes UART is initialized */
20106 \newline
20107 \InsetSpace ~
20108 \InsetSpace ~
20109 \InsetSpace ~
20110 \InsetSpace ~
20111 \InsetSpace ~
20112 \InsetSpace ~
20113 \InsetSpace ~
20114 \InsetSpace ~
20115 ;
20116 \newline
20117 \InsetSpace ~
20118 \InsetSpace ~
20119 \InsetSpace ~
20120 \InsetSpace ~
20121 TI
20122  = 0;
20123 \newline
20124 \InsetSpace ~
20125 \InsetSpace ~
20126 \InsetSpace ~
20127 \InsetSpace ~
20128 SBUF = c;
20129 \newline
20130 }
20131 \end_layout
20132
20133 \begin_layout Paragraph
20134 printf()
20135 \end_layout
20136
20137 \begin_layout Standard
20138 The default
20139 \family typewriter
20140  printf()
20141 \begin_inset LatexCommand \index{printf()}
20142
20143 \end_inset
20144
20145
20146 \family default
20147  implementation in
20148 \family typewriter
20149  printf_large.c
20150 \family default
20151  does not support float (except on ds390).
20152  To enable this recompile it with the option 
20153 \emph on
20154 -
20155 \begin_inset ERT
20156 status collapsed
20157
20158 \begin_layout Standard
20159
20160
20161 \backslash
20162 /
20163 \end_layout
20164
20165 \end_inset
20166
20167 DUSE_FLOATS=1
20168 \begin_inset LatexCommand \index{USE\_FLOATS}
20169
20170 \end_inset
20171
20172
20173 \emph default
20174  on the command line.
20175  Use
20176 \emph on
20177  -
20178 \begin_inset ERT
20179 status collapsed
20180
20181 \begin_layout Standard
20182
20183
20184 \backslash
20185 /
20186 \end_layout
20187
20188 \end_inset
20189
20190 -model-large
20191 \begin_inset LatexCommand \index{-\/-model-large}
20192
20193 \end_inset
20194
20195
20196 \emph default
20197  for the mcs51 port, since this uses a lot of memory.
20198 \end_layout
20199
20200 \begin_layout Standard
20201 If you're short on code memory you might want to use 
20202 \family typewriter
20203 printf_small()
20204 \begin_inset LatexCommand \index{printf\_small()}
20205
20206 \end_inset
20207
20208
20209 \family default
20210  
20211 \emph on
20212 instead
20213 \emph default
20214  of
20215 \family typewriter
20216  printf().
20217
20218 \family default
20219  For the mcs51 there additionally are assembly versions 
20220 \family typewriter
20221 printf_tiny()
20222 \begin_inset LatexCommand \index{printf\_tiny() (mcs51)}
20223
20224 \end_inset
20225
20226
20227 \family default
20228  (subset of printf using less than 270 bytes) and 
20229 \family typewriter
20230 printf_fast()
20231 \begin_inset LatexCommand \index{printf\_fast() (mcs51)}
20232
20233 \end_inset
20234
20235  
20236 \family default
20237 and
20238 \family typewriter
20239  printf_fast_f()
20240 \begin_inset LatexCommand \index{printf\_fast\_f() (mcs51)}
20241
20242 \end_inset
20243
20244
20245 \family default
20246  (floating-point aware version of printf_fast) which should fit the requirements
20247  of many embedded systems (printf_fast() can be customized by unsetting
20248  #defines to 
20249 \emph on
20250 not
20251 \emph default
20252  support long variables and field widths).
20253  Be sure to use only one of these printf options within a project.
20254 \newline
20255
20256 \end_layout
20257
20258 \begin_layout Standard
20259 Feature matrix of different 
20260 \emph on
20261 printf
20262 \emph default
20263  options on mcs51.
20264 \end_layout
20265
20266 \begin_layout Standard
20267 \begin_inset Tabular
20268 <lyxtabular version="3" rows="14" columns="7">
20269 <features islongtable="true">
20270 <column alignment="left" valignment="middle" leftline="true" width="14col%">
20271 <column alignment="center" valignment="top" leftline="true" width="0">
20272 <column alignment="center" valignment="top" leftline="true" width="12col%">
20273 <column alignment="center" valignment="top" leftline="true" width="10col%">
20274 <column alignment="center" valignment="top" leftline="true" width="0">
20275 <column alignment="center" valignment="top" leftline="true" rightline="true" width="12col%">
20276 <column alignment="center" valignment="top" rightline="true" width="0">
20277 <row topline="true" bottomline="true" endhead="true">
20278 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20279 \begin_inset Text
20280
20281 \begin_layout Standard
20282
20283 \series bold
20284 \size large
20285 mcs51
20286 \end_layout
20287
20288 \end_inset
20289 </cell>
20290 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20291 \begin_inset Text
20292
20293 \begin_layout Standard
20294 printf
20295 \begin_inset LatexCommand \index{printf}
20296
20297 \end_inset
20298
20299
20300 \end_layout
20301
20302 \end_inset
20303 </cell>
20304 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20305 \begin_inset Text
20306
20307 \begin_layout Standard
20308 printf 
20309 \size scriptsize
20310 USE_FLOATS=1
20311 \end_layout
20312
20313 \end_inset
20314 </cell>
20315 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20316 \begin_inset Text
20317
20318 \begin_layout Standard
20319 printf_small
20320 \end_layout
20321
20322 \end_inset
20323 </cell>
20324 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20325 \begin_inset Text
20326
20327 \begin_layout Standard
20328 printf_fast
20329 \end_layout
20330
20331 \end_inset
20332 </cell>
20333 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20334 \begin_inset Text
20335
20336 \begin_layout Standard
20337 printf_fast_f
20338 \end_layout
20339
20340 \end_inset
20341 </cell>
20342 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20343 \begin_inset Text
20344
20345 \begin_layout Standard
20346 printf_tiny
20347 \end_layout
20348
20349 \end_inset
20350 </cell>
20351 </row>
20352 <row topline="true" endhead="true">
20353 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20354 \begin_inset Text
20355
20356 \begin_layout Standard
20357 filename
20358 \end_layout
20359
20360 \end_inset
20361 </cell>
20362 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20363 \begin_inset Text
20364
20365 \begin_layout Standard
20366
20367 \size scriptsize
20368 printf_large.c
20369 \end_layout
20370
20371 \end_inset
20372 </cell>
20373 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20374 \begin_inset Text
20375
20376 \begin_layout Standard
20377
20378 \size scriptsize
20379 printf_large.c
20380 \end_layout
20381
20382 \end_inset
20383 </cell>
20384 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20385 \begin_inset Text
20386
20387 \begin_layout Standard
20388
20389 \size scriptsize
20390 printfl.c
20391 \end_layout
20392
20393 \end_inset
20394 </cell>
20395 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20396 \begin_inset Text
20397
20398 \begin_layout Standard
20399
20400 \size scriptsize
20401 printf_fast.c
20402 \end_layout
20403
20404 \end_inset
20405 </cell>
20406 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20407 \begin_inset Text
20408
20409 \begin_layout Standard
20410
20411 \size scriptsize
20412 printf_fast_f.c
20413 \end_layout
20414
20415 \end_inset
20416 </cell>
20417 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20418 \begin_inset Text
20419
20420 \begin_layout Standard
20421
20422 \size scriptsize
20423 printf_tiny.c
20424 \end_layout
20425
20426 \end_inset
20427 </cell>
20428 </row>
20429 <row topline="true" endhead="true">
20430 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20431 \begin_inset Text
20432
20433 \begin_layout Standard
20434 \begin_inset Quotes sld
20435 \end_inset
20436
20437 Hello World
20438 \begin_inset Quotes srd
20439 \end_inset
20440
20441  size
20442 \end_layout
20443
20444 \begin_layout Standard
20445 small / large
20446 \end_layout
20447
20448 \end_inset
20449 </cell>
20450 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20451 \begin_inset Text
20452
20453 \begin_layout Standard
20454 1.7k / 2.4k
20455 \end_layout
20456
20457 \end_inset
20458 </cell>
20459 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20460 \begin_inset Text
20461
20462 \begin_layout Standard
20463 4.3k / 5.6k
20464 \end_layout
20465
20466 \end_inset
20467 </cell>
20468 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20469 \begin_inset Text
20470
20471 \begin_layout Standard
20472 1.2k / 1.8k
20473 \end_layout
20474
20475 \end_inset
20476 </cell>
20477 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20478 \begin_inset Text
20479
20480 \begin_layout Standard
20481 1.3k / 1.3k
20482 \end_layout
20483
20484 \end_inset
20485 </cell>
20486 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20487 \begin_inset Text
20488
20489 \begin_layout Standard
20490 1.9k / 1.9k
20491 \end_layout
20492
20493 \end_inset
20494 </cell>
20495 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20496 \begin_inset Text
20497
20498 \begin_layout Standard
20499 0.44k / 0.44k
20500 \end_layout
20501
20502 \end_inset
20503 </cell>
20504 </row>
20505 <row topline="true" endhead="true">
20506 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20507 \begin_inset Text
20508
20509 \begin_layout Standard
20510 code size
20511 \end_layout
20512
20513 \begin_layout Standard
20514 small / large
20515 \end_layout
20516
20517 \end_inset
20518 </cell>
20519 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20520 \begin_inset Text
20521
20522 \begin_layout Standard
20523 1.4k / 2.0k
20524 \end_layout
20525
20526 \end_inset
20527 </cell>
20528 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20529 \begin_inset Text
20530
20531 \begin_layout Standard
20532 2.8k / 3.7k
20533 \end_layout
20534
20535 \end_inset
20536 </cell>
20537 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20538 \begin_inset Text
20539
20540 \begin_layout Standard
20541 0.45k / 0.47k (+ _ltoa)
20542 \end_layout
20543
20544 \end_inset
20545 </cell>
20546 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20547 \begin_inset Text
20548
20549 \begin_layout Standard
20550 1.2k / 1.2k
20551 \end_layout
20552
20553 \end_inset
20554 </cell>
20555 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20556 \begin_inset Text
20557
20558 \begin_layout Standard
20559 1.6k / 1.6k
20560 \end_layout
20561
20562 \end_inset
20563 </cell>
20564 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20565 \begin_inset Text
20566
20567 \begin_layout Standard
20568 0.26k / 0.26k
20569 \end_layout
20570
20571 \end_inset
20572 </cell>
20573 </row>
20574 <row topline="true">
20575 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20576 \begin_inset Text
20577
20578 \begin_layout Standard
20579 formats
20580 \end_layout
20581
20582 \end_inset
20583 </cell>
20584 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20585 \begin_inset Text
20586
20587 \begin_layout Standard
20588 cdi
20589 \emph on
20590 o
20591 \emph default
20592 psux
20593 \end_layout
20594
20595 \end_inset
20596 </cell>
20597 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20598 \begin_inset Text
20599
20600 \begin_layout Standard
20601
20602 \family roman
20603 \series medium
20604 \shape up
20605 \size normal
20606 \emph off
20607 \bar no
20608 \noun off
20609 \color none
20610 cd
20611 \family default
20612 \series default
20613 \shape default
20614 \size default
20615 \emph default
20616 \bar default
20617 \noun default
20618 f
20619 \family roman
20620 \series medium
20621 \shape up
20622 \size normal
20623 \emph off
20624 \bar no
20625 \noun off
20626 i
20627 \family default
20628 \series default
20629 \shape default
20630 \size default
20631 \emph on
20632 \bar default
20633 \noun default
20634 o
20635 \family roman
20636 \series medium
20637 \shape up
20638 \size normal
20639 \emph off
20640 \bar no
20641 \noun off
20642 psux
20643 \end_layout
20644
20645 \end_inset
20646 </cell>
20647 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20648 \begin_inset Text
20649
20650 \begin_layout Standard
20651 c
20652 \family roman
20653 \series medium
20654 \shape up
20655 \size normal
20656 \emph off
20657 \bar no
20658 \noun off
20659 \color none
20660 d
20661 \family default
20662 \series default
20663 \shape default
20664 \size default
20665 \emph on
20666 \bar default
20667 \noun default
20668 o
20669 \family roman
20670 \series medium
20671 \shape up
20672 \size normal
20673 \emph off
20674 \bar no
20675 \noun off
20676 s
20677 \family default
20678 \series default
20679 \shape default
20680 \size default
20681 \emph default
20682 \bar default
20683 \noun default
20684 x
20685 \end_layout
20686
20687 \end_inset
20688 </cell>
20689 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20690 \begin_inset Text
20691
20692 \begin_layout Standard
20693 cdsux
20694 \end_layout
20695
20696 \end_inset
20697 </cell>
20698 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20699 \begin_inset Text
20700
20701 \begin_layout Standard
20702 cdfsux
20703 \end_layout
20704
20705 \end_inset
20706 </cell>
20707 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20708 \begin_inset Text
20709
20710 \begin_layout Standard
20711 cdsux
20712 \end_layout
20713
20714 \end_inset
20715 </cell>
20716 </row>
20717 <row topline="true">
20718 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20719 \begin_inset Text
20720
20721 \begin_layout Standard
20722 long (32 bit) support
20723 \end_layout
20724
20725 \end_inset
20726 </cell>
20727 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20728 \begin_inset Text
20729
20730 \begin_layout Standard
20731 x
20732 \end_layout
20733
20734 \end_inset
20735 </cell>
20736 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20737 \begin_inset Text
20738
20739 \begin_layout Standard
20740 x
20741 \end_layout
20742
20743 \end_inset
20744 </cell>
20745 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20746 \begin_inset Text
20747
20748 \begin_layout Standard
20749 x
20750 \end_layout
20751
20752 \end_inset
20753 </cell>
20754 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20755 \begin_inset Text
20756
20757 \begin_layout Standard
20758 x
20759 \end_layout
20760
20761 \end_inset
20762 </cell>
20763 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20764 \begin_inset Text
20765
20766 \begin_layout Standard
20767
20768 \family roman
20769 \series medium
20770 \shape up
20771 \size normal
20772 \emph off
20773 \bar no
20774 \noun off
20775 \color none
20776 x
20777 \end_layout
20778
20779 \end_inset
20780 </cell>
20781 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20782 \begin_inset Text
20783
20784 \begin_layout Standard
20785 -
20786 \end_layout
20787
20788 \end_inset
20789 </cell>
20790 </row>
20791 <row topline="true">
20792 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20793 \begin_inset Text
20794
20795 \begin_layout Standard
20796 byte arguments on stack
20797 \end_layout
20798
20799 \end_inset
20800 </cell>
20801 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20802 \begin_inset Text
20803
20804 \begin_layout Standard
20805 b
20806 \end_layout
20807
20808 \end_inset
20809 </cell>
20810 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20811 \begin_inset Text
20812
20813 \begin_layout Standard
20814 b
20815 \end_layout
20816
20817 \end_inset
20818 </cell>
20819 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20820 \begin_inset Text
20821
20822 \begin_layout Standard
20823 -
20824 \end_layout
20825
20826 \end_inset
20827 </cell>
20828 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20829 \begin_inset Text
20830
20831 \begin_layout Standard
20832 -
20833 \end_layout
20834
20835 \end_inset
20836 </cell>
20837 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20838 \begin_inset Text
20839
20840 \begin_layout Standard
20841 -
20842 \end_layout
20843
20844 \end_inset
20845 </cell>
20846 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20847 \begin_inset Text
20848
20849 \begin_layout Standard
20850 -
20851 \end_layout
20852
20853 \end_inset
20854 </cell>
20855 </row>
20856 <row topline="true">
20857 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20858 \begin_inset Text
20859
20860 \begin_layout Standard
20861 float format
20862 \begin_inset LatexCommand \index{Floating point support}
20863
20864 \end_inset
20865
20866
20867 \end_layout
20868
20869 \end_inset
20870 </cell>
20871 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20872 \begin_inset Text
20873
20874 \begin_layout Standard
20875 -
20876 \end_layout
20877
20878 \end_inset
20879 </cell>
20880 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20881 \begin_inset Text
20882
20883 \begin_layout Standard
20884 %f
20885 \end_layout
20886
20887 \end_inset
20888 </cell>
20889 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20890 \begin_inset Text
20891
20892 \begin_layout Standard
20893 -
20894 \end_layout
20895
20896 \end_inset
20897 </cell>
20898 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20899 \begin_inset Text
20900
20901 \begin_layout Standard
20902 -
20903 \end_layout
20904
20905 \end_inset
20906 </cell>
20907 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20908 \begin_inset Text
20909
20910 \begin_layout Standard
20911 %f
20912 \begin_inset Foot
20913 status collapsed
20914
20915 \begin_layout Standard
20916 Range limited to +/- 4294967040, precision limited to 8 digits past decimal
20917 \end_layout
20918
20919 \end_inset
20920
20921
20922 \end_layout
20923
20924 \end_inset
20925 </cell>
20926 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20927 \begin_inset Text
20928
20929 \begin_layout Standard
20930 -
20931 \end_layout
20932
20933 \end_inset
20934 </cell>
20935 </row>
20936 <row topline="true">
20937 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20938 \begin_inset Text
20939
20940 \begin_layout Standard
20941 float formats %e %g
20942 \end_layout
20943
20944 \end_inset
20945 </cell>
20946 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20947 \begin_inset Text
20948
20949 \begin_layout Standard
20950 -
20951 \end_layout
20952
20953 \end_inset
20954 </cell>
20955 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20956 \begin_inset Text
20957
20958 \begin_layout Standard
20959 -
20960 \end_layout
20961
20962 \end_inset
20963 </cell>
20964 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20965 \begin_inset Text
20966
20967 \begin_layout Standard
20968 -
20969 \end_layout
20970
20971 \end_inset
20972 </cell>
20973 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20974 \begin_inset Text
20975
20976 \begin_layout Standard
20977 -
20978 \end_layout
20979
20980 \end_inset
20981 </cell>
20982 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20983 \begin_inset Text
20984
20985 \begin_layout Standard
20986 -
20987 \end_layout
20988
20989 \end_inset
20990 </cell>
20991 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20992 \begin_inset Text
20993
20994 \begin_layout Standard
20995 -
20996 \end_layout
20997
20998 \end_inset
20999 </cell>
21000 </row>
21001 <row topline="true" bottomline="true">
21002 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21003 \begin_inset Text
21004
21005 \begin_layout Standard
21006 field width
21007 \end_layout
21008
21009 \end_inset
21010 </cell>
21011 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21012 \begin_inset Text
21013
21014 \begin_layout Standard
21015 x
21016 \end_layout
21017
21018 \end_inset
21019 </cell>
21020 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21021 \begin_inset Text
21022
21023 \begin_layout Standard
21024 x
21025 \end_layout
21026
21027 \end_inset
21028 </cell>
21029 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21030 \begin_inset Text
21031
21032 \begin_layout Standard
21033 -
21034 \end_layout
21035
21036 \end_inset
21037 </cell>
21038 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21039 \begin_inset Text
21040
21041 \begin_layout Standard
21042 x
21043 \end_layout
21044
21045 \end_inset
21046 </cell>
21047 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21048 \begin_inset Text
21049
21050 \begin_layout Standard
21051 x
21052 \end_layout
21053
21054 \end_inset
21055 </cell>
21056 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21057 \begin_inset Text
21058
21059 \begin_layout Standard
21060 -
21061 \end_layout
21062
21063 \end_inset
21064 </cell>
21065 </row>
21066 <row bottomline="true">
21067 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21068 \begin_inset Text
21069
21070 \begin_layout Standard
21071 string speed
21072 \begin_inset Foot
21073 status collapsed
21074
21075 \begin_layout Standard
21076 Execution time of printf("%s%c%s%c%c%c", "Hello", ' ', "World", '!', '
21077 \backslash
21078 r', '
21079 \backslash
21080 n'); standard 8051 @ 22.1184 MHz, empty putchar()
21081 \end_layout
21082
21083 \end_inset
21084
21085 ,
21086 \end_layout
21087
21088 \begin_layout Standard
21089 small / large
21090 \end_layout
21091
21092 \end_inset
21093 </cell>
21094 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21095 \begin_inset Text
21096
21097 \begin_layout Standard
21098 1.52 / 2.59 ms
21099 \end_layout
21100
21101 \end_inset
21102 </cell>
21103 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21104 \begin_inset Text
21105
21106 \begin_layout Standard
21107 1.53 / 2.62 ms
21108 \end_layout
21109
21110 \end_inset
21111 </cell>
21112 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21113 \begin_inset Text
21114
21115 \begin_layout Standard
21116 0.92 / 0.93 ms
21117 \end_layout
21118
21119 \end_inset
21120 </cell>
21121 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21122 \begin_inset Text
21123
21124 \begin_layout Standard
21125 0.45 / 0.45 ms
21126 \end_layout
21127
21128 \end_inset
21129 </cell>
21130 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21131 \begin_inset Text
21132
21133 \begin_layout Standard
21134 0.46 / 0.46 ms
21135 \end_layout
21136
21137 \end_inset
21138 </cell>
21139 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21140 \begin_inset Text
21141
21142 \begin_layout Standard
21143 0.45 / 0.45 ms
21144 \end_layout
21145
21146 \end_inset
21147 </cell>
21148 </row>
21149 <row bottomline="true">
21150 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21151 \begin_inset Text
21152
21153 \begin_layout Standard
21154 int speed
21155 \begin_inset Foot
21156 status collapsed
21157
21158 \begin_layout Standard
21159 Execution time of printf("%d", -12345); standard 8051 @ 22.1184 MHz, empty
21160  putchar()
21161 \end_layout
21162
21163 \end_inset
21164
21165 ,
21166 \end_layout
21167
21168 \begin_layout Standard
21169 small / large
21170 \end_layout
21171
21172 \end_inset
21173 </cell>
21174 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21175 \begin_inset Text
21176
21177 \begin_layout Standard
21178 3.01 / 3.61 ms
21179 \end_layout
21180
21181 \end_inset
21182 </cell>
21183 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21184 \begin_inset Text
21185
21186 \begin_layout Standard
21187 3.01 / 3.61 ms
21188 \end_layout
21189
21190 \end_inset
21191 </cell>
21192 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21193 \begin_inset Text
21194
21195 \begin_layout Standard
21196 3.51 / 18.13 ms
21197 \end_layout
21198
21199 \end_inset
21200 </cell>
21201 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21202 \begin_inset Text
21203
21204 \begin_layout Standard
21205 0.22 / 0.22 ms
21206 \end_layout
21207
21208 \end_inset
21209 </cell>
21210 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21211 \begin_inset Text
21212
21213 \begin_layout Standard
21214 0.23 / 0.23 ms
21215 \end_layout
21216
21217 \end_inset
21218 </cell>
21219 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21220 \begin_inset Text
21221
21222 \begin_layout Standard
21223 0.25 / 0.25 ms
21224 \begin_inset Foot
21225 status collapsed
21226
21227 \begin_layout Standard
21228 printf_tiny integer speed is data dependent, worst case is 0.33 ms
21229 \end_layout
21230
21231 \end_inset
21232
21233
21234 \end_layout
21235
21236 \end_inset
21237 </cell>
21238 </row>
21239 <row bottomline="true">
21240 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21241 \begin_inset Text
21242
21243 \begin_layout Standard
21244 long speed
21245 \begin_inset Foot
21246 status collapsed
21247
21248 \begin_layout Standard
21249 Execution time of printf("%ld", -123456789); standard 8051 @ 22.1184 MHz,
21250  empty putchar()
21251 \end_layout
21252
21253 \end_inset
21254
21255 ,
21256 \end_layout
21257
21258 \begin_layout Standard
21259 small / large
21260 \end_layout
21261
21262 \end_inset
21263 </cell>
21264 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21265 \begin_inset Text
21266
21267 \begin_layout Standard
21268 5.37 / 6.31 ms
21269 \end_layout
21270
21271 \end_inset
21272 </cell>
21273 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21274 \begin_inset Text
21275
21276 \begin_layout Standard
21277 5.37 / 6.31 ms
21278 \end_layout
21279
21280 \end_inset
21281 </cell>
21282 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21283 \begin_inset Text
21284
21285 \begin_layout Standard
21286 8.71 / 40.65 ms
21287 \end_layout
21288
21289 \end_inset
21290 </cell>
21291 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21292 \begin_inset Text
21293
21294 \begin_layout Standard
21295 0.40 / 0.40 ms
21296 \end_layout
21297
21298 \end_inset
21299 </cell>
21300 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21301 \begin_inset Text
21302
21303 \begin_layout Standard
21304 0.40 / 0.40 ms
21305 \end_layout
21306
21307 \end_inset
21308 </cell>
21309 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21310 \begin_inset Text
21311
21312 \begin_layout Standard
21313 -
21314 \end_layout
21315
21316 \end_inset
21317 </cell>
21318 </row>
21319 <row bottomline="true">
21320 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21321 \begin_inset Text
21322
21323 \begin_layout Standard
21324 float speed
21325 \begin_inset Foot
21326 status collapsed
21327
21328 \begin_layout Standard
21329 Execution time of printf("%.3f", -12345.678); standard 8051 @ 22.1184 MHz,
21330  empty putchar()
21331 \end_layout
21332
21333 \end_inset
21334
21335 ,
21336 \end_layout
21337
21338 \begin_layout Standard
21339 small / large
21340 \end_layout
21341
21342 \end_inset
21343 </cell>
21344 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21345 \begin_inset Text
21346
21347 \begin_layout Standard
21348 -
21349 \end_layout
21350
21351 \end_inset
21352 </cell>
21353 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21354 \begin_inset Text
21355
21356 \begin_layout Standard
21357 7.49 / 22.47 ms
21358 \end_layout
21359
21360 \end_inset
21361 </cell>
21362 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21363 \begin_inset Text
21364
21365 \begin_layout Standard
21366 -
21367 \end_layout
21368
21369 \end_inset
21370 </cell>
21371 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21372 \begin_inset Text
21373
21374 \begin_layout Standard
21375 -
21376 \end_layout
21377
21378 \end_inset
21379 </cell>
21380 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21381 \begin_inset Text
21382
21383 \begin_layout Standard
21384 1.04 / 1.04 ms
21385 \end_layout
21386
21387 \end_inset
21388 </cell>
21389 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21390 \begin_inset Text
21391
21392 \begin_layout Standard
21393 -
21394 \end_layout
21395
21396 \end_inset
21397 </cell>
21398 </row>
21399 </lyxtabular>
21400
21401 \end_inset
21402
21403
21404 \end_layout
21405
21406 \begin_layout Subsubsection
21407 <malloc.h>
21408 \begin_inset LatexCommand \index{malloc.h}
21409
21410 \end_inset
21411
21412
21413 \end_layout
21414
21415 \begin_layout Standard
21416 As of SDCC 2.6.2 you no longer need to call an initialization routine before
21417  using dynamic memory allocation
21418 \begin_inset LatexCommand \index{dynamic memory allocation (malloc)}
21419
21420 \end_inset
21421
21422  and a default heap
21423 \begin_inset LatexCommand \index{heap (malloc)}
21424
21425 \end_inset
21426
21427  space of 1024 bytes is provided for malloc to allocate memory from.
21428  If you need a different heap size you need to recompile _heap.c with the
21429  required size defined in HEAP_SIZE.
21430  It is recommended to make a copy of this file into your project directory
21431  and compile it there with:
21432 \end_layout
21433
21434 \begin_layout Verse
21435
21436 \family typewriter
21437 sdcc -c _heap.c -D HEAD_SIZE=2048
21438 \end_layout
21439
21440 \begin_layout Standard
21441 And then link it with:
21442 \end_layout
21443
21444 \begin_layout Verse
21445
21446 \family typewriter
21447 sdcc main.rel _heap.rel
21448 \end_layout
21449
21450 \begin_layout Subsection
21451 Math functions (sinf, powf, sqrtf etc.)
21452 \end_layout
21453
21454 \begin_layout Subsubsection
21455 <math.h>
21456 \end_layout
21457
21458 \begin_layout Standard
21459 See definitions in file <math.h>.
21460 \end_layout
21461
21462 \begin_layout Subsection
21463 Other libraries
21464 \end_layout
21465
21466 \begin_layout Standard
21467 Libraries
21468 \begin_inset LatexCommand \index{Libraries}
21469
21470 \end_inset
21471
21472  included in SDCC should have a license at least as liberal as the GNU Lesser
21473  General Public License
21474 \begin_inset LatexCommand \index{GNU Lesser General Public License, LGPL}
21475
21476 \end_inset
21477
21478  
21479 \emph on
21480 LGPL
21481 \emph default
21482 .
21483 \end_layout
21484
21485 \begin_layout Standard
21486 \begin_inset Note Note
21487 status collapsed
21488
21489 \begin_layout Standard
21490 license statements for the libraries are missing.
21491  sdcc/device/lib/ser_ir.c
21492 \end_layout
21493
21494 \begin_layout Standard
21495 or _decdptr f.e.
21496  come with a GPL (as opposed to LGPL) License - this will not be liberal
21497  enough for many embedded programmers.
21498 \end_layout
21499
21500 \end_inset
21501
21502
21503 \end_layout
21504
21505 \begin_layout Standard
21506 If you have ported some library or want to share experience about some code
21507  which f.e.
21508  falls into any of these categories Busses (I
21509 \begin_inset Formula $^{\textrm{2}}$
21510 \end_inset
21511
21512 C, CAN, Ethernet, Profibus, Modbus, USB, SPI, JTAG ...), Media (IDE, Memory
21513  cards, eeprom, flash...), En-/Decryption, Remote debugging, Realtime kernel,
21514  Keyboard, LCD, RTC, FPGA, PID then the sdcc-user mailing list 
21515 \begin_inset LatexCommand \url{http://sourceforge.net/mail/?group_id=599}
21516
21517 \end_inset
21518
21519 \InsetSpace ~
21520 would certainly like to hear about it.
21521 \end_layout
21522
21523 \begin_layout Standard
21524 Programmers coding for embedded systems are not especially famous for being
21525  enthusiastic, so don't expect a big hurray but as the mailing list is searchabl
21526 e these references are very valuable.
21527  Let's help to create a climate where information is shared.
21528 \begin_inset VSpace bigskip
21529 \end_inset
21530
21531
21532 \end_layout
21533
21534 \begin_layout Section
21535 Memory Models
21536 \end_layout
21537
21538 \begin_layout Subsection
21539 MCS51 Memory Models
21540 \begin_inset LatexCommand \index{Memory model}
21541
21542 \end_inset
21543
21544
21545 \begin_inset LatexCommand \index{MCS51 memory model}
21546
21547 \end_inset
21548
21549
21550 \end_layout
21551
21552 \begin_layout Subsubsection
21553 Small, Medium and Large
21554 \end_layout
21555
21556 \begin_layout Standard
21557 SDCC allows three memory models for MCS51 code, 
21558 \shape slanted
21559 small, medium
21560 \shape default
21561  and 
21562 \shape slanted
21563 large
21564 \shape default
21565 .
21566  Modules compiled with different memory models should 
21567 \emph on
21568 never
21569 \emph default
21570  be combined together or the results would be unpredictable.
21571  The library routines supplied with the compiler are compiled as small,
21572  medium and large.
21573  The compiled library modules are contained in separate directories as small,
21574  medium and large so that you can link to the appropriate set.
21575 \end_layout
21576
21577 \begin_layout Standard
21578 When the medium or large model is used all variables declared without a
21579  storage class will be allocated into the external ram, this includes all
21580  parameters and local variables (for non-reentrant
21581 \begin_inset LatexCommand \index{reentrant}
21582
21583 \end_inset
21584
21585  functions).
21586  When the small model is used variables without storage class are allocated
21587  in the internal ram.
21588 \end_layout
21589
21590 \begin_layout Standard
21591 Judicious usage of the processor specific storage classes
21592 \begin_inset LatexCommand \index{Storage class}
21593
21594 \end_inset
21595
21596  and the 'reentrant' function type will yield much more efficient code,
21597  than using the large model.
21598  Several optimizations are disabled when the program is compiled using the
21599  large model, it is therefore recommended that the small model be used unless
21600  absolutely required.
21601 \end_layout
21602
21603 \begin_layout Subsubsection
21604 External Stack
21605 \begin_inset LatexCommand \label{sub:External-Stack}
21606
21607 \end_inset
21608
21609
21610 \begin_inset LatexCommand \index{stack}
21611
21612 \end_inset
21613
21614
21615 \begin_inset LatexCommand \index{External stack (mcs51)}
21616
21617 \end_inset
21618
21619
21620 \end_layout
21621
21622 \begin_layout Standard
21623 The external stack (-
21624 \begin_inset ERT
21625 status collapsed
21626
21627 \begin_layout Standard
21628
21629
21630 \backslash
21631 /
21632 \end_layout
21633
21634 \end_inset
21635
21636 -xstack option
21637 \begin_inset LatexCommand \index{-\/-xstack}
21638
21639 \end_inset
21640
21641 ) is located in pdata
21642 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
21643
21644 \end_inset
21645
21646  memory (usually at the start of the external ram segment) and uses all
21647  unused space in pdata (max.
21648  256 bytes).
21649  When -
21650 \begin_inset ERT
21651 status collapsed
21652
21653 \begin_layout Standard
21654
21655
21656 \backslash
21657 /
21658 \end_layout
21659
21660 \end_inset
21661
21662 -xstack option is used to compile the program, the parameters and local
21663  variables
21664 \begin_inset LatexCommand \index{local variables}
21665
21666 \end_inset
21667
21668  of all reentrant functions are allocated in this area.
21669  This option is provided for programs with large stack space requirements.
21670  When used with the -
21671 \begin_inset ERT
21672 status collapsed
21673
21674 \begin_layout Standard
21675
21676
21677 \backslash
21678 /
21679 \end_layout
21680
21681 \end_inset
21682
21683 -stack-auto
21684 \begin_inset LatexCommand \index{-\/-stack-auto}
21685
21686 \end_inset
21687
21688  option, all parameters and local variables are allocated on the external
21689  stack (note: support libraries will need to be recompiled with the same
21690  options.
21691  There is a predefined target in the library makefile).
21692 \end_layout
21693
21694 \begin_layout Standard
21695 The compiler outputs the higher order address byte of the external ram segment
21696  into port P2
21697 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
21698
21699 \end_inset
21700
21701  (see also section 
21702 \begin_inset LatexCommand \ref{sub:MCS51-variants}
21703
21704 \end_inset
21705
21706 ), therefore when using the External Stack option, this port 
21707 \emph on
21708 may not
21709 \emph default
21710  be used by the application program.
21711 \end_layout
21712
21713 \begin_layout Subsection
21714 DS390 Memory Model
21715 \begin_inset LatexCommand \index{Memory model}
21716
21717 \end_inset
21718
21719
21720 \begin_inset LatexCommand \index{DS390 memory model}
21721
21722 \end_inset
21723
21724
21725 \end_layout
21726
21727 \begin_layout Standard
21728 The only model supported is Flat 24
21729 \begin_inset LatexCommand \index{Flat 24 (DS390 memory model)}
21730
21731 \end_inset
21732
21733 .
21734  This generates code for the 24 bit contiguous addressing mode of the Dallas
21735  DS80C390 part.
21736  In this mode, up to four meg of external RAM or code space can be directly
21737  addressed.
21738  See the data sheets at www.dalsemi.com for further information on this part.
21739 \newline
21740
21741 \newline
21742 Note
21743  that the compiler does not generate any code to place the processor into
21744  24 bitmode (although 
21745 \emph on
21746 tinibios
21747 \emph default
21748  in the ds390 libraries will do that for you).
21749  If you don't use 
21750 \emph on
21751 tinibios
21752 \emph default
21753
21754 \begin_inset LatexCommand \index{Tinibios (DS390)}
21755
21756 \end_inset
21757
21758 , the boot loader or similar code must ensure that the processor is in 24
21759  bit contiguous addressing mode before calling the SDCC startup code.
21760 \newline
21761
21762 \newline
21763 Like
21764  the 
21765 \emph on
21766 -
21767 \begin_inset ERT
21768 status collapsed
21769
21770 \begin_layout Standard
21771
21772
21773 \backslash
21774 /
21775 \end_layout
21776
21777 \end_inset
21778
21779 -model-large
21780 \emph default
21781  option, variables will by default be placed into the XDATA segment.
21782  
21783 \newline
21784
21785 \newline
21786 Segments may be placed anywhere in the 4 meg address space using the usual
21787  -
21788 \begin_inset ERT
21789 status collapsed
21790
21791 \begin_layout Standard
21792
21793
21794 \backslash
21795 /
21796 \end_layout
21797
21798 \end_inset
21799
21800 -*-loc options.
21801  Note that if any segments are located above 64K, the -r flag must be passed
21802  to the linker to generate the proper segment relocations, and the Intel
21803  HEX output format must be used.
21804  The -r flag can be passed to the linker by using the option 
21805 \emph on
21806 -Wl-r
21807 \emph default
21808  on the SDCC command line.
21809  However, currently the linker can not handle code segments > 64k.
21810 \end_layout
21811
21812 \begin_layout Section
21813 Pragmas
21814 \begin_inset LatexCommand \label{sec:Pragmas}
21815
21816 \end_inset
21817
21818
21819 \begin_inset LatexCommand \index{Pragmas}
21820
21821 \end_inset
21822
21823
21824 \end_layout
21825
21826 \begin_layout Standard
21827 Pragmas are used to turn on and/or off certain compiler options.
21828  Some of them are closely related to corresponding command-line options
21829  (see section 
21830 \begin_inset LatexCommand \vref{sec:Command-Line-Options}
21831
21832 \end_inset
21833
21834 ).
21835 \newline
21836 Pragmas should be placed before and/or after a function, placing pragmas
21837  inside a function body could have unpredictable results.
21838 \newline
21839
21840 \newline
21841 SDCC supports the
21842  following #pragma directives:
21843 \end_layout
21844
21845 \begin_layout Itemize
21846
21847 \series bold
21848 save
21849 \series default
21850
21851 \begin_inset LatexCommand \index{\#pragma save}
21852
21853 \end_inset
21854
21855  - this will save most current options to the save/restore stack.
21856  See #pragma\InsetSpace ~
21857 restore.
21858 \end_layout
21859
21860 \begin_layout Itemize
21861
21862 \series bold
21863 restore
21864 \series default
21865
21866 \begin_inset LatexCommand \index{\#pragma restore}
21867
21868 \end_inset
21869
21870  - will restore saved options from the last save.
21871  saves & restores can be nested.
21872  SDCC uses a save/restore stack: save pushes current options to the stack,
21873  restore pulls current options from the stack.
21874  See #pragma\InsetSpace ~
21875 save.
21876 \newline
21877
21878 \end_layout
21879
21880 \begin_layout Itemize
21881
21882 \series bold
21883 callee_saves
21884 \series default
21885
21886 \begin_inset LatexCommand \index{\#pragma callee\_saves}
21887
21888 \end_inset
21889
21890
21891 \begin_inset LatexCommand \index{function prologue}
21892
21893 \end_inset
21894
21895  function1[,function2[,function3...]] 
21896 \begin_inset LatexCommand \label{ite:callee_saves-function1[,function2[,function3...]]--}
21897
21898 \end_inset
21899
21900 - The compiler by default uses a caller saves convention for register saving
21901  across function calls, however this can cause unnecessary register pushing
21902  and popping
21903 \begin_inset LatexCommand \index{push/pop}
21904
21905 \end_inset
21906
21907  when calling small functions from larger functions.
21908  This option can be used to switch off the register saving convention for
21909  the function names specified.
21910  The compiler will not save registers when calling these functions, extra
21911  code need to be manually inserted at the entry and exit for these functions
21912  to save and restore the registers used by these functions, this can SUBSTANTIAL
21913 LY reduce code and improve run time performance of the generated code.
21914  In the future the compiler (with inter procedural analysis) may be able
21915  to determine the appropriate scheme to use for each function call.
21916  If -
21917 \begin_inset ERT
21918 status collapsed
21919
21920 \begin_layout Standard
21921
21922
21923 \backslash
21924 /
21925 \end_layout
21926
21927 \end_inset
21928
21929 -callee-saves command line option is used (see page 
21930 \begin_inset LatexCommand \vpageref{lyx:--callee-saves-function1[,function2][,function3]...}
21931
21932 \end_inset
21933
21934 ), the function names specified in #pragma\InsetSpace ~
21935 callee_saves
21936 \begin_inset LatexCommand \index{\#pragma callee\_saves}
21937
21938 \end_inset
21939
21940  is appended to the list of functions specified in the command line.
21941 \end_layout
21942
21943 \begin_layout Itemize
21944
21945 \series bold
21946 exclude
21947 \series default
21948
21949 \begin_inset LatexCommand \index{\#pragma exclude}
21950
21951 \end_inset
21952
21953  none | {acc[,b[,dpl[,dph]]] - The exclude pragma disables the generation
21954  of pairs of push/pop
21955 \begin_inset LatexCommand \index{push/pop}
21956
21957 \end_inset
21958
21959  instructions in 
21960 \emph on
21961 I
21962 \emph default
21963 nterrupt
21964 \begin_inset LatexCommand \index{interrupt}
21965
21966 \end_inset
21967
21968  
21969 \emph on
21970 S
21971 \emph default
21972 ervice 
21973 \emph on
21974 R
21975 \emph default
21976 outines.
21977  The directive should be placed immediately before the ISR function definition
21978  and it affects ALL ISR functions following it.
21979  To enable the normal register saving for ISR functions use #pragma\InsetSpace ~
21980 exclude\InsetSpace ~
21981 none
21982 \begin_inset LatexCommand \index{\#pragma exclude}
21983
21984 \end_inset
21985
21986 .
21987  See also the related keyword _naked
21988 \begin_inset LatexCommand \index{\_naked}
21989
21990 \end_inset
21991
21992
21993 \begin_inset LatexCommand \index{\_\_naked}
21994
21995 \end_inset
21996
21997 .
21998 \end_layout
21999
22000 \begin_layout Itemize
22001
22002 \series bold
22003 less_pedantic
22004 \series default
22005
22006 \begin_inset LatexCommand \index{pedantic}
22007
22008 \end_inset
22009
22010
22011 \begin_inset LatexCommand \index{\#pragma less\_pedantic}
22012
22013 \end_inset
22014
22015  
22016 \begin_inset LatexCommand \label{ite:less_pedantic}
22017
22018 \end_inset
22019
22020 - the compiler will not warn you anymore for obvious mistakes, you're on
22021  your own now ;-( .
22022  See also the command line option -
22023 \begin_inset ERT
22024 status collapsed
22025
22026 \begin_layout Standard
22027
22028
22029 \backslash
22030 /
22031 \end_layout
22032
22033 \end_inset
22034
22035 -less-pedantic 
22036 \begin_inset LatexCommand \vpageref{lyx:--less-pedantic}
22037
22038 \end_inset
22039
22040 .
22041  
22042 \newline
22043 More specifically, the following warnings will be disabled: 
22044 \shape italic
22045 comparison is always [true/false] due to limited range of data type
22046 \shape default
22047  (94); 
22048 \shape italic
22049 overflow in implicit constant conversion
22050 \shape default
22051  (158); [the (in)famous] 
22052 \shape italic
22053 conditional flow changed by optimizer: so said EVELYN the modified DOG
22054 \shape default
22055  (110); 
22056 \shape italic
22057 function '[function name]' must return value
22058 \shape default
22059  (59).
22060  
22061 \newline
22062 Furthermore, warnings of less importance (of PEDANTIC and INFO warning
22063  level) are disabled, too, namely: 
22064 \shape italic
22065 constant value '[
22066 \begin_inset Note Note
22067 status collapsed
22068
22069 \begin_layout Standard
22070 dunno what comes here - this warning appears to be unused altogether
22071 \end_layout
22072
22073 \end_inset
22074
22075 ]', out of range
22076 \shape default
22077  (81); 
22078 \shape italic
22079 [left/right] shifting more than size of object changed to zero
22080 \shape default
22081  (116); 
22082 \shape italic
22083 unreachable code
22084 \shape default
22085  (126); 
22086 \shape italic
22087 integer overflow in expression
22088 \shape default
22089  (165); 
22090 \shape italic
22091 unmatched #pragma save and #pragma restore
22092 \shape default
22093  (170); 
22094 \shape italic
22095 comparison of 'signed char' with 'unsigned char' requires promotion to int
22096 \shape default
22097  (185); 
22098 \shape italic
22099 ISO C90 does not support flexible array members
22100 \shape default
22101  (187); 
22102 \shape italic
22103 extended stack by [number] bytes for compiler temp(s) :in function '[function\InsetSpace ~
22104 nam
22105 e]':\InsetSpace ~
22106 [
22107 \begin_inset Note Note
22108 status collapsed
22109
22110 \begin_layout Standard
22111 appears to be always blank - what was supposed to be here?
22112 \end_layout
22113
22114 \end_inset
22115
22116 ]
22117 \shape default
22118  (114); 
22119 \shape italic
22120 function '[function name]', # edges [number] , # nodes [number] , cyclomatic
22121  complexity [number]
22122 \shape default
22123  (121).
22124 \end_layout
22125
22126 \begin_layout Itemize
22127
22128 \series bold
22129 disable_warning
22130 \series default
22131  <nnnn>
22132 \begin_inset LatexCommand \index{\#pragma disable\_warning}
22133
22134 \end_inset
22135
22136  - the compiler will not warn you anymore about warning number <nnnn>.
22137 \end_layout
22138
22139 \begin_layout Itemize
22140
22141 \series bold
22142 nogcse
22143 \series default
22144
22145 \begin_inset LatexCommand \index{\#pragma nogcse}
22146
22147 \end_inset
22148
22149  - will stop global common subexpression elimination.
22150 \end_layout
22151
22152 \begin_layout Itemize
22153
22154 \series bold
22155 noinduction
22156 \series default
22157
22158 \begin_inset LatexCommand \index{\#pragma noinduction}
22159
22160 \end_inset
22161
22162  - will stop loop induction optimizations.
22163 \end_layout
22164
22165 \begin_layout Itemize
22166
22167 \series bold
22168 noinvariant
22169 \series default
22170
22171 \begin_inset LatexCommand \index{\#pragma noinvariant}
22172
22173 \end_inset
22174
22175  - will not do loop invariant optimizations.
22176  For more details see Loop Invariants in section
22177 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
22178
22179 \end_inset
22180
22181 .
22182 \end_layout
22183
22184 \begin_layout Itemize
22185
22186 \series bold
22187 noiv
22188 \series default
22189
22190 \begin_inset LatexCommand \index{\#pragma noiv}
22191
22192 \end_inset
22193
22194  - Do not generate interrupt
22195 \begin_inset LatexCommand \index{interrupt}
22196
22197 \end_inset
22198
22199  vector table
22200 \begin_inset LatexCommand \index{interrupt vector table}
22201
22202 \end_inset
22203
22204  entries for all ISR functions defined after the pragma.
22205  This is useful in cases where the interrupt vector table must be defined
22206  manually, or when there is a secondary, manually defined interrupt vector
22207  table (e.g.
22208  for the autovector feature of the Cypress EZ-USB FX2).
22209  More elegantly this can be achieved by obmitting the optional interrupt
22210  number after the interrupt keyword, see section 
22211 \begin_inset LatexCommand \ref{sub:Interrupt-Service-Routines}
22212
22213 \end_inset
22214
22215 \InsetSpace ~
22216 about interrupts.
22217 \end_layout
22218
22219 \begin_layout Itemize
22220
22221 \series bold
22222 nojtbound
22223 \series default
22224
22225 \begin_inset LatexCommand \index{\#pragma nojtbound}
22226
22227 \end_inset
22228
22229  - will not generate code for boundary value checking, when switch statements
22230  are turned into jump-tables (dangerous).
22231  For more details see section 
22232 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
22233
22234 \end_inset
22235
22236 .
22237 \end_layout
22238
22239 \begin_layout Itemize
22240
22241 \series bold
22242 noloopreverse
22243 \series default
22244
22245 \begin_inset LatexCommand \index{\#pragma noloopreverse}
22246
22247 \end_inset
22248
22249  - Will not do loop reversal optimization
22250 \end_layout
22251
22252 \begin_layout Itemize
22253
22254 \series bold
22255 nooverlay
22256 \series default
22257
22258 \begin_inset LatexCommand \index{\#pragma nooverlay}
22259
22260 \end_inset
22261
22262  - the compiler will not overlay the parameters and local variables of a
22263  function.
22264 \end_layout
22265
22266 \begin_layout Itemize
22267
22268 \series bold
22269 stackauto
22270 \series default
22271
22272 \begin_inset LatexCommand \index{\#pragma stackauto}
22273
22274 \end_inset
22275
22276 - See option -
22277 \begin_inset ERT
22278 status collapsed
22279
22280 \begin_layout Standard
22281
22282
22283 \backslash
22284 /
22285 \end_layout
22286
22287 \end_inset
22288
22289 -stack-auto
22290 \begin_inset LatexCommand \index{-\/-stack-auto}
22291
22292 \end_inset
22293
22294  and section 
22295 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
22296
22297 \end_inset
22298
22299  Parameters and Local Variables.
22300 \end_layout
22301
22302 \begin_layout Itemize
22303
22304 \series bold
22305 opt_code_speed
22306 \series default
22307  
22308 \begin_inset LatexCommand \index{\#pragma opt\_code\_speed}
22309
22310 \end_inset
22311
22312 - The compiler will optimize code generation towards fast code, possibly
22313  at the expense of code size.
22314  Currently this has little effect.
22315 \end_layout
22316
22317 \begin_layout Itemize
22318
22319 \series bold
22320 opt_code_size
22321 \series default
22322  
22323 \begin_inset LatexCommand \index{\#pragma opt\_code\_size}
22324
22325 \end_inset
22326
22327 - The compiler will optimize code generation towards compact code, possibly
22328  at the expense of code speed.
22329  Currently this has little effect.
22330 \end_layout
22331
22332 \begin_layout Itemize
22333
22334 \series bold
22335 opt_code_balanced
22336 \series default
22337  
22338 \begin_inset LatexCommand \index{\#pragma opt\_code\_balanced}
22339
22340 \end_inset
22341
22342 - The compiler will attempt to generate code that is both compact and fast,
22343  as long as meeting one goal is not a detriment to the other (this is the
22344  default).
22345  
22346 \end_layout
22347
22348 \begin_layout Itemize
22349
22350 \series bold
22351 std_sdcc89
22352 \series default
22353  
22354 \begin_inset LatexCommand \index{\#pragma std\_sdcc89}
22355
22356 \end_inset
22357
22358 - Generally follow the C89 standard, but allow SDCC features that conflict
22359  with the standard (default).
22360 \end_layout
22361
22362 \begin_layout Itemize
22363
22364 \series bold
22365 std_c89
22366 \series default
22367  
22368 \begin_inset LatexCommand \index{\#pragma std\_c89}
22369
22370 \end_inset
22371
22372 - Follow the C89 standard and disable SDCC features that conflict with the
22373  standard.
22374 \end_layout
22375
22376 \begin_layout Itemize
22377
22378 \series bold
22379 std_sdcc99
22380 \series default
22381  
22382 \begin_inset LatexCommand \index{\#pragma std\_sdcc99}
22383
22384 \end_inset
22385
22386 - Generally follow the C99 standard, but allow SDCC features that conflict
22387  with the standard (incomplete support).
22388 \end_layout
22389
22390 \begin_layout Itemize
22391
22392 \series bold
22393 std_c99
22394 \series default
22395  
22396 \begin_inset LatexCommand \index{\#pragma std\_c99}
22397
22398 \end_inset
22399
22400 - Follow the C99 standard and disable SDCC features that conflict with the
22401  standard (incomplete support).
22402 \end_layout
22403
22404 \begin_layout Itemize
22405
22406 \series bold
22407 codeseg
22408 \series default
22409  <name>
22410 \begin_inset LatexCommand \index{\#pragma codeseg}
22411
22412 \end_inset
22413
22414 - Use this name (max.
22415  8 characters) for the code segment.
22416  See option -
22417 \begin_inset ERT
22418 status collapsed
22419
22420 \begin_layout Standard
22421
22422
22423 \backslash
22424 /
22425 \end_layout
22426
22427 \end_inset
22428
22429 -codeseg.
22430 \end_layout
22431
22432 \begin_layout Itemize
22433
22434 \series bold
22435 constseg
22436 \series default
22437  <name>
22438 \begin_inset LatexCommand \index{\#pragma constseg}
22439
22440 \end_inset
22441
22442 - Use this name (max.
22443  8 characters) for the const segment.
22444  See option -
22445 \begin_inset ERT
22446 status collapsed
22447
22448 \begin_layout Standard
22449
22450
22451 \backslash
22452 /
22453 \end_layout
22454
22455 \end_inset
22456
22457 -constseg.
22458 \end_layout
22459
22460 \begin_layout Standard
22461 The preprocessor SDCPP
22462 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
22463
22464 \end_inset
22465
22466  supports the following #pragma directives:
22467 \end_layout
22468
22469 \begin_layout Itemize
22470
22471 \series bold
22472 pedantic_parse_number
22473 \series default
22474
22475 \begin_inset LatexCommand \index{pedantic}
22476
22477 \end_inset
22478
22479
22480 \begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
22481
22482 \end_inset
22483
22484  (+ | -) 
22485 \begin_inset LatexCommand \label{ite:pedantic_parse_number}
22486
22487 \end_inset
22488
22489 - Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed
22490  properly and the macro LO_B(3) gets expanded.
22491  Default is off.
22492  See also the -
22493 \begin_inset ERT
22494 status collapsed
22495
22496 \begin_layout Standard
22497
22498
22499 \backslash
22500 /
22501 \end_layout
22502
22503 \end_inset
22504
22505 -pedantic-parse-number command line option 
22506 \begin_inset LatexCommand \vpageref{lyx:-pedantic-parse-number}
22507
22508 \end_inset
22509
22510 .
22511  
22512 \newline
22513 Below is an example on how to use this pragma.
22514
22515 \emph on
22516  Note: this functionality is not in conformance with standard!
22517 \end_layout
22518
22519 \begin_layout Verse
22520
22521 \family typewriter
22522 #pragma pedantic_parse_number +
22523 \begin_inset LatexCommand \index{\#pragma pedantic\_parse\_number}
22524
22525 \end_inset
22526
22527
22528 \newline
22529
22530 \newline
22531 #define LO_B(x) ((x) & 0xff)
22532 \newline
22533
22534 \newline
22535 unsigned char foo(void)
22536 \newline
22537 {
22538 \newline
22539 \InsetSpace ~
22540 \InsetSpace ~
22541 \InsetSpace ~
22542 unsigned char c=0xfe-LO_B(3)
22543 ;
22544 \newline
22545
22546 \newline
22547 \InsetSpace ~
22548 \InsetSpace ~
22549 \InsetSpace ~
22550 return c;
22551 \newline
22552 }
22553 \newline
22554
22555 \end_layout
22556
22557 \begin_layout Itemize
22558
22559 \series bold
22560 preproc_asm
22561 \series default
22562
22563 \begin_inset LatexCommand \index{\#pragma preproc\_asm}
22564
22565 \end_inset
22566
22567  (+ | -) - switch _asm _endasm block preprocessing on / off.
22568  Default is on.
22569  You use this prama to define multilines of assembly code.
22570  This will prevent the preprocessor from changing the formating required
22571  by assembly code.
22572  Below is an example on how to use this pragma.
22573 \end_layout
22574
22575 \begin_layout Verse
22576
22577 \family typewriter
22578 #pragma preproc_asm -
22579 \begin_inset LatexCommand \index{\#pragma preproc\_asm}
22580
22581 \end_inset
22582
22583
22584 \newline
22585 #define MYDELAY _asm
22586 \newline
22587 \InsetSpace ~
22588 \InsetSpace ~
22589 \InsetSpace ~
22590 nop ;my assembly comment...
22591 \newline
22592 \InsetSpace ~
22593 \InsetSpace ~
22594 \InsetSpace ~
22595 nop
22596 \newline
22597 \InsetSpace ~
22598 \InsetSpace ~
22599 \InsetSpace ~
22600 nop
22601 \newline
22602 _endasm
22603 \newline
22604 #pragma preproc_asm
22605  +
22606 \newline
22607
22608 \newline
22609 void foo (void) 
22610 \newline
22611
22612 \newline
22613 \InsetSpace ~
22614 \InsetSpace ~
22615 \InsetSpace ~
22616  ...
22617  
22618 \newline
22619 \InsetSpace ~
22620 \InsetSpace ~
22621 \InsetSpace ~
22622  MYDELAY;
22623 \newline
22624 \InsetSpace ~
22625 \InsetSpace ~
22626 \InsetSpace ~
22627  ...
22628  
22629 \newline
22630
22631 \newline
22632
22633 \end_layout
22634
22635 \begin_layout Itemize
22636
22637 \series bold
22638 sdcc_hash
22639 \series default
22640
22641 \begin_inset LatexCommand \index{\#pragma sdcc\_hash}
22642
22643 \end_inset
22644
22645  (+ | -) - Allow "naked" hash in macro definition, for example:
22646 \newline
22647
22648 \family typewriter
22649 #define DIR_LO(x) #(x & 0xff)
22650 \family default
22651
22652 \newline
22653 Default is off.
22654  Below is an example on how to use this pragma.
22655 \end_layout
22656
22657 \begin_layout Verse
22658
22659 \family typewriter
22660 #pragma preproc_asm +
22661 \newline
22662 #pragma sdcc_hash +
22663 \begin_inset LatexCommand \index{\#pragma sdcc\_hash}
22664
22665 \end_inset
22666
22667
22668 \newline
22669
22670 \newline
22671 #define ROMCALL(x) 
22672 \backslash
22673
22674 \newline
22675 \InsetSpace ~
22676 \InsetSpace ~
22677 \InsetSpace ~
22678 mov R6_B3, #(x & 0xff) 
22679 \backslash
22680
22681 \newline
22682 \InsetSpace ~
22683 \InsetSpace ~
22684 \InsetSpace ~
22685 mov R7_B3, #((x >> 8) & 0xff) 
22686 \backslash
22687
22688 \newline
22689 \InsetSpace ~
22690 \InsetSpace ~
22691 \InsetSpace ~
22692 lcall __romcall
22693 \newline
22694
22695 \newline
22696 ...
22697 \newline
22698 _asm
22699 \newline
22700 ROMCALL(72)
22701 \newline
22702 _endasm;
22703 \newline
22704 ...
22705 \newline
22706
22707 \end_layout
22708
22709 \begin_layout Standard
22710 Some of the pragmas are intended to be used to turn-on or off certain optimizati
22711 ons which might cause the compiler to generate extra stack and/or data space
22712  to store compiler generated temporary variables.
22713  This usually happens in large functions.
22714  Pragma directives should be used as shown in the following example, they
22715  are used to control options and optimizations for a given function.
22716  
22717 \end_layout
22718
22719 \begin_layout Verse
22720
22721 \family typewriter
22722 #pragma save
22723 \begin_inset LatexCommand \index{\#pragma save}
22724
22725 \end_inset
22726
22727  \InsetSpace ~
22728 \InsetSpace ~
22729 \InsetSpace ~
22730 \InsetSpace ~
22731 \InsetSpace ~
22732 \InsetSpace ~
22733 \InsetSpace ~
22734 /* save the current settings */ 
22735 \newline
22736 #pragma nogcse
22737 \begin_inset LatexCommand \index{\#pragma nogcse}
22738
22739 \end_inset
22740
22741  \InsetSpace ~
22742 \InsetSpace ~
22743 \InsetSpace ~
22744 \InsetSpace ~
22745 \InsetSpace ~
22746 /* turnoff global subexpression elimination */ 
22747 \newline
22748 #pragma noinduction
22749 \begin_inset LatexCommand \index{\#pragma noinduction}
22750
22751 \end_inset
22752
22753  /* turn off induction optimizations */ 
22754 \newline
22755 int foo () 
22756 \newline
22757
22758 \newline
22759 \InsetSpace ~
22760  \InsetSpace ~
22761  ...
22762  
22763 \newline
22764 \InsetSpace ~
22765  \InsetSpace ~
22766  /* large code */ 
22767 \newline
22768 \InsetSpace ~
22769  \InsetSpace ~
22770  ...
22771  
22772 \newline
22773
22774 \newline
22775 #pragma restore
22776 \begin_inset LatexCommand \index{\#pragma restore}
22777
22778 \end_inset
22779
22780  /* turn the optimizations back on */
22781 \end_layout
22782
22783 \begin_layout Standard
22784 The compiler will generate a warning message when extra space is allocated.
22785  It is strongly recommended that the save and restore pragmas be used when
22786  changing options for a function.
22787 \newline
22788
22789 \newline
22790
22791 \newline
22792
22793 \end_layout
22794
22795 \begin_layout Section
22796 Defines Created by the Compiler
22797 \end_layout
22798
22799 \begin_layout Standard
22800 The compiler creates the following #defines
22801 \begin_inset LatexCommand \index{\#defines}
22802
22803 \end_inset
22804
22805
22806 \begin_inset LatexCommand \index{Defines created by the compiler}
22807
22808 \end_inset
22809
22810 :
22811 \newline
22812
22813 \end_layout
22814
22815 \begin_layout Standard
22816 \begin_inset Tabular
22817 <lyxtabular version="3" rows="15" columns="2">
22818 <features>
22819 <column alignment="left" valignment="top" leftline="true" width="3in">
22820 <column alignment="left" valignment="top" leftline="true" rightline="true" width="3in">
22821 <row topline="true" bottomline="true">
22822 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22823 \begin_inset Text
22824
22825 \begin_layout Standard
22826
22827 \series bold
22828 #define
22829 \end_layout
22830
22831 \end_inset
22832 </cell>
22833 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22834 \begin_inset Text
22835
22836 \begin_layout Standard
22837
22838 \series bold
22839 Description
22840 \end_layout
22841
22842 \end_inset
22843 </cell>
22844 </row>
22845 <row topline="true">
22846 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22847 \begin_inset Text
22848
22849 \begin_layout Standard
22850 SDCC
22851 \begin_inset LatexCommand \index{SDCC}
22852
22853 \end_inset
22854
22855  
22856 \end_layout
22857
22858 \end_inset
22859 </cell>
22860 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22861 \begin_inset Text
22862
22863 \begin_layout Standard
22864 Always defined.
22865  Since version 2.5.6 the version number as an int (ex.
22866  256)
22867 \end_layout
22868
22869 \end_inset
22870 </cell>
22871 </row>
22872 <row topline="true">
22873 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22874 \begin_inset Text
22875
22876 \begin_layout Standard
22877 SDCC_mcs51
22878 \begin_inset LatexCommand \index{SDCC\_mcs51}
22879
22880 \end_inset
22881
22882  or SDCC_ds390
22883 \begin_inset LatexCommand \index{SDCC\_ds390}
22884
22885 \end_inset
22886
22887  or SDCC_z80
22888 \begin_inset LatexCommand \index{SDCC\_z80}
22889
22890 \end_inset
22891
22892 , etc.
22893 \end_layout
22894
22895 \end_inset
22896 </cell>
22897 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22898 \begin_inset Text
22899
22900 \begin_layout Standard
22901 depending on the model used (e.g.: -mds390)
22902 \end_layout
22903
22904 \end_inset
22905 </cell>
22906 </row>
22907 <row topline="true">
22908 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22909 \begin_inset Text
22910
22911 \begin_layout Standard
22912 __mcs51
22913 \begin_inset LatexCommand \index{\_\_mcs51}
22914
22915 \end_inset
22916
22917 , __ds390
22918 \begin_inset LatexCommand \index{\_\_ds390}
22919
22920 \end_inset
22921
22922 , __hc08
22923 \begin_inset LatexCommand \index{\_\_hc08}
22924
22925 \end_inset
22926
22927 , __z80
22928 \begin_inset LatexCommand \index{\_\_z80}
22929
22930 \end_inset
22931
22932 , etc
22933 \end_layout
22934
22935 \end_inset
22936 </cell>
22937 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22938 \begin_inset Text
22939
22940 \begin_layout Standard
22941 depending on the model used (e.g.
22942  -mz80)
22943 \end_layout
22944
22945 \end_inset
22946 </cell>
22947 </row>
22948 <row topline="true">
22949 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22950 \begin_inset Text
22951
22952 \begin_layout Standard
22953 SDCC_STACK_AUTO
22954 \begin_inset LatexCommand \index{SDCC\_STACK\_AUTO}
22955
22956 \end_inset
22957
22958
22959 \end_layout
22960
22961 \end_inset
22962 </cell>
22963 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22964 \begin_inset Text
22965
22966 \begin_layout Standard
22967 when 
22968 \emph on
22969 -
22970 \begin_inset ERT
22971 status collapsed
22972
22973 \begin_layout Standard
22974
22975
22976 \backslash
22977 /
22978 \end_layout
22979
22980 \end_inset
22981
22982 -stack-auto
22983 \emph default
22984  option is used
22985 \end_layout
22986
22987 \end_inset
22988 </cell>
22989 </row>
22990 <row topline="true">
22991 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22992 \begin_inset Text
22993
22994 \begin_layout Standard
22995 SDCC_MODEL_SMALL
22996 \begin_inset LatexCommand \index{SDCC\_MODEL\_SMALL}
22997
22998 \end_inset
22999
23000
23001 \end_layout
23002
23003 \end_inset
23004 </cell>
23005 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23006 \begin_inset Text
23007
23008 \begin_layout Standard
23009 when 
23010 \emph on
23011 -
23012 \begin_inset ERT
23013 status collapsed
23014
23015 \begin_layout Standard
23016
23017
23018 \backslash
23019 /
23020 \end_layout
23021
23022 \end_inset
23023
23024 -model-small
23025 \emph default
23026  is used
23027 \end_layout
23028
23029 \end_inset
23030 </cell>
23031 </row>
23032 <row topline="true">
23033 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23034 \begin_inset Text
23035
23036 \begin_layout Standard
23037 SDCC_MODEL_MEDIUM
23038 \begin_inset LatexCommand \index{SDCC\_MODEL\_MEDIUM}
23039
23040 \end_inset
23041
23042
23043 \end_layout
23044
23045 \end_inset
23046 </cell>
23047 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23048 \begin_inset Text
23049
23050 \begin_layout Standard
23051 when 
23052 \emph on
23053 -
23054 \begin_inset ERT
23055 status collapsed
23056
23057 \begin_layout Standard
23058
23059
23060 \backslash
23061 /
23062 \end_layout
23063
23064 \end_inset
23065
23066 -model-medium
23067 \emph default
23068  is used
23069 \end_layout
23070
23071 \end_inset
23072 </cell>
23073 </row>
23074 <row topline="true">
23075 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23076 \begin_inset Text
23077
23078 \begin_layout Standard
23079 SDCC_MODEL_LARGE
23080 \begin_inset LatexCommand \index{SDCC\_MODEL\_LARGE}
23081
23082 \end_inset
23083
23084
23085 \end_layout
23086
23087 \end_inset
23088 </cell>
23089 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23090 \begin_inset Text
23091
23092 \begin_layout Standard
23093 when 
23094 \emph on
23095 -
23096 \begin_inset ERT
23097 status collapsed
23098
23099 \begin_layout Standard
23100
23101
23102 \backslash
23103 /
23104 \end_layout
23105
23106 \end_inset
23107
23108 -model-large
23109 \emph default
23110  is used
23111 \end_layout
23112
23113 \end_inset
23114 </cell>
23115 </row>
23116 <row topline="true">
23117 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23118 \begin_inset Text
23119
23120 \begin_layout Standard
23121 SDCC_USE_XSTACK
23122 \begin_inset LatexCommand \index{SDCC\_USE\_XSTACK}
23123
23124 \end_inset
23125
23126
23127 \end_layout
23128
23129 \end_inset
23130 </cell>
23131 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23132 \begin_inset Text
23133
23134 \begin_layout Standard
23135 when 
23136 \emph on
23137 -
23138 \begin_inset ERT
23139 status collapsed
23140
23141 \begin_layout Standard
23142
23143
23144 \backslash
23145 /
23146 \end_layout
23147
23148 \end_inset
23149
23150 -xstack
23151 \emph default
23152  option is used
23153 \end_layout
23154
23155 \end_inset
23156 </cell>
23157 </row>
23158 <row topline="true">
23159 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23160 \begin_inset Text
23161
23162 \begin_layout Standard
23163 SDCC_STACK_TENBIT
23164 \begin_inset LatexCommand \index{SDCC\_STACK\_TENBIT}
23165
23166 \end_inset
23167
23168  
23169 \end_layout
23170
23171 \end_inset
23172 </cell>
23173 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23174 \begin_inset Text
23175
23176 \begin_layout Standard
23177 when 
23178 \emph on
23179 -mds390
23180 \emph default
23181  is used
23182 \end_layout
23183
23184 \end_inset
23185 </cell>
23186 </row>
23187 <row topline="true">
23188 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23189 \begin_inset Text
23190
23191 \begin_layout Standard
23192 SDCC_MODEL_FLAT24
23193 \begin_inset LatexCommand \index{SDCC\_MODEL\_FLAT24}
23194
23195 \end_inset
23196
23197
23198 \end_layout
23199
23200 \end_inset
23201 </cell>
23202 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23203 \begin_inset Text
23204
23205 \begin_layout Standard
23206 when 
23207 \emph on
23208 -mds390
23209 \emph default
23210  is used
23211 \end_layout
23212
23213 \end_inset
23214 </cell>
23215 </row>
23216 <row topline="true">
23217 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23218 \begin_inset Text
23219
23220 \begin_layout Standard
23221 SDCC_REVISION
23222 \begin_inset LatexCommand \index{SDCC\_REVISION}
23223
23224 \end_inset
23225
23226
23227 \end_layout
23228
23229 \end_inset
23230 </cell>
23231 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23232 \begin_inset Text
23233
23234 \begin_layout Standard
23235 Always defined.
23236  SDCC svn revision number
23237 \end_layout
23238
23239 \end_inset
23240 </cell>
23241 </row>
23242 <row topline="true">
23243 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23244 \begin_inset Text
23245
23246 \begin_layout Standard
23247 SDCC_PARMS_IN_BANK1
23248 \begin_inset LatexCommand \index{SDCC\_PARMS\_IN\_BANK1}
23249
23250 \end_inset
23251
23252
23253 \end_layout
23254
23255 \end_inset
23256 </cell>
23257 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23258 \begin_inset Text
23259
23260 \begin_layout Standard
23261 when 
23262 \emph on
23263 -
23264 \begin_inset ERT
23265 status collapsed
23266
23267 \begin_layout Standard
23268
23269
23270 \backslash
23271 /
23272 \end_layout
23273
23274 \end_inset
23275
23276 -parms-in-bank1
23277 \emph default
23278  is used
23279 \end_layout
23280
23281 \end_inset
23282 </cell>
23283 </row>
23284 <row topline="true">
23285 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23286 \begin_inset Text
23287
23288 \begin_layout Standard
23289 SDCC_FLOAT_REENT
23290 \begin_inset LatexCommand \index{SDCC\_MODEL\_FLAT24}
23291
23292 \end_inset
23293
23294
23295 \end_layout
23296
23297 \end_inset
23298 </cell>
23299 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23300 \begin_inset Text
23301
23302 \begin_layout Standard
23303 when 
23304 \emph on
23305 -
23306 \begin_inset ERT
23307 status collapsed
23308
23309 \begin_layout Standard
23310
23311
23312 \backslash
23313 /
23314 \end_layout
23315
23316 \end_inset
23317
23318 -float-reent
23319 \emph default
23320  is used
23321 \end_layout
23322
23323 \end_inset
23324 </cell>
23325 </row>
23326 <row topline="true" bottomline="true">
23327 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23328 \begin_inset Text
23329
23330 \begin_layout Standard
23331 SDCC_INT_LONG_REENT
23332 \begin_inset LatexCommand \index{SDCC\_INT\_LONG\_REENT}
23333
23334 \end_inset
23335
23336
23337 \end_layout
23338
23339 \end_inset
23340 </cell>
23341 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23342 \begin_inset Text
23343
23344 \begin_layout Standard
23345 when 
23346 \emph on
23347 -
23348 \begin_inset ERT
23349 status collapsed
23350
23351 \begin_layout Standard
23352
23353
23354 \backslash
23355 /
23356 \end_layout
23357
23358 \end_inset
23359
23360 -int-long-reent
23361 \emph default
23362  is used
23363 \end_layout
23364
23365 \end_inset
23366 </cell>
23367 </row>
23368 </lyxtabular>
23369
23370 \end_inset
23371
23372
23373 \end_layout
23374
23375 \begin_layout Chapter
23376 Notes on supported Processors
23377 \end_layout
23378
23379 \begin_layout Section
23380 MCS51 variants
23381 \begin_inset LatexCommand \label{sub:MCS51-variants}
23382
23383 \end_inset
23384
23385
23386 \begin_inset LatexCommand \index{MCS51 variants}
23387
23388 \end_inset
23389
23390
23391 \end_layout
23392
23393 \begin_layout Standard
23394 MCS51 processors are available from many vendors and come in many different
23395  flavours.
23396  While they might differ considerably in respect to Special Function Registers
23397  the core MCS51 is usually not modified or is kept compatible.
23398  
23399 \end_layout
23400
23401 \begin_layout Subsection
23402 pdata access by SFR 
23403 \end_layout
23404
23405 \begin_layout Standard
23406 With the upcome of devices with internal xdata and flash memory devices
23407  using port P2
23408 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
23409
23410 \end_inset
23411
23412  as dedicated I/O port is becoming more popular.
23413  Switching the high byte for pdata
23414 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
23415
23416 \end_inset
23417
23418  access which was formerly done by port P2 is then achieved by a Special
23419  Function Register
23420 \begin_inset LatexCommand \index{sfr}
23421
23422 \end_inset
23423
23424 .
23425  In well-established MCS51 tradition the address of this 
23426 \emph on
23427 sfr
23428 \emph default
23429  is where the chip designers decided to put it.
23430  Needless to say that they didn't agree on a common name either.
23431  So that the startup code can correctly initialize xdata variables, you
23432  should define an sfr with the name _XPAGE
23433 \family typewriter
23434
23435 \begin_inset LatexCommand \index{\_XPAGE (mcs51)}
23436
23437 \end_inset
23438
23439
23440 \family default
23441  at the appropriate location if the default, port P2, is not used for this.
23442  Some examples are:
23443 \end_layout
23444
23445 \begin_layout Verse
23446
23447 \family typewriter
23448 __sfr __at (0x85) _XPAGE; /* Ramtron VRS51 family a.k.a.
23449  MPAGE */
23450 \end_layout
23451
23452 \begin_layout Verse
23453
23454 \family typewriter
23455 __sfr __at (0x92) _XPAGE; /* Cypress EZ-USB family, Texas Instruments (Chipcon)
23456  a.k.a.
23457  MPAGE */
23458 \end_layout
23459
23460 \begin_layout Verse
23461
23462 \family typewriter
23463 __sfr __at (0x91) _XPAGE; /* Infineon (Siemens) C500 family a.k.a.
23464  XPAGE */
23465 \end_layout
23466
23467 \begin_layout Verse
23468
23469 \family typewriter
23470 __sfr __at (0xaf) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
23471  EMI0CN */
23472 \end_layout
23473
23474 \begin_layout Verse
23475
23476 \family typewriter
23477 __sfr __at (0xaa) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
23478  EMI0CN */
23479 \end_layout
23480
23481 \begin_layout Standard
23482 For more exotic implementations further customizations may be needed.
23483  See section 
23484 \begin_inset LatexCommand \ref{sub:Startup-Code}
23485
23486 \end_inset
23487
23488  for other possibilities.
23489 \end_layout
23490
23491 \begin_layout Subsection
23492 Other Features available by SFR
23493 \end_layout
23494
23495 \begin_layout Standard
23496 Some MCS51 variants offer features like Double DPTR
23497 \begin_inset LatexCommand \index{DPTR}
23498
23499 \end_inset
23500
23501 , multiple DPTR, decrementing DPTR, 16x16 Multiply.
23502  These are currently not used for the MCS51 port.
23503  If you absolutely need them you can fall back to inline assembly or submit
23504  a patch to SDCC.
23505 \end_layout
23506
23507 \begin_layout Subsection
23508 Bankswitching
23509 \end_layout
23510
23511 \begin_layout Standard
23512 Bankswitching
23513 \begin_inset LatexCommand \index{Bankswitching}
23514
23515 \end_inset
23516
23517  (a.k.a.
23518  code banking
23519 \begin_inset LatexCommand \index{code banking}
23520
23521 \end_inset
23522
23523 ) is a technique to increase the code space above the 64k limit of the 8051.
23524 \end_layout
23525
23526 \begin_layout Subsubsection
23527 Hardware
23528 \end_layout
23529
23530 \begin_layout Standard
23531 \begin_inset Tabular
23532 <lyxtabular version="3" rows="3" columns="4">
23533 <features>
23534 <column alignment="center" valignment="top" width="0">
23535 <column alignment="center" valignment="top" leftline="true" width="0">
23536 <column alignment="center" valignment="top" leftline="true" width="0">
23537 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
23538 <row topline="true" bottomline="true">
23539 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
23540 \begin_inset Text
23541
23542 \begin_layout Standard
23543 8000-FFFF
23544 \end_layout
23545
23546 \end_inset
23547 </cell>
23548 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23549 \begin_inset Text
23550
23551 \begin_layout Standard
23552 bank1
23553 \end_layout
23554
23555 \end_inset
23556 </cell>
23557 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23558 \begin_inset Text
23559
23560 \begin_layout Standard
23561 bank2
23562 \end_layout
23563
23564 \end_inset
23565 </cell>
23566 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23567 \begin_inset Text
23568
23569 \begin_layout Standard
23570 bank3
23571 \end_layout
23572
23573 \end_inset
23574 </cell>
23575 </row>
23576 <row topline="true" bottomline="true">
23577 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
23578 \begin_inset Text
23579
23580 \begin_layout Standard
23581 0000-7FFF
23582 \end_layout
23583
23584 \end_inset
23585 </cell>
23586 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23587 \begin_inset Text
23588
23589 \begin_layout Standard
23590 common
23591 \end_layout
23592
23593 \end_inset
23594 </cell>
23595 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
23596 \begin_inset Text
23597
23598 \begin_layout Standard
23599
23600 \end_layout
23601
23602 \end_inset
23603 </cell>
23604 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23605 \begin_inset Text
23606
23607 \begin_layout Standard
23608
23609 \end_layout
23610
23611 \end_inset
23612 </cell>
23613 </row>
23614 <row>
23615 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
23616 \begin_inset Text
23617
23618 \begin_layout Standard
23619 SiLabs C8051F120 example
23620 \end_layout
23621
23622 \end_inset
23623 </cell>
23624 <cell multicolumn="2" alignment="center" valignment="top" usebox="none">
23625 \begin_inset Text
23626
23627 \begin_layout Standard
23628
23629 \end_layout
23630
23631 \end_inset
23632 </cell>
23633 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23634 \begin_inset Text
23635
23636 \begin_layout Standard
23637
23638 \end_layout
23639
23640 \end_inset
23641 </cell>
23642 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23643 \begin_inset Text
23644
23645 \begin_layout Standard
23646
23647 \end_layout
23648
23649 \end_inset
23650 </cell>
23651 </row>
23652 </lyxtabular>
23653
23654 \end_inset
23655
23656
23657 \newline
23658
23659 \newline
23660 Usually the hardware uses some sfr (an output port or an internal sfr) to
23661  select a bank and put it in the banked area of the memory map.
23662  The selected bank usually becomes active immediately upon assignment to
23663  this sfr and when running inside a bank it will switch out this code it
23664  is currently running.
23665  Therefor you cannot jump or call directly from one bank to another and
23666  need to use a so-called trampoline in the common area.
23667  For SDCC an example trampoline is in crtbank.asm and you may need to change
23668  it to your 8051 derivative or schematic.
23669  The presented code is written for the C8051F120.
23670 \newline
23671
23672 \newline
23673 When calling a banked function
23674  SDCC will put the LSB of the functions address in register R0, the MSB
23675  in R1 and the bank in R2 and then call this trampoline 
23676 \emph on
23677 __sdcc_banked_call
23678 \emph default
23679 .
23680  The current selected bank is saved on the stack, the new bank is selected
23681  and an indirect jump is made.
23682  When the banked function returns it jumps to 
23683 \emph on
23684 __sdcc_banked_ret
23685 \emph default
23686  which restores the previous bank and returns to the caller.
23687 \end_layout
23688
23689 \begin_layout Subsubsection
23690 Software
23691 \end_layout
23692
23693 \begin_layout Standard
23694 When writing banked software using SDCC you need to use some special keywords
23695  and options.
23696  You also need to take over a bit of work from the linker.
23697 \newline
23698
23699 \newline
23700 To create a function
23701  that can be called from another bank it requires the keyword 
23702 \emph on
23703 banked
23704 \emph default
23705
23706 \begin_inset LatexCommand \index{banked}
23707
23708 \end_inset
23709
23710 .
23711  The caller must see this in the prototype of the callee and the callee
23712  needs it for a proper return.
23713  Called functions within the same bank as the caller do not need the 
23714 \emph on
23715 banked
23716 \emph default
23717  keyword nor do functions in the common area.
23718  Beware: SDCC does not know or check if functions are in the same bank.
23719  This is your responsibility!
23720 \newline
23721
23722 \newline
23723 Normally all functions you write end up in
23724  the segment CSEG.
23725  If you want a function explicitly to reside in the common area put it in
23726  segment HOME.
23727  This applies for instance to interrupt service routines as they should
23728  not be banked.
23729 \end_layout
23730
23731 \begin_layout Standard
23732 Functions that need to be in a switched bank must be put in a named segment.
23733  The name can be mostly anything upto eight characters (e.g.
23734  BANK1).
23735  To do this you either use -
23736 \begin_inset ERT
23737 status collapsed
23738
23739 \begin_layout Standard
23740
23741
23742 \backslash
23743 /
23744 \end_layout
23745
23746 \end_inset
23747
23748 -codeseg BANK1 (See 
23749 \begin_inset LatexCommand \ref{lyx:-codeseg}
23750
23751 \end_inset
23752
23753 ) on the command line when compiling or #pragma codeseg BANK1 (See 
23754 \begin_inset LatexCommand \ref{sec:Pragmas}
23755
23756 \end_inset
23757
23758 ) at the top of the C source file.
23759  The segment name always applies to the whole source file and generated
23760  object so functions for different banks need to be defined in different
23761  source files.
23762 \newline
23763
23764 \newline
23765 When linking your objects you need to tell the linker where
23766  to put your segments.
23767  To do this you use the following command line option to SDCC: -Wl-b BANK1=0x180
23768 00 (See 
23769 \begin_inset LatexCommand \ref{lyx:-Wl option}
23770
23771 \end_inset
23772
23773 ).
23774  This sets the virtual start address of this segment.
23775  It sets the banknumber to 0x01 and maps the bank to 0x8000 and up.
23776  The linker will not check for overflows, again this is your responsibility.
23777 \end_layout
23778
23779 \begin_layout Standard
23780 \begin_inset VSpace bigskip
23781 \end_inset
23782
23783
23784 \end_layout
23785
23786 \begin_layout Section
23787 DS400 port
23788 \end_layout
23789
23790 \begin_layout Standard
23791 The DS80C400
23792 \begin_inset LatexCommand \index{DS80C400}
23793
23794 \end_inset
23795
23796
23797 \begin_inset LatexCommand \index{DS400}
23798
23799 \end_inset
23800
23801  microcontroller has a rich set of peripherals.
23802  In its built-in ROM library it includes functions to access some of the
23803  features, among them is a TCP stack with IP4 and IP6 support.
23804  Library headers (currently in beta status) and other files are provided
23805  at 
23806 \size footnotesize
23807
23808 \begin_inset LatexCommand \url{ftp://ftp.dalsemi.com/pub/tini/ds80c400/c_libraries/sdcc/index.html}
23809
23810 \end_inset
23811
23812 .
23813  
23814 \begin_inset VSpace bigskip
23815 \end_inset
23816
23817
23818 \end_layout
23819
23820 \begin_layout Section
23821 The Z80 and gbz80 port
23822 \end_layout
23823
23824 \begin_layout Standard
23825 SDCC can target both the Zilog Z80
23826 \begin_inset LatexCommand \index{Z80}
23827
23828 \end_inset
23829
23830  and the Nintendo Gameboy's Z80-like gbz80
23831 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
23832
23833 \end_inset
23834
23835 .
23836  The Z80 port is passed through the same 
23837 \emph on
23838 regressions tests
23839 \begin_inset LatexCommand \index{Regression test}
23840
23841 \end_inset
23842
23843
23844 \emph default
23845  (see section 
23846 \begin_inset LatexCommand \ref{sec:Quality-control}
23847
23848 \end_inset
23849
23850 ) as the MCS51 and DS390 ports, so floating point support, support for long
23851  variables and bitfield support is fine.
23852  See mailing lists and forums about interrupt routines.
23853 \end_layout
23854
23855 \begin_layout Standard
23856 As always, the code is the authoritative reference - see z80/ralloc.c and
23857  z80/gen.c.
23858  The stack
23859 \begin_inset LatexCommand \index{Z80!stack}
23860
23861 \end_inset
23862
23863  frame is similar to that generated by the IAR Z80 compiler.
23864  IX is used as the base pointer, HL and IY are used as a temporary registers,
23865  and BC and DE are available for holding variables.
23866  Return values
23867 \begin_inset LatexCommand \index{Z80!return value}
23868
23869 \end_inset
23870
23871  for the Z80 port are stored in L (one byte), HL (two bytes), or DEHL (four
23872  bytes).
23873  The gbz80 port use the same set of registers for the return values, but
23874  in a different order of significance: E (one byte), DE (two bytes), or
23875  HLDE (four bytes).
23876 \begin_inset VSpace bigskip
23877 \end_inset
23878
23879
23880 \end_layout
23881
23882 \begin_layout Section
23883 The HC08 port
23884 \end_layout
23885
23886 \begin_layout Standard
23887 The port to the Freescale/Motorola HC08
23888 \begin_inset LatexCommand \index{HC08}
23889
23890 \end_inset
23891
23892  family has been added in October 2003, and is still undergoing some basic
23893  development.
23894  The code generator is complete, but the register allocation is still quite
23895  unoptimized.
23896  Some of the SDCC's standard C library functions have embedded non-HC08
23897  inline assembly and so are not yet usable.
23898 \end_layout
23899
23900 \begin_layout Standard
23901 The HC08 port passes the regression test suite (see section 
23902 \begin_inset LatexCommand \ref{sec:Quality-control}
23903
23904 \end_inset
23905
23906 ).
23907 \begin_inset VSpace bigskip
23908 \end_inset
23909
23910
23911 \end_layout
23912
23913 \begin_layout Section
23914 The PIC14
23915 \begin_inset LatexCommand \index{PIC14}
23916
23917 \end_inset
23918
23919  port
23920 \end_layout
23921
23922 \begin_layout Standard
23923 The PIC14 port adds support for Microchip
23924 \begin_inset LatexCommand \index{Microchip}
23925
23926 \end_inset
23927
23928
23929 \begin_inset Formula $^{\text{TM}}$
23930 \end_inset
23931
23932  PIC
23933 \begin_inset LatexCommand \index{PIC14}
23934
23935 \end_inset
23936
23937
23938 \begin_inset Formula $^{\text{TM}}$
23939 \end_inset
23940
23941  MCUs with 14 bit wide instructions.
23942  This port is not yet mature and still lacks many features.
23943  However, it can work for simple code.
23944 \end_layout
23945
23946 \begin_layout Standard
23947 Currently supported devices include:
23948 \end_layout
23949
23950 \begin_layout Standard
23951 12F: 629, 635, 675, 683
23952 \end_layout
23953
23954 \begin_layout Standard
23955 16C: 432, 433
23956 \end_layout
23957
23958 \begin_layout Standard
23959 16C: 554, 557, 558
23960 \end_layout
23961
23962 \begin_layout Standard
23963 16C: 62, 620, 620a, 621, 621a, 622, 622a, 63a, 65b
23964 \end_layout
23965
23966 \begin_layout Standard
23967 16C: 71, 710, 711, 715, 717, 72, 73b, 745, 74b, 765, 770, 771, 773, 774,
23968  781, 782
23969 \end_layout
23970
23971 \begin_layout Standard
23972 16C: 925, 926
23973 \end_layout
23974
23975 \begin_layout Standard
23976 16CR: 620a, 73, 74, 76, 77
23977 \end_layout
23978
23979 \begin_layout Standard
23980 16F: 616, 627, 627a, 628, 628a, 630, 636, 639, 648, 648a, 676, 684, 685,
23981  687, 688, 689, 690
23982 \end_layout
23983
23984 \begin_layout Standard
23985 16F: 716, 72, 73, 737, 74, 747, 76, 767, 77, 777, 785
23986 \end_layout
23987
23988 \begin_layout Standard
23989 16F: 818, 819, 84, 84a, 87, 870, 871, 872, 873, 873a, 874, 874a, 876, 876a,
23990  877, 877a, 88, 886, 887
23991 \end_layout
23992
23993 \begin_layout Standard
23994 16F: 913, 914, 916, 917, 946
23995 \end_layout
23996
23997 \begin_layout Standard
23998 26HV: 626, 785
23999 \end_layout
24000
24001 \begin_layout Standard
24002 An up-to-date list of currently supported devices can be obtained via 
24003 \family typewriter
24004 sdcc -mpic14 -phelp foo.c
24005 \family default
24006  (foo.c must exist...).
24007 \end_layout
24008
24009 \begin_layout Subsection
24010 PIC Code Pages
24011 \begin_inset LatexCommand \index{code page (pic14)}
24012
24013 \end_inset
24014
24015  and Memory Banks
24016 \begin_inset LatexCommand \index{Memory bank (pic14)}
24017
24018 \end_inset
24019
24020
24021 \end_layout
24022
24023 \begin_layout Standard
24024 The linker organizes allocation for the code page and RAM banks.
24025  It does not have intimate knowledge of the code flow.
24026  It will put all the code section of a single .asm file into a single code
24027  page.
24028  In order to make use of multiple code pages, separate asm files must be
24029  used.
24030  The compiler assigns all 
24031 \emph on
24032 static
24033 \emph default
24034  functions of a single .c file into the same code page.
24035 \newline
24036
24037 \newline
24038 To get the best results,
24039  follow these guidelines:
24040 \end_layout
24041
24042 \begin_layout Enumerate
24043 Make local functions static, as non static functions require code page selection
24044  overhead.
24045 \newline
24046 Due to the way sdcc handles functions, place called functions prior
24047  to calling functions in the file wherever possible: Otherwise sdcc will
24048  insert unneccessary pagesel directives around the call, believing that
24049  the called function is externally defined.
24050 \end_layout
24051
24052 \begin_layout Enumerate
24053 For devices that have multiple code pages it is more efficient to use the
24054  same number of files as pages: Use up to 4 separate .c files for the 16F877,
24055  but only 2 files for the 16F874.
24056  This way the linker can put the code for each file into different code
24057  pages and there will be less page selection overhead.
24058 \end_layout
24059
24060 \begin_layout Enumerate
24061 And as for any 8 bit micro (especially for PIC14 as they have a very simple
24062  instruction set), use `unsigned char' wherever possible instead of `int'.
24063 \end_layout
24064
24065 \begin_layout Subsection
24066 Adding New Devices to the Port 
24067 \end_layout
24068
24069 \begin_layout Standard
24070 Adding support for a new 14
24071 \begin_inset ERT
24072 status open
24073
24074 \begin_layout Standard
24075
24076
24077 \backslash
24078 ,
24079 \end_layout
24080
24081 \end_inset
24082
24083 bit PIC MCU requires the following steps:
24084 \end_layout
24085
24086 \begin_layout Enumerate
24087 Create a new device description.
24088 \newline
24089 Each device is described in two files: pic16f*.h
24090  and pic16f*.c.
24091  These files primarily define SFRs, structs to access their bits, and symbolic
24092  configuration options.
24093  Both files can be generated from gputils' .inc files using the perl script
24094  
24095 \family typewriter
24096 support/scripts/inc2h.pl
24097 \family default
24098 .
24099  This file also contains further instructions on how to proceed.
24100 \end_layout
24101
24102 \begin_layout Enumerate
24103 Copy the .h file into SDCC's include path and either add the .c file to your
24104  project or copy it to 
24105 \family typewriter
24106 device/lib/pic/libdev
24107 \family default
24108 .
24109  Afterwards, rebuild and install the libraries.
24110 \end_layout
24111
24112 \begin_layout Enumerate
24113 Edit pic14devices.txt in SDCC's include path (
24114 \family typewriter
24115 device/include/pic/
24116 \family default
24117  in the source tree or 
24118 \family typewriter
24119 /usr/local/share/sdcc/include/pic
24120 \family default
24121  after installation).
24122 \newline
24123 You need to add a device specification here to make
24124  the memory layout (code banks, RAM, aliased memory regions, ...) known to
24125  the compiler.
24126  Probably you can copy and modify an existing entry.
24127  The file format is documented at the top of the file.
24128 \end_layout
24129
24130 \begin_layout Subsection
24131 Interrupt Code
24132 \end_layout
24133
24134 \begin_layout Standard
24135 For the interrupt function, use the keyword `__interrupt'
24136 \begin_inset LatexCommand \index{PIC14!interrupt}
24137
24138 \end_inset
24139
24140  with level number of 0 (PIC14 only has 1 interrupt so this number is only
24141  there to avoid a syntax error - it ought to be fixed).
24142  E.g.:
24143 \end_layout
24144
24145 \begin_layout Verse
24146
24147 \family typewriter
24148 void Intr(void) __interrupt 0
24149 \newline
24150 {
24151 \newline
24152 \InsetSpace ~
24153 \InsetSpace ~
24154 T0IF = 0; /* Clear timer interrupt */
24155 \newline
24156 }
24157 \end_layout
24158
24159 \begin_layout Subsection
24160 Linking and Assembling
24161 \end_layout
24162
24163 \begin_layout Standard
24164 For assembling you can use either GPUTILS'
24165 \begin_inset LatexCommand \index{gputils (pic tools)}
24166
24167 \end_inset
24168
24169  gpasm.exe or MPLAB's mpasmwin.exe.
24170  GPUTILS are available from 
24171 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
24172
24173 \end_inset
24174
24175 .
24176  For linking you can use either GPUTILS' gplink or MPLAB's mplink.exe.
24177  If you use MPLAB and an interrupt function then the linker script file
24178  vectors section will need to be enlarged to link with mplink.
24179 \newline
24180
24181 \newline
24182 Here is a 
24183 \family typewriter
24184 Makefile
24185 \family default
24186  using GPUTILS:
24187 \end_layout
24188
24189 \begin_layout Verse
24190
24191 \family typewriter
24192 .c.o:
24193 \newline
24194 \InsetSpace ~
24195 \InsetSpace ~
24196 \InsetSpace ~
24197 \InsetSpace ~
24198 \InsetSpace ~
24199 \InsetSpace ~
24200 \InsetSpace ~
24201 \InsetSpace ~
24202 sdcc -V -mpic14 -p16f877 -c $< 
24203 \newline
24204
24205 \newline
24206 $(PRJ).hex: $(OBJS) 
24207 \newline
24208 \InsetSpace ~
24209 \InsetSpace ~
24210 \InsetSpace ~
24211 \InsetSpace ~
24212 \InsetSpace ~
24213 \InsetSpace ~
24214 \InsetSpace ~
24215 \InsetSpace ~
24216 gplink -m -s $(PRJ).lkr
24217  -o $(PRJ).hex $(OBJS) libsdcc.lib
24218 \end_layout
24219
24220 \begin_layout Standard
24221 Here is a 
24222 \family typewriter
24223 Makefile
24224 \family default
24225  using MPLAB:
24226 \end_layout
24227
24228 \begin_layout Verse
24229
24230 \family typewriter
24231 .c.o: 
24232 \newline
24233 \InsetSpace ~
24234 \InsetSpace ~
24235 \InsetSpace ~
24236 \InsetSpace ~
24237 \InsetSpace ~
24238 \InsetSpace ~
24239 \InsetSpace ~
24240 \InsetSpace ~
24241 sdcc -S -V -mpic14 -p16f877 $< 
24242 \newline
24243 \InsetSpace ~
24244 \InsetSpace ~
24245 \InsetSpace ~
24246 \InsetSpace ~
24247 \InsetSpace ~
24248 \InsetSpace ~
24249 \InsetSpace ~
24250 \InsetSpace ~
24251 mpasmwin /q /o $*.asm
24252 \newline
24253
24254 \newline
24255 $(PRJ).hex: $(OBJS)
24256  
24257 \newline
24258 \InsetSpace ~
24259 \InsetSpace ~
24260 \InsetSpace ~
24261 \InsetSpace ~
24262 \InsetSpace ~
24263 \InsetSpace ~
24264 \InsetSpace ~
24265 \InsetSpace ~
24266 mplink /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS) libsdcc.lib
24267 \end_layout
24268
24269 \begin_layout Standard
24270 Please note that indentations within a
24271 \family typewriter
24272  Makefile
24273 \family default
24274  have to be done with a tabulator character.
24275 \end_layout
24276
24277 \begin_layout Subsection
24278 Command-Line Options
24279 \end_layout
24280
24281 \begin_layout Standard
24282 Besides the switches common to all SDCC backends, the PIC14 port accepts
24283  the following options (for an updated list see sdcc -
24284 \begin_inset ERT
24285 status collapsed
24286
24287 \begin_layout Standard
24288
24289
24290 \backslash
24291 /
24292 \end_layout
24293
24294 \end_inset
24295
24296 -help):
24297 \end_layout
24298
24299 \begin_layout Description
24300 -
24301 \begin_inset ERT
24302 status collapsed
24303
24304 \begin_layout Standard
24305
24306
24307 \backslash
24308 /
24309 \end_layout
24310
24311 \end_inset
24312
24313 -debug-xtra
24314 \begin_inset LatexCommand \index{PIC14!Options!-\/-debug-extra}
24315
24316 \end_inset
24317
24318  emit debug info in assembly output
24319 \end_layout
24320
24321 \begin_layout Description
24322 -
24323 \begin_inset ERT
24324 status collapsed
24325
24326 \begin_layout Standard
24327
24328
24329 \backslash
24330 /
24331 \end_layout
24332
24333 \end_inset
24334
24335 -no-pcode-opt
24336 \begin_inset LatexCommand \index{PIC14!Options!-\/-no-pcode-opt}
24337
24338 \end_inset
24339
24340  disable (slightly faulty) optimization on pCode
24341 \end_layout
24342
24343 \begin_layout Description
24344 -
24345 \begin_inset ERT
24346 status collapsed
24347
24348 \begin_layout Standard
24349
24350
24351 \backslash
24352 /
24353 \end_layout
24354
24355 \end_inset
24356
24357 -stack-loc
24358 \begin_inset LatexCommand \index{PIC14!Options!-\/-stack-loc}
24359
24360 \end_inset
24361
24362  sets the lowest address of the argument passing stack (defaults to a suitably
24363  large shared databank to reduce BANKSEL overhead)
24364 \end_layout
24365
24366 \begin_layout Description
24367 -
24368 \begin_inset ERT
24369 status collapsed
24370
24371 \begin_layout Standard
24372
24373
24374 \backslash
24375 /
24376 \end_layout
24377
24378 \end_inset
24379
24380 -stack-size
24381 \begin_inset LatexCommand \index{PIC14!Options!-\/-stack-size}
24382
24383 \end_inset
24384
24385  sets the size if the argument passing stack (default: 16, minimum: 4)
24386 \end_layout
24387
24388 \begin_layout Subsection
24389 Environment Variables
24390 \end_layout
24391
24392 \begin_layout Standard
24393 The PIC14 port recognizes the following environment variables:
24394 \end_layout
24395
24396 \begin_layout Description
24397 SDCC_PIC14_SPLIT_LOCALS If set and not empty, sdcc will allocate each temporary
24398  register (the ones called r0xNNNN) in a section of its own.
24399  By default (if this variable is unset), sdcc tries to cluster registers
24400  in sections in order to reduce the BANKSEL overhead when accessing them.
24401 \end_layout
24402
24403 \begin_layout Subsection
24404 The Library
24405 \end_layout
24406
24407 \begin_layout Standard
24408 The PIC14 library currently only contains support routines required by the
24409  compiler to implement multiplication, division, and floating point support.
24410  No libc-like replacement is available at the moment, though many of the
24411  common sdcc library sources (in 
24412 \family typewriter
24413 device/lib
24414 \family default
24415 ) should also compile with the PIC14 port.
24416 \end_layout
24417
24418 \begin_layout Subsubsection
24419 error: missing definition for symbol ``__gptrget1''
24420 \end_layout
24421
24422 \begin_layout Standard
24423 The PIC14 port uses library routines to provide more complex operations
24424  like multiplication, division/modulus and (generic) pointer dereferencing.
24425  In order to add these routines to your project, you must link with PIC14's
24426  
24427 \family typewriter
24428 libsdcc.lib
24429 \family default
24430 .
24431  For single source file projects this is done automatically, more complex
24432  projects must add 
24433 \family typewriter
24434 libsdcc.lib
24435 \family default
24436  to the linker's arguments.
24437  Make sure you also add an include path for the library (using the -I switch
24438  to the linker)!
24439 \end_layout
24440
24441 \begin_layout Subsubsection
24442 Processor mismatch in file ``XXX''.
24443 \end_layout
24444
24445 \begin_layout Standard
24446 This warning can usually be ignored due to the very good compatibility amongst
24447  14
24448 \begin_inset ERT
24449 status open
24450
24451 \begin_layout Standard
24452
24453
24454 \backslash
24455 ,
24456 \end_layout
24457
24458 \end_inset
24459
24460 bit PIC
24461 \begin_inset LatexCommand \index{PIC14}
24462
24463 \end_inset
24464
24465  devices.
24466 \end_layout
24467
24468 \begin_layout Standard
24469 You might also consider recompiling the library for your specific device
24470  by changing the ARCH=p16f877 (default target) entry in 
24471 \family typewriter
24472 device/lib/pic/Makefile.in
24473 \family default
24474  and 
24475 \family typewriter
24476 device/lib/pic/Makefile
24477 \family default
24478  to reflect your device.
24479  This might even improve performance for smaller devices as unneccesary
24480  BANKSELs might be removed.
24481 \end_layout
24482
24483 \begin_layout Subsection
24484 Known Bugs
24485 \end_layout
24486
24487 \begin_layout Subsubsection
24488 Function arguments
24489 \end_layout
24490
24491 \begin_layout Standard
24492 Functions with variable argument lists (like printf) are not yet supported.
24493  Similarly, taking the address of the first argument passed into a function
24494  does not work: It is currently passed in WREG and has no address...
24495 \end_layout
24496
24497 \begin_layout Subsubsection
24498 Regression tests fail
24499 \end_layout
24500
24501 \begin_layout Standard
24502 Though the small subset of regression tests in src/regression passes, SDCC
24503  regression test suite does not, indicating that there are still major bugs
24504  in the port.
24505  However, many smaller projects have successfully used SDCC in the past...
24506 \end_layout
24507
24508 \begin_layout Standard
24509
24510 \size footnotesize
24511
24512 \newpage
24513
24514 \end_layout
24515
24516 \begin_layout Section
24517 The PIC16
24518 \begin_inset LatexCommand \index{PIC16}
24519
24520 \end_inset
24521
24522  port
24523 \end_layout
24524
24525 \begin_layout Standard
24526 The PIC16 port adds support for Microchip
24527 \begin_inset LatexCommand \index{Microchip}
24528
24529 \end_inset
24530
24531
24532 \begin_inset Formula $^{\text{TM}}$
24533 \end_inset
24534
24535  PIC
24536 \begin_inset LatexCommand \index{PIC}
24537
24538 \end_inset
24539
24540
24541 \begin_inset Formula $^{\text{TM}}$
24542 \end_inset
24543
24544  MCUs with 16 bit wide instructions.
24545  Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx
24546 ; devices supported by the port include:
24547 \end_layout
24548
24549 \begin_layout Standard
24550 18F: 242, 248, 252, 258, 442, 448, 452, 458
24551 \end_layout
24552
24553 \begin_layout Standard
24554 18F: 1220, 1320
24555 \end_layout
24556
24557 \begin_layout Standard
24558 18F: 2220, 2221, 2320, 2321, 2331, 2420, 2423, 2431, 2455, 2480, 24j10
24559 \end_layout
24560
24561 \begin_layout Standard
24562 18F: 2520, 2523, 2525, 2550, 2580, 2585, 25j10, 2620, 2680, 2682, 2685
24563 \end_layout
24564
24565 \begin_layout Standard
24566 18F: 4220, 4221, 4320, 4321, 4331, 4420, 4423, 4431, 4455, 4480, 44j10
24567 \end_layout
24568
24569 \begin_layout Standard
24570 18F: 4520, 4523, 4525, 4550, 4580, 4585, 45j10, 4620, 4680, 4682, 4685
24571 \end_layout
24572
24573 \begin_layout Standard
24574 18F: 6520, 6585, 6620, 6680, 6720
24575 \end_layout
24576
24577 \begin_layout Standard
24578 18F: 8520, 8585, 8620, 8680, 8720
24579 \end_layout
24580
24581 \begin_layout Standard
24582 A list of supported devices is also available via '
24583 \family typewriter
24584 sdcc -mpic16 -plist
24585 \family default
24586 '.
24587 \end_layout
24588
24589 \begin_layout Subsection
24590 Global Options
24591 \end_layout
24592
24593 \begin_layout Standard
24594 PIC16 port supports the standard command line arguments as supposed, with
24595  the exception of certain cases that will be mentioned in the following
24596  list:
24597 \end_layout
24598
24599 \begin_layout Description
24600 -
24601 \begin_inset ERT
24602 status collapsed
24603
24604 \begin_layout Standard
24605
24606
24607 \backslash
24608 /
24609 \end_layout
24610
24611 \end_inset
24612
24613 -callee-saves
24614 \begin_inset LatexCommand \index{PIC16!Options!-\/-callee-saves}
24615
24616 \end_inset
24617
24618  See -
24619 \begin_inset ERT
24620 status collapsed
24621
24622 \begin_layout Standard
24623
24624
24625 \backslash
24626 /
24627 \end_layout
24628
24629 \end_inset
24630
24631 -all-callee-saves
24632 \end_layout
24633
24634 \begin_layout Description
24635 -
24636 \begin_inset ERT
24637 status collapsed
24638
24639 \begin_layout Standard
24640
24641
24642 \backslash
24643 /
24644 \end_layout
24645
24646 \end_inset
24647
24648 -fommit-frame-pointer
24649 \begin_inset LatexCommand \index{PIC16!Options!-\/-fommit-frame-pointer}
24650
24651 \end_inset
24652
24653  Frame pointer will be omitted when the function uses no local variables.
24654 \end_layout
24655
24656 \begin_layout Subsection
24657 Port Specific Options
24658 \begin_inset LatexCommand \index{Options PIC16}
24659
24660 \end_inset
24661
24662
24663 \end_layout
24664
24665 \begin_layout Standard
24666 The port specific options appear after the global options in the sdcc -
24667 \begin_inset ERT
24668 status collapsed
24669
24670 \begin_layout Standard
24671
24672
24673 \backslash
24674 /
24675 \end_layout
24676
24677 \end_inset
24678
24679 -help output.
24680 \end_layout
24681
24682 \begin_layout Subsubsection
24683 Code Generation Options
24684 \end_layout
24685
24686 \begin_layout Standard
24687 These options influence the generated assembler code.
24688 \end_layout
24689
24690 \begin_layout Description
24691 -
24692 \begin_inset ERT
24693 status collapsed
24694
24695 \begin_layout Standard
24696
24697
24698 \backslash
24699 /
24700 \end_layout
24701
24702 \end_inset
24703
24704 -pstack-model=[model] Used in conjuction with the command above.
24705  Defines the stack model to be used, valid stack models are:
24706 \end_layout
24707
24708 \begin_deeper
24709 \begin_layout List
24710 \labelwidthstring 00.00.0000
24711
24712 \emph on
24713 small
24714 \emph default
24715  Selects small stack model.
24716  8 bit stack and frame pointers.
24717  Supports 256 bytes stack size.
24718 \end_layout
24719
24720 \begin_layout List
24721 \labelwidthstring 00.00.0000
24722
24723 \emph on
24724 large
24725 \emph default
24726  Selects large stack model.
24727  16 bit stack and frame pointers.
24728  Supports 65536 bytes stack size.
24729 \end_layout
24730
24731 \end_deeper
24732 \begin_layout Description
24733 -
24734 \begin_inset ERT
24735 status collapsed
24736
24737 \begin_layout Standard
24738
24739
24740 \backslash
24741 /
24742 \end_layout
24743
24744 \end_inset
24745
24746 -pno-banksel Do not generate BANKSEL assembler directives.
24747 \end_layout
24748
24749 \begin_layout Description
24750 -
24751 \begin_inset ERT
24752 status collapsed
24753
24754 \begin_layout Standard
24755
24756
24757 \backslash
24758 /
24759 \end_layout
24760
24761 \end_inset
24762
24763 -extended Enable extended instruction set/literal offset addressing mode.
24764  Use with care!
24765 \end_layout
24766
24767 \begin_layout Subsubsection
24768 Optimization Options
24769 \end_layout
24770
24771 \begin_layout Description
24772 -
24773 \begin_inset ERT
24774 status collapsed
24775
24776 \begin_layout Standard
24777
24778
24779 \backslash
24780 /
24781 \end_layout
24782
24783 \end_inset
24784
24785 -obanksel=n Set optimization level for inserting BANKSELs.
24786 \newline
24787
24788 \end_layout
24789
24790 \begin_deeper
24791 \begin_layout List
24792 \labelwidthstring 00.00.0000
24793 0 no optimization
24794 \end_layout
24795
24796 \begin_layout List
24797 \labelwidthstring 00.00.0000
24798 1 checks previous used register and if it is the same then does not emit
24799  BANKSEL, accounts only for labels.
24800 \end_layout
24801
24802 \begin_layout List
24803 \labelwidthstring 00.00.0000
24804 2 tries to check the location of (even different) symbols and removes BANKSELs
24805  if they are in the same bank.
24806  
24807 \newline
24808
24809 \emph on
24810 Important: There might be problems if the linker script has data sections
24811  across bank borders!
24812 \end_layout
24813
24814 \end_deeper
24815 \begin_layout Description
24816 -
24817 \begin_inset ERT
24818 status collapsed
24819
24820 \begin_layout Standard
24821
24822
24823 \backslash
24824 /
24825 \end_layout
24826
24827 \end_inset
24828
24829 -denable-peeps Force the usage of peepholes.
24830  Use with care.
24831 \end_layout
24832
24833 \begin_layout Description
24834 -
24835 \begin_inset ERT
24836 status collapsed
24837
24838 \begin_layout Standard
24839
24840
24841 \backslash
24842 /
24843 \end_layout
24844
24845 \end_inset
24846
24847 -no-optimize-goto Do not use (conditional) BRA instead of GOTO.
24848 \end_layout
24849
24850 \begin_layout Description
24851 -
24852 \begin_inset ERT
24853 status collapsed
24854
24855 \begin_layout Standard
24856
24857
24858 \backslash
24859 /
24860 \end_layout
24861
24862 \end_inset
24863
24864 -optimize-cmp Try to optimize some compares.
24865 \end_layout
24866
24867 \begin_layout Description
24868 -
24869 \begin_inset ERT
24870 status collapsed
24871
24872 \begin_layout Standard
24873
24874
24875 \backslash
24876 /
24877 \end_layout
24878
24879 \end_inset
24880
24881 -optimize-df Analyze the dataflow of the generated code and improve it.
24882 \end_layout
24883
24884 \begin_layout Subsubsection
24885 Assembling Options
24886 \end_layout
24887
24888 \begin_layout Description
24889 -
24890 \begin_inset ERT
24891 status collapsed
24892
24893 \begin_layout Standard
24894
24895
24896 \backslash
24897 /
24898 \end_layout
24899
24900 \end_inset
24901
24902 -asm= Sets the full path and name of an external assembler to call.
24903 \end_layout
24904
24905 \begin_layout Description
24906 -
24907 \begin_inset ERT
24908 status collapsed
24909
24910 \begin_layout Standard
24911
24912
24913 \backslash
24914 /
24915 \end_layout
24916
24917 \end_inset
24918
24919 -mplab-comp MPLAB
24920 \begin_inset LatexCommand \index{PIC16!MPLAB}
24921
24922 \end_inset
24923
24924  compatibility option.
24925  Currently only suppresses special gpasm directives.
24926 \end_layout
24927
24928 \begin_layout Subsubsection
24929 Linking Options
24930 \end_layout
24931
24932 \begin_layout Description
24933 -
24934 \begin_inset ERT
24935 status collapsed
24936
24937 \begin_layout Standard
24938
24939
24940 \backslash
24941 /
24942 \end_layout
24943
24944 \end_inset
24945
24946 -link= Sets the full path and name of an external linker to call.
24947 \end_layout
24948
24949 \begin_layout Description
24950 -
24951 \begin_inset ERT
24952 status collapsed
24953
24954 \begin_layout Standard
24955
24956
24957 \backslash
24958 /
24959 \end_layout
24960
24961 \end_inset
24962
24963 -preplace-udata-with=[kword] Replaces the default udata keyword for allocating
24964  unitialized data variables with [kword].
24965  Valid keywords are: "udata_acs", "udata_shr", "udata_ovr".
24966 \end_layout
24967
24968 \begin_layout Description
24969 -
24970 \begin_inset ERT
24971 status collapsed
24972
24973 \begin_layout Standard
24974
24975
24976 \backslash
24977 /
24978 \end_layout
24979
24980 \end_inset
24981
24982 -ivt-loc=n Place the interrupt vector table at address 
24983 \emph on
24984 n
24985 \emph default
24986 .
24987  Useful for bootloaders.
24988 \end_layout
24989
24990 \begin_layout Description
24991 -
24992 \begin_inset ERT
24993 status collapsed
24994
24995 \begin_layout Standard
24996
24997
24998 \backslash
24999 /
25000 \end_layout
25001
25002 \end_inset
25003
25004 -nodefaultlibs Do not link default libraries when linking.
25005 \end_layout
25006
25007 \begin_layout Description
25008 -
25009 \begin_inset ERT
25010 status collapsed
25011
25012 \begin_layout Standard
25013
25014
25015 \backslash
25016 /
25017 \end_layout
25018
25019 \end_inset
25020
25021 -use-crt= Use a custom run-time module instead of the defaults.
25022 \end_layout
25023
25024 \begin_layout Description
25025 -
25026 \begin_inset ERT
25027 status collapsed
25028
25029 \begin_layout Standard
25030
25031
25032 \backslash
25033 /
25034 \end_layout
25035
25036 \end_inset
25037
25038 -no-crt Don't link the default run-time modules
25039 \end_layout
25040
25041 \begin_layout Subsubsection
25042 Debugging Options
25043 \end_layout
25044
25045 \begin_layout Standard
25046 Debugging options enable extra debugging information in the output files.
25047 \end_layout
25048
25049 \begin_layout Description
25050 -
25051 \begin_inset ERT
25052 status collapsed
25053
25054 \begin_layout Standard
25055
25056
25057 \backslash
25058 /
25059 \end_layout
25060
25061 \end_inset
25062
25063 -debug-xtra Similar to -
25064 \begin_inset ERT
25065 status collapsed
25066
25067 \begin_layout Standard
25068
25069
25070 \backslash
25071 /
25072 \end_layout
25073
25074 \end_inset
25075
25076 -debug
25077 \begin_inset LatexCommand \index{-\/-debug}
25078
25079 \end_inset
25080
25081 , but dumps more information.
25082 \end_layout
25083
25084 \begin_layout Description
25085 -
25086 \begin_inset ERT
25087 status collapsed
25088
25089 \begin_layout Standard
25090
25091
25092 \backslash
25093 /
25094 \end_layout
25095
25096 \end_inset
25097
25098 -debug-ralloc Force register allocator to dump <source>.d file with debugging
25099  information.
25100  <source> is the name of the file being compiled.
25101 \end_layout
25102
25103 \begin_layout Description
25104 -
25105 \begin_inset ERT
25106 status collapsed
25107
25108 \begin_layout Standard
25109
25110
25111 \backslash
25112 /
25113 \end_layout
25114
25115 \end_inset
25116
25117 -pcode-verbose Enable pcode debugging information in translation.
25118 \end_layout
25119
25120 \begin_layout Description
25121 -
25122 \begin_inset ERT
25123 status collapsed
25124
25125 \begin_layout Standard
25126
25127
25128 \backslash
25129 /
25130 \end_layout
25131
25132 \end_inset
25133
25134 -calltree Dump call tree in .calltree file.
25135 \end_layout
25136
25137 \begin_layout Description
25138 -
25139 \begin_inset ERT
25140 status collapsed
25141
25142 \begin_layout Standard
25143
25144
25145 \backslash
25146 /
25147 \end_layout
25148
25149 \end_inset
25150
25151 -gstack Trace push/pops for stack pointer overflow.
25152 \end_layout
25153
25154 \begin_layout Subsection
25155 Enviroment Variables
25156 \end_layout
25157
25158 \begin_layout Standard
25159 There is a number of enviromental variables that can be used when running
25160  SDCC to enable certain optimizations or force a specific program behaviour.
25161  these variables are primarily for debugging purposes so they can be enabled/dis
25162 abled at will.
25163 \end_layout
25164
25165 \begin_layout Standard
25166 Currently there is only two such variables available:
25167 \end_layout
25168
25169 \begin_layout Description
25170 OPTIMIZE_BITFIELD_POINTER_GET When this variable exists, reading of structure
25171  bitfields is optimized by directly loading FSR0 with the address of the
25172  bitfield structure.
25173  Normally SDCC will cast the bitfield structure to a bitfield pointer and
25174  then load FSR0.
25175  This step saves data ram and code space for functions that make heavy use
25176  of bitfields.
25177  (i.e., 80 bytes of code space are saved when compiling malloc.c with this
25178  option).
25179  
25180 \end_layout
25181
25182 \begin_layout Description
25183 NO_REG_OPT Do not perform pCode registers optimization.
25184  This should be used for debugging purposes.
25185  If bugs in the pcode optimizer are found, users can benefit from temporarily
25186  disabling the optimizer until the bug is fixed.
25187 \end_layout
25188
25189 \begin_layout Subsection
25190 Preprocessor Macros
25191 \end_layout
25192
25193 \begin_layout Standard
25194 PIC16
25195 \begin_inset LatexCommand \index{PIC16}
25196
25197 \end_inset
25198
25199  port defines the following preprocessor macros while translating a source.
25200 \end_layout
25201
25202 \begin_layout Standard
25203 \align center
25204 \begin_inset Tabular
25205 <lyxtabular version="3" rows="6" columns="2">
25206 <features>
25207 <column alignment="center" valignment="top" leftline="true" width="0">
25208 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25209 <row topline="true" bottomline="true">
25210 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25211 \begin_inset Text
25212
25213 \begin_layout Standard
25214 Macro
25215 \end_layout
25216
25217 \end_inset
25218 </cell>
25219 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25220 \begin_inset Text
25221
25222 \begin_layout Standard
25223 Description
25224 \end_layout
25225
25226 \end_inset
25227 </cell>
25228 </row>
25229 <row topline="true">
25230 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25231 \begin_inset Text
25232
25233 \begin_layout Standard
25234 SDCC_pic16
25235 \end_layout
25236
25237 \end_inset
25238 </cell>
25239 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25240 \begin_inset Text
25241
25242 \begin_layout Standard
25243 Port identification
25244 \end_layout
25245
25246 \end_inset
25247 </cell>
25248 </row>
25249 <row topline="true">
25250 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25251 \begin_inset Text
25252
25253 \begin_layout Standard
25254 _
25255 \begin_inset ERT
25256 status collapsed
25257
25258 \begin_layout Standard
25259
25260
25261 \backslash
25262 /
25263 \end_layout
25264
25265 \end_inset
25266
25267 _pic16
25268 \end_layout
25269
25270 \end_inset
25271 </cell>
25272 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25273 \begin_inset Text
25274
25275 \begin_layout Standard
25276 Port identification (same as above)
25277 \end_layout
25278
25279 \end_inset
25280 </cell>
25281 </row>
25282 <row topline="true">
25283 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25284 \begin_inset Text
25285
25286 \begin_layout Standard
25287 pic18fxxxx
25288 \end_layout
25289
25290 \end_inset
25291 </cell>
25292 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25293 \begin_inset Text
25294
25295 \begin_layout Standard
25296 MCU Identification.
25297  
25298 \emph on
25299 xxxx
25300 \emph default
25301  is the microcontrol identification number, i.e.
25302  452, 6620, etc
25303 \end_layout
25304
25305 \end_inset
25306 </cell>
25307 </row>
25308 <row topline="true">
25309 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25310 \begin_inset Text
25311
25312 \begin_layout Standard
25313 _
25314 \begin_inset ERT
25315 status collapsed
25316
25317 \begin_layout Standard
25318
25319
25320 \backslash
25321 /
25322 \end_layout
25323
25324 \end_inset
25325
25326 _18Fxxxx
25327 \end_layout
25328
25329 \end_inset
25330 </cell>
25331 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25332 \begin_inset Text
25333
25334 \begin_layout Standard
25335 MCU Identification (same as above)
25336 \end_layout
25337
25338 \end_inset
25339 </cell>
25340 </row>
25341 <row topline="true" bottomline="true">
25342 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25343 \begin_inset Text
25344
25345 \begin_layout Standard
25346 STACK_MODEL_nnn
25347 \end_layout
25348
25349 \end_inset
25350 </cell>
25351 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25352 \begin_inset Text
25353
25354 \begin_layout Standard
25355 nnn = SMALL or LARGE respectively according to the stack model used
25356 \end_layout
25357
25358 \end_inset
25359 </cell>
25360 </row>
25361 </lyxtabular>
25362
25363 \end_inset
25364
25365
25366 \end_layout
25367
25368 \begin_layout Standard
25369 In addition the following macros are defined when calling assembler:
25370 \end_layout
25371
25372 \begin_layout Standard
25373 \align center
25374 \begin_inset Tabular
25375 <lyxtabular version="3" rows="4" columns="2">
25376 <features>
25377 <column alignment="center" valignment="top" leftline="true" width="0">
25378 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25379 <row topline="true" bottomline="true">
25380 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25381 \begin_inset Text
25382
25383 \begin_layout Standard
25384 Macro
25385 \end_layout
25386
25387 \end_inset
25388 </cell>
25389 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25390 \begin_inset Text
25391
25392 \begin_layout Standard
25393 Description
25394 \end_layout
25395
25396 \end_inset
25397 </cell>
25398 </row>
25399 <row topline="true">
25400 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25401 \begin_inset Text
25402
25403 \begin_layout Standard
25404 __18Fxxxx
25405 \end_layout
25406
25407 \end_inset
25408 </cell>
25409 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25410 \begin_inset Text
25411
25412 \begin_layout Standard
25413 MCU Identification.
25414  
25415 \emph on
25416 xxxx
25417 \emph default
25418  is the microcontrol identification number, i.e.
25419  452, 6620, etc
25420 \end_layout
25421
25422 \end_inset
25423 </cell>
25424 </row>
25425 <row topline="true">
25426 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25427 \begin_inset Text
25428
25429 \begin_layout Standard
25430 SDCC_MODEL_nnn
25431 \end_layout
25432
25433 \end_inset
25434 </cell>
25435 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25436 \begin_inset Text
25437
25438 \begin_layout Standard
25439 nnn = SMALL or LARGE respectively according to the memory model used for
25440  SDCC
25441 \end_layout
25442
25443 \end_inset
25444 </cell>
25445 </row>
25446 <row topline="true" bottomline="true">
25447 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25448 \begin_inset Text
25449
25450 \begin_layout Standard
25451 STACK_MODEL_nnn
25452 \end_layout
25453
25454 \end_inset
25455 </cell>
25456 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25457 \begin_inset Text
25458
25459 \begin_layout Standard
25460 nnn = SMALL or LARGE respectively according to the stack model used
25461 \end_layout
25462
25463 \end_inset
25464 </cell>
25465 </row>
25466 </lyxtabular>
25467
25468 \end_inset
25469
25470
25471 \end_layout
25472
25473 \begin_layout Subsection
25474 Directories
25475 \end_layout
25476
25477 \begin_layout Standard
25478 PIC16
25479 \begin_inset LatexCommand \index{PIC16}
25480
25481 \end_inset
25482
25483  port uses the following directories for searching header files and libraries.
25484 \end_layout
25485
25486 \begin_layout Standard
25487 \align center
25488 \begin_inset Tabular
25489 <lyxtabular version="3" rows="3" columns="4">
25490 <features>
25491 <column alignment="center" valignment="top" leftline="true" width="0">
25492 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25493 <column alignment="center" valignment="top" width="0">
25494 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25495 <row topline="true" bottomline="true">
25496 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25497 \begin_inset Text
25498
25499 \begin_layout Standard
25500 Directory
25501 \end_layout
25502
25503 \end_inset
25504 </cell>
25505 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25506 \begin_inset Text
25507
25508 \begin_layout Standard
25509 Description
25510 \end_layout
25511
25512 \end_inset
25513 </cell>
25514 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25515 \begin_inset Text
25516
25517 \begin_layout Standard
25518 Target
25519 \end_layout
25520
25521 \end_inset
25522 </cell>
25523 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25524 \begin_inset Text
25525
25526 \begin_layout Standard
25527 Command prefix
25528 \end_layout
25529
25530 \end_inset
25531 </cell>
25532 </row>
25533 <row topline="true">
25534 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25535 \begin_inset Text
25536
25537 \begin_layout Standard
25538 PREFIX/sdcc/include/pic16
25539 \end_layout
25540
25541 \end_inset
25542 </cell>
25543 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25544 \begin_inset Text
25545
25546 \begin_layout Standard
25547 PIC16 specific headers
25548 \end_layout
25549
25550 \end_inset
25551 </cell>
25552 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25553 \begin_inset Text
25554
25555 \begin_layout Standard
25556 Compiler
25557 \end_layout
25558
25559 \end_inset
25560 </cell>
25561 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25562 \begin_inset Text
25563
25564 \begin_layout Standard
25565 -I
25566 \end_layout
25567
25568 \end_inset
25569 </cell>
25570 </row>
25571 <row topline="true" bottomline="true">
25572 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25573 \begin_inset Text
25574
25575 \begin_layout Standard
25576 PREFIX/sdcc/lib/pic16
25577 \end_layout
25578
25579 \end_inset
25580 </cell>
25581 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25582 \begin_inset Text
25583
25584 \begin_layout Standard
25585 PIC16 specific libraries
25586 \end_layout
25587
25588 \end_inset
25589 </cell>
25590 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25591 \begin_inset Text
25592
25593 \begin_layout Standard
25594 Linker
25595 \end_layout
25596
25597 \end_inset
25598 </cell>
25599 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25600 \begin_inset Text
25601
25602 \begin_layout Standard
25603 -L
25604 \end_layout
25605
25606 \end_inset
25607 </cell>
25608 </row>
25609 </lyxtabular>
25610
25611 \end_inset
25612
25613
25614 \end_layout
25615
25616 \begin_layout Subsection
25617 Pragmas
25618 \begin_inset LatexCommand \label{sub:PIC16_Pragmas}
25619
25620 \end_inset
25621
25622
25623 \end_layout
25624
25625 \begin_layout Standard
25626 The PIC16
25627 \begin_inset LatexCommand \index{PIC16}
25628
25629 \end_inset
25630
25631  port currently supports the following pragmas:
25632 \end_layout
25633
25634 \begin_layout Description
25635 stack
25636 \begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma stack}
25637
25638 \end_inset
25639
25640  This forces the code generator to initialize the stack & frame pointers
25641  at a specific address.
25642  This is an ad hoc solution for cases where no STACK directive is available
25643  in the linker script or gplink is not instructed to create a stack section.
25644 \newline
25645 The
25646  stack pragma should be used only once in a project.
25647  Multiple pragmas may result in indeterminate behaviour of the program.
25648 \begin_inset Foot
25649 status open
25650
25651 \begin_layout Standard
25652 The old format (ie.
25653  #pragma stack 0x5ff) is deprecated and will cause the stack pointer to
25654  cross page boundaries (or even exceed the available data RAM) and crash
25655  the program.
25656  Make sure that stack does not cross page boundaries when using the SMALL
25657  stack model.
25658 \end_layout
25659
25660 \end_inset
25661
25662
25663 \newline
25664 The format is as follows:
25665 \newline
25666
25667 \end_layout
25668
25669 \begin_layout LyX-Code
25670 #pragma stack bottom_address [stack_size]
25671 \newline
25672
25673 \end_layout
25674
25675 \begin_layout Standard
25676
25677 \emph on
25678 bottom_address
25679 \emph default
25680  is the lower bound of the stack section.
25681  The stack pointer initially will point at address (bottom_address+stack_size-1).
25682 \end_layout
25683
25684 \begin_layout LyX-Code
25685 Example:
25686 \end_layout
25687
25688 \begin_layout LyX-Code
25689
25690 \end_layout
25691
25692 \begin_layout LyX-Code
25693 /* initializes stack of 100 bytes at RAM address 0x200 */
25694 \end_layout
25695
25696 \begin_layout LyX-Code
25697 #pragma stack 0x200 100
25698 \end_layout
25699
25700 \begin_layout Standard
25701 If the stack_size field is omitted then a stack is created with the default
25702  size of 64.
25703  This size might be enough for most programs, but its not enough for operations
25704  with deep function nesting or excessive stack usage.
25705 \end_layout
25706
25707 \begin_layout Description
25708 code
25709 \begin_inset LatexCommand \index{PIC16!Pragmas!\#pragma code}
25710
25711 \end_inset
25712
25713  Force a function to a static FLASH address.
25714 \end_layout
25715
25716 \begin_layout LyX-Code
25717 Example:
25718 \end_layout
25719
25720 \begin_layout LyX-Code
25721
25722 \end_layout
25723
25724 \begin_layout LyX-Code
25725 /* place function test_func at 0x4000 */
25726 \end_layout
25727
25728 \begin_layout LyX-Code
25729 #pragma code test_func 0x4000
25730 \end_layout
25731
25732 \begin_layout LyX-Code
25733
25734 \end_layout
25735
25736 \begin_layout Description
25737 library instructs the linker to use a library module.
25738 \newline
25739 Usage:
25740 \end_layout
25741
25742 \begin_layout LyX-Code
25743 #pragma library module_name
25744 \end_layout
25745
25746 \begin_layout Standard
25747
25748 \emph on
25749 module_name
25750 \emph default
25751  can be any library or object file (including its path).
25752  Note that there are four reserved keywords which have special meaning.
25753  These are:
25754 \end_layout
25755
25756 \begin_layout Standard
25757 \align center
25758 \begin_inset Tabular
25759 <lyxtabular version="3" rows="6" columns="3">
25760 <features>
25761 <column alignment="center" valignment="top" leftline="true" width="0">
25762 <column alignment="block" valignment="top" leftline="true" width="20page%">
25763 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
25764 <row topline="true" bottomline="true">
25765 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25766 \begin_inset Text
25767
25768 \begin_layout Standard
25769 Keyword
25770 \end_layout
25771
25772 \end_inset
25773 </cell>
25774 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25775 \begin_inset Text
25776
25777 \begin_layout Standard
25778 Description
25779 \end_layout
25780
25781 \end_inset
25782 </cell>
25783 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25784 \begin_inset Text
25785
25786 \begin_layout Standard
25787 Module to link
25788 \end_layout
25789
25790 \end_inset
25791 </cell>
25792 </row>
25793 <row topline="true">
25794 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25795 \begin_inset Text
25796
25797 \begin_layout Standard
25798
25799 \series bold
25800 ignore
25801 \end_layout
25802
25803 \end_inset
25804 </cell>
25805 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25806 \begin_inset Text
25807
25808 \begin_layout Standard
25809 ignore all library pragmas
25810 \end_layout
25811
25812 \end_inset
25813 </cell>
25814 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25815 \begin_inset Text
25816
25817 \begin_layout Standard
25818
25819 \emph on
25820 (none)
25821 \end_layout
25822
25823 \end_inset
25824 </cell>
25825 </row>
25826 <row topline="true">
25827 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25828 \begin_inset Text
25829
25830 \begin_layout Standard
25831
25832 \series bold
25833 c
25834 \end_layout
25835
25836 \end_inset
25837 </cell>
25838 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25839 \begin_inset Text
25840
25841 \begin_layout Standard
25842 link the C library
25843 \end_layout
25844
25845 \end_inset
25846 </cell>
25847 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25848 \begin_inset Text
25849
25850 \begin_layout Standard
25851
25852 \emph on
25853 libc18f
25854 \emph default
25855 .lib
25856 \end_layout
25857
25858 \end_inset
25859 </cell>
25860 </row>
25861 <row topline="true">
25862 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25863 \begin_inset Text
25864
25865 \begin_layout Standard
25866
25867 \series bold
25868 math
25869 \end_layout
25870
25871 \end_inset
25872 </cell>
25873 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25874 \begin_inset Text
25875
25876 \begin_layout Standard
25877 link the Math libarary
25878 \end_layout
25879
25880 \end_inset
25881 </cell>
25882 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25883 \begin_inset Text
25884
25885 \begin_layout Standard
25886
25887 \emph on
25888 libm18f
25889 \emph default
25890 .lib
25891 \end_layout
25892
25893 \end_inset
25894 </cell>
25895 </row>
25896 <row topline="true">
25897 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25898 \begin_inset Text
25899
25900 \begin_layout Standard
25901
25902 \series bold
25903 io
25904 \end_layout
25905
25906 \end_inset
25907 </cell>
25908 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25909 \begin_inset Text
25910
25911 \begin_layout Standard
25912 link the I/O library
25913 \end_layout
25914
25915 \end_inset
25916 </cell>
25917 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25918 \begin_inset Text
25919
25920 \begin_layout Standard
25921
25922 \emph on
25923 libio18f*
25924 \emph default
25925 .lib
25926 \end_layout
25927
25928 \end_inset
25929 </cell>
25930 </row>
25931 <row topline="true" bottomline="true">
25932 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25933 \begin_inset Text
25934
25935 \begin_layout Standard
25936
25937 \series bold
25938 debug
25939 \end_layout
25940
25941 \end_inset
25942 </cell>
25943 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25944 \begin_inset Text
25945
25946 \begin_layout Standard
25947 link the debug library
25948 \end_layout
25949
25950 \end_inset
25951 </cell>
25952 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25953 \begin_inset Text
25954
25955 \begin_layout Standard
25956
25957 \emph on
25958 libdebug
25959 \emph default
25960 .lib
25961 \end_layout
25962
25963 \end_inset
25964 </cell>
25965 </row>
25966 </lyxtabular>
25967
25968 \end_inset
25969
25970
25971 \newline
25972 * is the device number, i.e.
25973  452 for PIC18F452 MCU.
25974 \end_layout
25975
25976 \begin_layout Standard
25977 This feature allows for linking with specific libraries withoug having to
25978  explicit name them in the command line.
25979  Note that the 
25980 \noun on
25981 ignore
25982 \noun default
25983  keyword will reject all modules specified by the library pragma.
25984 \end_layout
25985
25986 \begin_layout Description
25987 udata The pragma udata instructs the compiler to emit code so that linker
25988  will place a variable at a specific memory bank.
25989 \end_layout
25990
25991 \begin_layout LyX-Code
25992 Example:
25993 \end_layout
25994
25995 \begin_layout LyX-Code
25996
25997 \end_layout
25998
25999 \begin_layout LyX-Code
26000 /* places variable foo at bank2 */
26001 \end_layout
26002
26003 \begin_layout LyX-Code
26004 #pragma udata bank2 foo
26005 \end_layout
26006
26007 \begin_layout LyX-Code
26008 char foo;
26009 \end_layout
26010
26011 \begin_layout Standard
26012 In order for this pragma to work extra SECTION directives should be added
26013  in the .lkr script.
26014  In the following example a sample .lkr file is shown:
26015 \end_layout
26016
26017 \begin_layout LyX-Code
26018
26019 \end_layout
26020
26021 \begin_layout LyX-Code
26022 // Sample linker script for the PIC18F452 processor
26023 \end_layout
26024
26025 \begin_layout LyX-Code
26026 LIBPATH .
26027 \end_layout
26028
26029 \begin_layout LyX-Code
26030 CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
26031 \end_layout
26032
26033 \begin_layout LyX-Code
26034 CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
26035 \end_layout
26036
26037 \begin_layout LyX-Code
26038 CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
26039 \end_layout
26040
26041 \begin_layout LyX-Code
26042 CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
26043 \end_layout
26044
26045 \begin_layout LyX-Code
26046 CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
26047 \end_layout
26048
26049 \begin_layout LyX-Code
26050 CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
26051 \end_layout
26052
26053 \begin_layout LyX-Code
26054 ACCESSBANK NAME=accessram  START=0x0            END=0x7F
26055 \end_layout
26056
26057 \begin_layout LyX-Code
26058
26059 \end_layout
26060
26061 \begin_layout LyX-Code
26062 DATABANK   NAME=gpr0       START=0x80           END=0xFF
26063 \end_layout
26064
26065 \begin_layout LyX-Code
26066 DATABANK   NAME=gpr1       START=0x100          END=0x1FF
26067 \end_layout
26068
26069 \begin_layout LyX-Code
26070 DATABANK   NAME=gpr2       START=0x200          END=0x2FF
26071 \end_layout
26072
26073 \begin_layout LyX-Code
26074 DATABANK   NAME=gpr3       START=0x300          END=0x3FF
26075 \end_layout
26076
26077 \begin_layout LyX-Code
26078 DATABANK   NAME=gpr4       START=0x400          END=0x4FF
26079 \end_layout
26080
26081 \begin_layout LyX-Code
26082 DATABANK   NAME=gpr5       START=0x500          END=0x5FF
26083 \end_layout
26084
26085 \begin_layout LyX-Code
26086 ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED
26087 \end_layout
26088
26089 \begin_layout LyX-Code
26090
26091 \end_layout
26092
26093 \begin_layout LyX-Code
26094 SECTION    NAME=CONFIG     ROM=config
26095 \end_layout
26096
26097 \begin_layout LyX-Code
26098
26099 \end_layout
26100
26101 \begin_layout LyX-Code
26102 SECTION    NAME=bank0      RAM=gpr0       # these SECTION directives
26103 \end_layout
26104
26105 \begin_layout LyX-Code
26106 SECTION    NAME=bank1      RAM=gpr1       # should be added to link
26107 \end_layout
26108
26109 \begin_layout LyX-Code
26110 SECTION    NAME=bank2      RAM=gpr2       # section name 'bank?' with
26111 \end_layout
26112
26113 \begin_layout LyX-Code
26114 SECTION    NAME=bank3      RAM=gpr3       # a specific DATABANK name
26115 \end_layout
26116
26117 \begin_layout LyX-Code
26118 SECTION    NAME=bank4      RAM=gpr4
26119 \end_layout
26120
26121 \begin_layout LyX-Code
26122 SECTION    NAME=bank5      RAM=gpr5
26123 \end_layout
26124
26125 \begin_layout Standard
26126 The linker will recognise the section name set in the pragma statement and
26127  will position the variable at the memory bank set with the RAM field at
26128  the SECTION line in the linker script file.
26129 \end_layout
26130
26131 \begin_layout Subsection
26132 Header Files
26133 \begin_inset LatexCommand \label{sub:PIC16_Header-Files}
26134
26135 \end_inset
26136
26137
26138 \end_layout
26139
26140 \begin_layout Standard
26141 There is one main header file
26142 \begin_inset LatexCommand \index{PIC16!Header files}
26143
26144 \end_inset
26145
26146  that can be included to the source files using the pic16
26147 \begin_inset LatexCommand \index{PIC16}
26148
26149 \end_inset
26150
26151  port.
26152  That file is the 
26153 \series bold
26154 pic18fregs.h
26155 \series default
26156 .
26157  This header file contains the definitions for the processor special registers,
26158  so it is necessary if the source accesses them.
26159  It can be included by adding the following line in the beginning of the
26160  file:
26161 \end_layout
26162
26163 \begin_layout LyX-Code
26164 #include <pic18fregs.h>
26165 \end_layout
26166
26167 \begin_layout Standard
26168 The specific microcontroller is selected within the pic18fregs.h automatically,
26169  so the same source can be used with a variety of devices.
26170 \end_layout
26171
26172 \begin_layout Subsection
26173 Libraries
26174 \end_layout
26175
26176 \begin_layout Standard
26177 The libraries
26178 \begin_inset LatexCommand \index{PIC16!Libraries}
26179
26180 \end_inset
26181
26182  that PIC16
26183 \begin_inset LatexCommand \index{PIC16}
26184
26185 \end_inset
26186
26187  port depends on are the microcontroller device libraries which contain
26188  the symbol definitions for the microcontroller special function registers.
26189  These libraries have the format pic18fxxxx.lib, where 
26190 \emph on
26191 xxxx
26192 \emph default
26193  is the microcontroller identification number.
26194  The specific library is selected automatically by the compiler at link
26195  stage according to the selected device.
26196 \end_layout
26197
26198 \begin_layout Standard
26199 Libraries are created with gplib which is part of the gputils package 
26200 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
26201
26202 \end_inset
26203
26204 .
26205 \end_layout
26206
26207 \begin_layout Subsubsection*
26208 Building the libraries
26209 \end_layout
26210
26211 \begin_layout Standard
26212 Before using SDCC/pic16 there are some libraries that need to be compiled.
26213  This process is not done automatically by SDCC since not all users use
26214  SDCC for pic16 projects.
26215  So each user should compile the libraries separately.
26216 \end_layout
26217
26218 \begin_layout Standard
26219 The steps to compile the pic16 libraries under Linux and Mac OS X are:
26220 \end_layout
26221
26222 \begin_layout LyX-Code
26223 cd device/lib/pic16
26224 \end_layout
26225
26226 \begin_layout LyX-Code
26227 ./configure
26228 \end_layout
26229
26230 \begin_layout LyX-Code
26231 make
26232 \end_layout
26233
26234 \begin_layout LyX-Code
26235 cd ..
26236 \end_layout
26237
26238 \begin_layout LyX-Code
26239 make model-pic16
26240 \end_layout
26241
26242 \begin_layout LyX-Code
26243 su -c 'make install'     # install the libraries, you need the root password
26244 \end_layout
26245
26246 \begin_layout Standard
26247 If you need to install the headers too, do:
26248 \end_layout
26249
26250 \begin_layout LyX-Code
26251 cd device/include
26252 \end_layout
26253
26254 \begin_layout LyX-Code
26255 su -c 'make install'     # install the headers, you need the root password
26256 \end_layout
26257
26258 \begin_layout Standard
26259 There exist a special target to build the I/O libraries.
26260  This target is not automatically build because it will build the I/O library
26261  for 
26262 \emph on
26263 every
26264 \emph default
26265  supported device.
26266  This way building will take quite a lot of time.
26267  Users are advised to edit the 
26268 \series bold
26269 device/lib/pic16/pics.build
26270 \series default
26271  file and then execute:
26272 \end_layout
26273
26274 \begin_layout LyX-Code
26275 make lib-io
26276 \end_layout
26277
26278 \begin_layout Subsection
26279 Adding New Devices to the Port
26280 \end_layout
26281
26282 \begin_layout Standard
26283 Adding support for a new 16
26284 \begin_inset ERT
26285 status open
26286
26287 \begin_layout Standard
26288
26289
26290 \backslash
26291 ,
26292 \end_layout
26293
26294 \end_inset
26295
26296 bit PIC MCU requires the following steps:
26297 \end_layout
26298
26299 \begin_layout Enumerate
26300 Create picDEVICE.c and picDEVICE.h from pDEVICE.inc using
26301 \newline
26302
26303 \family typewriter
26304 perl /path/to/sdcc/support/scripts/inc2h-pic16.pl /path/to/gputils/header/pDEVICE.
26305 inc
26306 \end_layout
26307
26308 \begin_layout Enumerate
26309
26310 \family typewriter
26311 mv picDEVICE.h /path/to/sdcc/device/include/pic16
26312 \end_layout
26313
26314 \begin_layout Enumerate
26315
26316 \family typewriter
26317 mv picDEVICE.c /path/to/sdcc/device/lib/pic16/libdev
26318 \end_layout
26319
26320 \begin_layout Enumerate
26321 Add DEVICE to 
26322 \family typewriter
26323 /path/to/sdcc/device/lib/pic16/pics.all
26324 \family default
26325  (and 
26326 \family typewriter
26327 .build
26328 \family default
26329 ).
26330 \newline
26331 Note: No 18f prefix here!
26332 \end_layout
26333
26334 \begin_layout Enumerate
26335 Set up the I/O library by doing 
26336 \series bold
26337 one
26338 \series default
26339  of the following:
26340 \end_layout
26341
26342 \begin_deeper
26343 \begin_layout Enumerate
26344 Adjust 
26345 \family typewriter
26346 /path/to/sdcc/device/lib/pic16/libio/*.ignore
26347 \family default
26348
26349 \newline
26350 Add your DEVICE if it does not compile in 
26351 \family typewriter
26352 adc
26353 \family default
26354
26355 \family typewriter
26356 i2c
26357 \family default
26358 , or 
26359 \family typewriter
26360 usart
26361 \family default
26362 .
26363 \end_layout
26364
26365 \begin_layout Enumerate
26366 Adjust 
26367 \family typewriter
26368 /path/to/sdcc/device/include/pic16/adc.h
26369 \newline
26370
26371 \family default
26372 Add the new devices to the correct ADC style class.
26373 \end_layout
26374
26375 \end_deeper
26376 \begin_layout Enumerate
26377 Edit 
26378 \family typewriter
26379 /path/to/sdcc/device/include/pic16/pic18fregs.h
26380 \family default
26381 .
26382  The file format is self-explanatory, just add
26383 \newline
26384
26385 \family typewriter
26386 #elif defined(picDEVICE)
26387 \newline
26388 # include <picDEVICE.h>
26389 \family default
26390
26391 \newline
26392 at the right place (keep it sorted).
26393 \end_layout
26394
26395 \begin_layout Enumerate
26396 Edit 
26397 \family typewriter
26398 /path/to/sdcc/device/include/pic16devices.txt
26399 \newline
26400
26401 \family default
26402 Copy and modify an existing entry or create a new one and insert it at the
26403  correct place (keep the file sorted).
26404 \end_layout
26405
26406 \begin_layout Enumerate
26407 Recompile the pic16 libraries.
26408 \end_layout
26409
26410 \begin_layout Subsection
26411 Memory Models
26412 \end_layout
26413
26414 \begin_layout Standard
26415 The following memory models are supported by the PIC16 port:
26416 \end_layout
26417
26418 \begin_layout Itemize
26419 small model
26420 \end_layout
26421
26422 \begin_layout Itemize
26423 large model
26424 \end_layout
26425
26426 \begin_layout Standard
26427 Memory model affects the default size of pointers within the source.
26428  The sizes are shown in the next table:
26429 \end_layout
26430
26431 \begin_layout Standard
26432 \align center
26433 \begin_inset Tabular
26434 <lyxtabular version="3" rows="3" columns="3">
26435 <features>
26436 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26437 <column alignment="center" valignment="top" leftline="true" width="0">
26438 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26439 <row topline="true" bottomline="true">
26440 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26441 \begin_inset Text
26442
26443 \begin_layout Standard
26444 Pointer sizes according to memory model
26445 \end_layout
26446
26447 \end_inset
26448 </cell>
26449 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26450 \begin_inset Text
26451
26452 \begin_layout Standard
26453 small model
26454 \end_layout
26455
26456 \end_inset
26457 </cell>
26458 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26459 \begin_inset Text
26460
26461 \begin_layout Standard
26462 large model
26463 \end_layout
26464
26465 \end_inset
26466 </cell>
26467 </row>
26468 <row topline="true" bottomline="true">
26469 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26470 \begin_inset Text
26471
26472 \begin_layout Standard
26473 code pointers
26474 \end_layout
26475
26476 \end_inset
26477 </cell>
26478 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26479 \begin_inset Text
26480
26481 \begin_layout Standard
26482 16-bits
26483 \end_layout
26484
26485 \end_inset
26486 </cell>
26487 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26488 \begin_inset Text
26489
26490 \begin_layout Standard
26491 24-bits
26492 \end_layout
26493
26494 \end_inset
26495 </cell>
26496 </row>
26497 <row topline="true" bottomline="true">
26498 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26499 \begin_inset Text
26500
26501 \begin_layout Standard
26502 data pointers
26503 \end_layout
26504
26505 \end_inset
26506 </cell>
26507 <cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
26508 \begin_inset Text
26509
26510 \begin_layout Standard
26511 16-bits
26512 \end_layout
26513
26514 \end_inset
26515 </cell>
26516 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26517 \begin_inset Text
26518
26519 \begin_layout Standard
26520 16-bits
26521 \end_layout
26522
26523 \end_inset
26524 </cell>
26525 </row>
26526 </lyxtabular>
26527
26528 \end_inset
26529
26530
26531 \end_layout
26532
26533 \begin_layout Standard
26534 It is advisable that all sources within a project are compiled with the
26535  same memory model.
26536  If one wants to override the default memory model, this can be done by
26537  declaring a pointer as 
26538 \series bold
26539 far
26540 \series default
26541  or 
26542 \series bold
26543 near
26544 \series default
26545 .
26546  Far selects large memory model's pointers, while near selects small memory
26547  model's pointers.
26548 \end_layout
26549
26550 \begin_layout Standard
26551 The standard device libraries (see 
26552 \begin_inset LatexCommand \ref{sub:PIC16_Header-Files}
26553
26554 \end_inset
26555
26556 ) contain no reference to pointers, so they can be used with both memory
26557  models.
26558 \end_layout
26559
26560 \begin_layout Subsection
26561 Stack
26562 \end_layout
26563
26564 \begin_layout Standard
26565 The stack
26566 \begin_inset LatexCommand \index{PIC16!stack}
26567
26568 \end_inset
26569
26570  implementation for the PIC16 port uses two indirect registers, FSR1 and
26571  FSR2.
26572 \end_layout
26573
26574 \begin_layout Description
26575 FSR1 is assigned as stack pointer
26576 \end_layout
26577
26578 \begin_layout Description
26579 FSR2 is assigned as frame pointer
26580 \end_layout
26581
26582 \begin_layout Standard
26583 The following stack models are supported by the PIC16 port
26584 \end_layout
26585
26586 \begin_layout Itemize
26587
26588 \noun on
26589 small
26590 \noun default
26591  model
26592 \end_layout
26593
26594 \begin_layout Itemize
26595
26596 \noun on
26597 large
26598 \noun default
26599  model
26600 \end_layout
26601
26602 \begin_layout Standard
26603
26604 \noun on
26605 Small
26606 \noun default
26607  model means that only the FSRxL byte is used to access stack and frame,
26608  while 
26609 \emph on
26610 \noun on
26611 large
26612 \emph default
26613 \noun default
26614  uses both FSRxL and FSRxH registers.
26615  The following table shows the stack/frame pointers sizes according to stack
26616  model and the maximum space they can address:
26617 \end_layout
26618
26619 \begin_layout Standard
26620 \align center
26621 \begin_inset Tabular
26622 <lyxtabular version="3" rows="3" columns="3">
26623 <features>
26624 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26625 <column alignment="center" valignment="top" leftline="true" width="0">
26626 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26627 <row topline="true" bottomline="true">
26628 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26629 \begin_inset Text
26630
26631 \begin_layout Standard
26632 Stack & Frame pointer sizes according to stack model
26633 \end_layout
26634
26635 \end_inset
26636 </cell>
26637 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26638 \begin_inset Text
26639
26640 \begin_layout Standard
26641 small
26642 \end_layout
26643
26644 \end_inset
26645 </cell>
26646 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26647 \begin_inset Text
26648
26649 \begin_layout Standard
26650 large
26651 \end_layout
26652
26653 \end_inset
26654 </cell>
26655 </row>
26656 <row topline="true">
26657 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26658 \begin_inset Text
26659
26660 \begin_layout Standard
26661 Stack pointer FSR1
26662 \end_layout
26663
26664 \end_inset
26665 </cell>
26666 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26667 \begin_inset Text
26668
26669 \begin_layout Standard
26670 8-bits
26671 \end_layout
26672
26673 \end_inset
26674 </cell>
26675 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26676 \begin_inset Text
26677
26678 \begin_layout Standard
26679 16-bits
26680 \end_layout
26681
26682 \end_inset
26683 </cell>
26684 </row>
26685 <row topline="true" bottomline="true">
26686 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26687 \begin_inset Text
26688
26689 \begin_layout Standard
26690 Frame pointer FSR2
26691 \end_layout
26692
26693 \end_inset
26694 </cell>
26695 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26696 \begin_inset Text
26697
26698 \begin_layout Standard
26699 8-bits
26700 \end_layout
26701
26702 \end_inset
26703 </cell>
26704 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26705 \begin_inset Text
26706
26707 \begin_layout Standard
26708 16-bits
26709 \end_layout
26710
26711 \end_inset
26712 </cell>
26713 </row>
26714 </lyxtabular>
26715
26716 \end_inset
26717
26718
26719 \end_layout
26720
26721 \begin_layout Standard
26722
26723 \noun on
26724 Large 
26725 \noun default
26726 stack model is currently not working properly throughout the code generator.
26727  So its use is not advised.
26728  Also there are some other points that need special care:
26729 \newline
26730
26731 \end_layout
26732
26733 \begin_layout Enumerate
26734 Do not create stack sections with size more than one physical bank (that
26735  is 256 bytes)
26736 \end_layout
26737
26738 \begin_layout Enumerate
26739 Stack sections should no cross physical bank limits (i.e.
26740  #pragma stack 0x50 0x100)
26741 \end_layout
26742
26743 \begin_layout Standard
26744 These limitations are caused by the fact that only FSRxL is modified when
26745  using SMALL stack model, so no more than 256 bytes of stack can be used.
26746  This problem will disappear after LARGE model is fully implemented.
26747 \end_layout
26748
26749 \begin_layout Subsection
26750 Functions
26751 \end_layout
26752
26753 \begin_layout Standard
26754 In addition to the standard SDCC function keywords, PIC16
26755 \begin_inset LatexCommand \index{PIC16}
26756
26757 \end_inset
26758
26759  port makes available two more:
26760 \end_layout
26761
26762 \begin_layout Description
26763 wparam
26764 \begin_inset LatexCommand \index{PIC16!wparam}
26765
26766 \end_inset
26767
26768  Use the WREG to pass one byte of the first function argument.
26769  This improves speed but you may not use this for functions with arguments
26770  that are called via function pointers, otherwise the first byte of the
26771  first parameter will get lost.
26772  Usage:
26773 \end_layout
26774
26775 \begin_layout LyX-Code
26776 void func_wparam(int a) wparam
26777 \end_layout
26778
26779 \begin_layout LyX-Code
26780 {
26781 \end_layout
26782
26783 \begin_layout LyX-Code
26784     /* WREG hold the lower part of a */
26785 \end_layout
26786
26787 \begin_layout LyX-Code
26788     /* the high part of a is stored in FSR2+2 (or +3 for large stack model)
26789  */
26790 \end_layout
26791
26792 \begin_layout LyX-Code
26793 ...
26794 \end_layout
26795
26796 \begin_layout LyX-Code
26797 }
26798 \end_layout
26799
26800 \begin_layout Description
26801 shadowregs
26802 \begin_inset LatexCommand \index{PIC16!shadowregs}
26803
26804 \end_inset
26805
26806  When entering/exiting an ISR, it is possible to take advantage of the PIC18F
26807  hardware shadow registers which hold the values of WREG, STATUS and BSR
26808  registers.
26809  This can be done by adding the keyword 
26810 \emph on
26811 shadowregs
26812 \emph default
26813  before the 
26814 \emph on
26815 interrupt
26816 \emph default
26817  keyword in the function's header.
26818 \end_layout
26819
26820 \begin_layout LyX-Code
26821 void isr_shadow(void) shadowregs interrupt 1
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 LyX-Code
26833 }
26834 \end_layout
26835
26836 \begin_layout Standard
26837
26838 \emph on
26839 shadowregs
26840 \emph default
26841  instructs the code generator not to store/restore WREG, STATUS, BSR when
26842  entering/exiting the ISR.
26843 \end_layout
26844
26845 \begin_layout Subsection
26846 Function return values
26847 \end_layout
26848
26849 \begin_layout Standard
26850 Return values from functions are placed to the appropriate registers following
26851  a modified Microchip policy optimized for SDCC.
26852  The following table shows these registers:
26853 \end_layout
26854
26855 \begin_layout Standard
26856 \align center
26857 \begin_inset Tabular
26858 <lyxtabular version="3" rows="6" columns="2">
26859 <features>
26860 <column alignment="center" valignment="top" leftline="true" width="0">
26861 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26862 <row topline="true" bottomline="true">
26863 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26864 \begin_inset Text
26865
26866 \begin_layout Standard
26867 size
26868 \end_layout
26869
26870 \end_inset
26871 </cell>
26872 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26873 \begin_inset Text
26874
26875 \begin_layout Standard
26876 destination register
26877 \end_layout
26878
26879 \end_inset
26880 </cell>
26881 </row>
26882 <row topline="true">
26883 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26884 \begin_inset Text
26885
26886 \begin_layout Standard
26887 8 bits
26888 \end_layout
26889
26890 \end_inset
26891 </cell>
26892 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26893 \begin_inset Text
26894
26895 \begin_layout Standard
26896 WREG
26897 \end_layout
26898
26899 \end_inset
26900 </cell>
26901 </row>
26902 <row topline="true">
26903 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26904 \begin_inset Text
26905
26906 \begin_layout Standard
26907 16 bits
26908 \end_layout
26909
26910 \end_inset
26911 </cell>
26912 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26913 \begin_inset Text
26914
26915 \begin_layout Standard
26916 PRODL:WREG
26917 \end_layout
26918
26919 \end_inset
26920 </cell>
26921 </row>
26922 <row topline="true">
26923 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26924 \begin_inset Text
26925
26926 \begin_layout Standard
26927 24 bits
26928 \end_layout
26929
26930 \end_inset
26931 </cell>
26932 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26933 \begin_inset Text
26934
26935 \begin_layout Standard
26936 PRODH:PRODL:WREG
26937 \end_layout
26938
26939 \end_inset
26940 </cell>
26941 </row>
26942 <row topline="true">
26943 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26944 \begin_inset Text
26945
26946 \begin_layout Standard
26947 32 bits
26948 \end_layout
26949
26950 \end_inset
26951 </cell>
26952 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26953 \begin_inset Text
26954
26955 \begin_layout Standard
26956 FSR0L:PRODH:PRODL:WREG
26957 \end_layout
26958
26959 \end_inset
26960 </cell>
26961 </row>
26962 <row topline="true" bottomline="true">
26963 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26964 \begin_inset Text
26965
26966 \begin_layout Standard
26967 >32 bits
26968 \end_layout
26969
26970 \end_inset
26971 </cell>
26972 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26973 \begin_inset Text
26974
26975 \begin_layout Standard
26976 on stack, FSR0 points to the beginning
26977 \end_layout
26978
26979 \end_inset
26980 </cell>
26981 </row>
26982 </lyxtabular>
26983
26984 \end_inset
26985
26986
26987 \end_layout
26988
26989 \begin_layout Subsection
26990 Interrupts
26991 \end_layout
26992
26993 \begin_layout Standard
26994 An interrupt
26995 \begin_inset LatexCommand \index{PIC16!interrupt}
26996
26997 \end_inset
26998
26999  service routine (ISR) is declared using the 
27000 \emph on
27001 interrupt
27002 \emph default
27003  keyword.
27004 \end_layout
27005
27006 \begin_layout LyX-Code
27007 void isr(void) interrupt 
27008 \emph on
27009 n
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 LyX-Code
27021 }
27022 \end_layout
27023
27024 \begin_layout Standard
27025
27026 \emph on
27027 n
27028 \emph default
27029  is the interrupt number, which for PIC18F devices can be:
27030 \end_layout
27031
27032 \begin_layout Standard
27033 \align center
27034 \begin_inset Tabular
27035 <lyxtabular version="3" rows="4" columns="3">
27036 <features>
27037 <column alignment="center" valignment="top" leftline="true" width="0">
27038 <column alignment="center" valignment="top" leftline="true" width="0">
27039 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27040 <row topline="true" bottomline="true">
27041 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27042 \begin_inset Text
27043
27044 \begin_layout Standard
27045
27046 \emph on
27047 n
27048 \end_layout
27049
27050 \end_inset
27051 </cell>
27052 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27053 \begin_inset Text
27054
27055 \begin_layout Standard
27056 Interrupt Vector
27057 \end_layout
27058
27059 \end_inset
27060 </cell>
27061 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27062 \begin_inset Text
27063
27064 \begin_layout Standard
27065 Interrupt Vector Address
27066 \end_layout
27067
27068 \end_inset
27069 </cell>
27070 </row>
27071 <row topline="true">
27072 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27073 \begin_inset Text
27074
27075 \begin_layout Standard
27076 0
27077 \end_layout
27078
27079 \end_inset
27080 </cell>
27081 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27082 \begin_inset Text
27083
27084 \begin_layout Standard
27085 RESET vector
27086 \end_layout
27087
27088 \end_inset
27089 </cell>
27090 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27091 \begin_inset Text
27092
27093 \begin_layout Standard
27094 0x000000
27095 \end_layout
27096
27097 \end_inset
27098 </cell>
27099 </row>
27100 <row topline="true">
27101 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27102 \begin_inset Text
27103
27104 \begin_layout Standard
27105
27106 \family roman
27107 \series medium
27108 \shape up
27109 \size normal
27110 \emph off
27111 \bar no
27112 \noun off
27113 \color none
27114 1
27115 \end_layout
27116
27117 \end_inset
27118 </cell>
27119 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27120 \begin_inset Text
27121
27122 \begin_layout Standard
27123
27124 \family roman
27125 \series medium
27126 \shape up
27127 \size normal
27128 \emph off
27129 \bar no
27130 \noun off
27131 \color none
27132 HIGH priority interrupts
27133 \end_layout
27134
27135 \end_inset
27136 </cell>
27137 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27138 \begin_inset Text
27139
27140 \begin_layout Standard
27141 0x000008
27142 \end_layout
27143
27144 \end_inset
27145 </cell>
27146 </row>
27147 <row topline="true" bottomline="true">
27148 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27149 \begin_inset Text
27150
27151 \begin_layout Standard
27152 2
27153 \end_layout
27154
27155 \end_inset
27156 </cell>
27157 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27158 \begin_inset Text
27159
27160 \begin_layout Standard
27161 LOW priority interrupts
27162 \end_layout
27163
27164 \end_inset
27165 </cell>
27166 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27167 \begin_inset Text
27168
27169 \begin_layout Standard
27170 0x000018
27171 \end_layout
27172
27173 \end_inset
27174 </cell>
27175 </row>
27176 </lyxtabular>
27177
27178 \end_inset
27179
27180
27181 \end_layout
27182
27183 \begin_layout Standard
27184 When generating assembly code for ISR the code generator places a 
27185 \noun on
27186 goto 
27187 \noun default
27188 instruction at the 
27189 \emph on
27190 Interrupt Vector Address
27191 \emph default
27192  which points at the genetated ISR.
27193  This single GOTO instruction is part of an automatically generated 
27194 \emph on
27195 interrupt entry point
27196 \emph default
27197  function.
27198  The actuall ISR code is placed as normally would in the code space.
27199  Upon interrupt request, the GOTO instruction is executed which jumps to
27200  the ISR code.
27201  When declaring interrupt functions as _naked this GOTO instruction is 
27202 \series bold
27203 not
27204 \series default
27205  generated.
27206  The whole interrupt functions is therefore placed at the Interrupt Vector
27207  Address of the specific interrupt.
27208  This is not a problem for the LOW priority interrupts, but it is a problem
27209  for the RESET and the HIGH priority interrupts because code may be written
27210  at the next interrupt's vector address and cause undeterminate program
27211  behaviour if that interrupt is raised.
27212 \begin_inset Foot
27213 status open
27214
27215 \begin_layout Standard
27216 This is not a problem when
27217 \end_layout
27218
27219 \begin_layout Enumerate
27220 this is a HIGH interrupt ISR and LOW interrupts are 
27221 \emph on
27222 disabled
27223 \emph default
27224  or not used.
27225 \end_layout
27226
27227 \begin_layout Enumerate
27228 when the ISR is small enough not to reach the next interrupt's vector address.
27229 \end_layout
27230
27231 \end_inset
27232
27233
27234 \end_layout
27235
27236 \begin_layout Standard
27237
27238 \emph on
27239 n
27240 \emph default
27241  may be omitted.
27242  This way a function is generated similar to an ISR, but it is not assigned
27243  to any interrupt.
27244 \end_layout
27245
27246 \begin_layout Standard
27247 When entering an interrupt, currently the PIC16
27248 \begin_inset LatexCommand \index{PIC16}
27249
27250 \end_inset
27251
27252  port automatically saves the following registers:
27253 \end_layout
27254
27255 \begin_layout Itemize
27256 WREG
27257 \end_layout
27258
27259 \begin_layout Itemize
27260 STATUS
27261 \end_layout
27262
27263 \begin_layout Itemize
27264 BSR
27265 \end_layout
27266
27267 \begin_layout Itemize
27268 PROD (PRODL and PRODH)
27269 \end_layout
27270
27271 \begin_layout Itemize
27272 FSR0 (FSR0L and FSR0H)
27273 \end_layout
27274
27275 \begin_layout Standard
27276 These registers are restored upon return from the interrupt routine.
27277 \begin_inset Foot
27278 status open
27279
27280 \begin_layout Standard
27281 NOTE that when the _naked attribute is specified for an interrupt routine,
27282  then NO registers are stored or restored.
27283 \end_layout
27284
27285 \end_inset
27286
27287
27288 \end_layout
27289
27290 \begin_layout Subsection
27291 Generic Pointers
27292 \end_layout
27293
27294 \begin_layout Standard
27295 Generic pointers are implemented in PIC16 port as 3-byte (24-bit) types.
27296  There are 3 types of generic pointers currently implemented data, code
27297  and eeprom pointers.
27298  They are differentiated by the value of the 7th and 6th bits of the upper
27299  byte:
27300 \end_layout
27301
27302 \begin_layout Standard
27303 \align center
27304 \begin_inset Tabular
27305 <lyxtabular version="3" rows="5" columns="5">
27306 <features>
27307 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27308 <column alignment="center" valignment="top" width="0">
27309 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27310 <column alignment="center" valignment="top" width="0">
27311 <column alignment="left" valignment="top" rightline="true" width="0">
27312 <row topline="true" bottomline="true">
27313 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27314 \begin_inset Text
27315
27316 \begin_layout Standard
27317 pointer type
27318 \end_layout
27319
27320 \end_inset
27321 </cell>
27322 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27323 \begin_inset Text
27324
27325 \begin_layout Standard
27326 7th bit
27327 \end_layout
27328
27329 \end_inset
27330 </cell>
27331 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27332 \begin_inset Text
27333
27334 \begin_layout Standard
27335 6th bit
27336 \end_layout
27337
27338 \end_inset
27339 </cell>
27340 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27341 \begin_inset Text
27342
27343 \begin_layout Standard
27344 rest of the pointer
27345 \end_layout
27346
27347 \end_inset
27348 </cell>
27349 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27350 \begin_inset Text
27351
27352 \begin_layout Standard
27353 description
27354 \end_layout
27355
27356 \end_inset
27357 </cell>
27358 </row>
27359 <row topline="true" bottomline="true">
27360 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27361 \begin_inset Text
27362
27363 \begin_layout Standard
27364 data 
27365 \end_layout
27366
27367 \end_inset
27368 </cell>
27369 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27370 \begin_inset Text
27371
27372 \begin_layout Standard
27373 1
27374 \end_layout
27375
27376 \end_inset
27377 </cell>
27378 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27379 \begin_inset Text
27380
27381 \begin_layout Standard
27382 0
27383 \end_layout
27384
27385 \end_inset
27386 </cell>
27387 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27388 \begin_inset Text
27389
27390 \begin_layout Standard
27391
27392 \family typewriter
27393 \shape slanted
27394 \emph on
27395 uuuuuu uuuuxxxx xxxxxxxx
27396 \end_layout
27397
27398 \end_inset
27399 </cell>
27400 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27401 \begin_inset Text
27402
27403 \begin_layout Standard
27404 a 12-bit data pointer in data RAM memory
27405 \end_layout
27406
27407 \end_inset
27408 </cell>
27409 </row>
27410 <row bottomline="true">
27411 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27412 \begin_inset Text
27413
27414 \begin_layout Standard
27415 code
27416 \end_layout
27417
27418 \end_inset
27419 </cell>
27420 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27421 \begin_inset Text
27422
27423 \begin_layout Standard
27424 0
27425 \end_layout
27426
27427 \end_inset
27428 </cell>
27429 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27430 \begin_inset Text
27431
27432 \begin_layout Standard
27433 0
27434 \end_layout
27435
27436 \end_inset
27437 </cell>
27438 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27439 \begin_inset Text
27440
27441 \begin_layout Standard
27442
27443 \family typewriter
27444 \shape slanted
27445 \emph on
27446 uxxxxx xxxxxxxx xxxxxxxx
27447 \end_layout
27448
27449 \end_inset
27450 </cell>
27451 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27452 \begin_inset Text
27453
27454 \begin_layout Standard
27455 a 21-bit code pointer in FLASH memory
27456 \end_layout
27457
27458 \end_inset
27459 </cell>
27460 </row>
27461 <row bottomline="true">
27462 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27463 \begin_inset Text
27464
27465 \begin_layout Standard
27466 eeprom
27467 \end_layout
27468
27469 \end_inset
27470 </cell>
27471 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27472 \begin_inset Text
27473
27474 \begin_layout Standard
27475 0
27476 \end_layout
27477
27478 \end_inset
27479 </cell>
27480 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27481 \begin_inset Text
27482
27483 \begin_layout Standard
27484 1
27485 \end_layout
27486
27487 \end_inset
27488 </cell>
27489 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27490 \begin_inset Text
27491
27492 \begin_layout Standard
27493
27494 \family typewriter
27495 \shape slanted
27496 \emph on
27497 uuuuuu uuuuuuxx xxxxxxxx
27498 \end_layout
27499
27500 \end_inset
27501 </cell>
27502 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27503 \begin_inset Text
27504
27505 \begin_layout Standard
27506 a 10-bit eeprom pointer in EEPROM memory
27507 \end_layout
27508
27509 \end_inset
27510 </cell>
27511 </row>
27512 <row bottomline="true">
27513 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27514 \begin_inset Text
27515
27516 \begin_layout Standard
27517 (unimplemented)
27518 \end_layout
27519
27520 \end_inset
27521 </cell>
27522 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27523 \begin_inset Text
27524
27525 \begin_layout Standard
27526 1
27527 \end_layout
27528
27529 \end_inset
27530 </cell>
27531 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27532 \begin_inset Text
27533
27534 \begin_layout Standard
27535 1
27536 \end_layout
27537
27538 \end_inset
27539 </cell>
27540 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27541 \begin_inset Text
27542
27543 \begin_layout Standard
27544
27545 \family typewriter
27546 \shape slanted
27547 \emph on
27548 xxxxxx xxxxxxxx xxxxxxxx
27549 \end_layout
27550
27551 \end_inset
27552 </cell>
27553 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27554 \begin_inset Text
27555
27556 \begin_layout Standard
27557 unimplemented pointer type
27558 \end_layout
27559
27560 \end_inset
27561 </cell>
27562 </row>
27563 </lyxtabular>
27564
27565 \end_inset
27566
27567
27568 \end_layout
27569
27570 \begin_layout Standard
27571 Generic pointer are read and written with a set of library functions which
27572  read/write 1, 2, 3, 4 bytes.
27573 \end_layout
27574
27575 \begin_layout Subsection
27576 PIC16 C Libraries
27577 \end_layout
27578
27579 \begin_layout Subsubsection
27580 Standard I/O Streams
27581 \end_layout
27582
27583 \begin_layout Standard
27584 In the 
27585 \emph on
27586 stdio.h
27587 \emph default
27588  the type FILE is defined as:
27589 \end_layout
27590
27591 \begin_layout LyX-Code
27592 typedef char * FILE;
27593 \end_layout
27594
27595 \begin_layout Standard
27596 This type is the stream type implemented I/O in the PIC18F devices.
27597  Also the standard input and output streams are declared in stdio.h:
27598 \end_layout
27599
27600 \begin_layout LyX-Code
27601 extern FILE * stdin;
27602 \end_layout
27603
27604 \begin_layout LyX-Code
27605 extern FILE * stdout;
27606 \end_layout
27607
27608 \begin_layout Standard
27609 The FILE type is actually a generic pointer which defines one more type
27610  of generic pointers, the 
27611 \emph on
27612 stream 
27613 \emph default
27614 pointer.
27615  This new type has the format:
27616 \end_layout
27617
27618 \begin_layout Standard
27619 \align center
27620 \begin_inset Tabular
27621 <lyxtabular version="3" rows="2" columns="7">
27622 <features>
27623 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27624 <column alignment="center" valignment="top" width="0">
27625 <column alignment="center" valignment="top" leftline="true" width="0">
27626 <column alignment="center" valignment="top" leftline="true" width="0">
27627 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27628 <column alignment="center" valignment="top" width="0">
27629 <column alignment="left" valignment="top" rightline="true" width="0">
27630 <row topline="true" bottomline="true">
27631 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27632 \begin_inset Text
27633
27634 \begin_layout Standard
27635 pointer type
27636 \end_layout
27637
27638 \end_inset
27639 </cell>
27640 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27641 \begin_inset Text
27642
27643 \begin_layout Standard
27644 <7:6>
27645 \end_layout
27646
27647 \end_inset
27648 </cell>
27649 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27650 \begin_inset Text
27651
27652 \begin_layout Standard
27653 <5>
27654 \end_layout
27655
27656 \end_inset
27657 </cell>
27658 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27659 \begin_inset Text
27660
27661 \begin_layout Standard
27662 <4>
27663 \end_layout
27664
27665 \end_inset
27666 </cell>
27667 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27668 \begin_inset Text
27669
27670 \begin_layout Standard
27671 <3:0>
27672 \end_layout
27673
27674 \end_inset
27675 </cell>
27676 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27677 \begin_inset Text
27678
27679 \begin_layout Standard
27680 rest of the pointer
27681 \end_layout
27682
27683 \end_inset
27684 </cell>
27685 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27686 \begin_inset Text
27687
27688 \begin_layout Standard
27689 descrption
27690 \end_layout
27691
27692 \end_inset
27693 </cell>
27694 </row>
27695 <row topline="true" bottomline="true">
27696 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27697 \begin_inset Text
27698
27699 \begin_layout Standard
27700 stream
27701 \end_layout
27702
27703 \end_inset
27704 </cell>
27705 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27706 \begin_inset Text
27707
27708 \begin_layout Standard
27709 00
27710 \end_layout
27711
27712 \end_inset
27713 </cell>
27714 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27715 \begin_inset Text
27716
27717 \begin_layout Standard
27718 1
27719 \end_layout
27720
27721 \end_inset
27722 </cell>
27723 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27724 \begin_inset Text
27725
27726 \begin_layout Standard
27727 0
27728 \end_layout
27729
27730 \end_inset
27731 </cell>
27732 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27733 \begin_inset Text
27734
27735 \begin_layout Standard
27736 nnnn
27737 \end_layout
27738
27739 \end_inset
27740 </cell>
27741 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27742 \begin_inset Text
27743
27744 \begin_layout Standard
27745
27746 \family typewriter
27747 \shape slanted
27748 \emph on
27749 uuuuuuuu uuuuuuuu
27750 \end_layout
27751
27752 \end_inset
27753 </cell>
27754 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27755 \begin_inset Text
27756
27757 \begin_layout Standard
27758 upper byte high nubble is 0x2n, the rest are zeroes
27759 \end_layout
27760
27761 \end_inset
27762 </cell>
27763 </row>
27764 </lyxtabular>
27765
27766 \end_inset
27767
27768
27769 \end_layout
27770
27771 \begin_layout Standard
27772 Currently implemented there are 3 types of streams defined:
27773 \end_layout
27774
27775 \begin_layout Standard
27776 \align center
27777 \begin_inset Tabular
27778 <lyxtabular version="3" rows="4" columns="4">
27779 <features>
27780 <column alignment="center" valignment="top" leftline="true" width="0">
27781 <column alignment="center" valignment="top" leftline="true" width="0">
27782 <column alignment="center" valignment="top" leftline="true" width="0">
27783 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27784 <row topline="true" bottomline="true">
27785 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27786 \begin_inset Text
27787
27788 \begin_layout Standard
27789 stream type
27790 \end_layout
27791
27792 \end_inset
27793 </cell>
27794 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27795 \begin_inset Text
27796
27797 \begin_layout Standard
27798 value
27799 \end_layout
27800
27801 \end_inset
27802 </cell>
27803 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27804 \begin_inset Text
27805
27806 \begin_layout Standard
27807 module
27808 \end_layout
27809
27810 \end_inset
27811 </cell>
27812 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27813 \begin_inset Text
27814
27815 \begin_layout Standard
27816 description
27817 \end_layout
27818
27819 \end_inset
27820 </cell>
27821 </row>
27822 <row topline="true">
27823 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27824 \begin_inset Text
27825
27826 \begin_layout Standard
27827 STREAM_USART
27828 \end_layout
27829
27830 \end_inset
27831 </cell>
27832 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27833 \begin_inset Text
27834
27835 \begin_layout Standard
27836
27837 \family typewriter
27838 0x200000UL
27839 \end_layout
27840
27841 \end_inset
27842 </cell>
27843 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27844 \begin_inset Text
27845
27846 \begin_layout Standard
27847 USART
27848 \end_layout
27849
27850 \end_inset
27851 </cell>
27852 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27853 \begin_inset Text
27854
27855 \begin_layout Standard
27856 Writes/Reads characters via the USART peripheral
27857 \end_layout
27858
27859 \end_inset
27860 </cell>
27861 </row>
27862 <row topline="true">
27863 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27864 \begin_inset Text
27865
27866 \begin_layout Standard
27867 STREAM_MSSP
27868 \end_layout
27869
27870 \end_inset
27871 </cell>
27872 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27873 \begin_inset Text
27874
27875 \begin_layout Standard
27876
27877 \family typewriter
27878 0x210000UL
27879 \end_layout
27880
27881 \end_inset
27882 </cell>
27883 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27884 \begin_inset Text
27885
27886 \begin_layout Standard
27887 MSSP
27888 \end_layout
27889
27890 \end_inset
27891 </cell>
27892 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27893 \begin_inset Text
27894
27895 \begin_layout Standard
27896 Writes/Reads characters via the MSSP peripheral
27897 \end_layout
27898
27899 \end_inset
27900 </cell>
27901 </row>
27902 <row topline="true" bottomline="true">
27903 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27904 \begin_inset Text
27905
27906 \begin_layout Standard
27907 STREAM_USER
27908 \end_layout
27909
27910 \end_inset
27911 </cell>
27912 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27913 \begin_inset Text
27914
27915 \begin_layout Standard
27916
27917 \family typewriter
27918 0x2f0000UL
27919 \end_layout
27920
27921 \end_inset
27922 </cell>
27923 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27924 \begin_inset Text
27925
27926 \begin_layout Standard
27927 (none)
27928 \end_layout
27929
27930 \end_inset
27931 </cell>
27932 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27933 \begin_inset Text
27934
27935 \begin_layout Standard
27936 Writes/Reads characters via used defined functions
27937 \end_layout
27938
27939 \end_inset
27940 </cell>
27941 </row>
27942 </lyxtabular>
27943
27944 \end_inset
27945
27946
27947 \end_layout
27948
27949 \begin_layout Standard
27950 The stream identifiers are declared as macros in the stdio.h header.
27951 \end_layout
27952
27953 \begin_layout Standard
27954 In the libc library there exist the functions that are used to write to
27955  each of the above streams.
27956  These are
27957 \end_layout
27958
27959 \begin_layout Description
27960 _
27961 \begin_inset ERT
27962 status collapsed
27963
27964 \begin_layout Standard
27965
27966
27967 \backslash
27968 /
27969 \end_layout
27970
27971 \end_inset
27972
27973 _stream_usart_putchar writes a character at the USART stream
27974 \end_layout
27975
27976 \begin_layout Description
27977 _
27978 \begin_inset ERT
27979 status collapsed
27980
27981 \begin_layout Standard
27982
27983
27984 \backslash
27985 /
27986 \end_layout
27987
27988 \end_inset
27989
27990 _stream_mssp_putchar writes a character at the MSSP stream
27991 \end_layout
27992
27993 \begin_layout Description
27994 putchar dummy function.
27995  This writes a character to a user specified manner.
27996 \end_layout
27997
27998 \begin_layout Standard
27999 In order to increase performance 
28000 \emph on
28001 putchar 
28002 \emph default
28003 is declared in stdio.h as having its parameter in WREG (it has the wparam
28004  keyword).
28005  In stdio.h exists the macro PUTCHAR(arg) that defines the putchar function
28006  in a user-friendly way.
28007  
28008 \emph on
28009 arg
28010 \emph default
28011  is the name of the variable that holds the character to print.
28012  An example follows:
28013 \end_layout
28014
28015 \begin_layout LyX-Code
28016 #include <pic18fregs.h>
28017 \newline
28018 #include <stdio.h>
28019 \newline
28020
28021 \newline
28022 PUTCHAR( c )
28023 \end_layout
28024
28025 \begin_layout LyX-Code
28026 {
28027 \end_layout
28028
28029 \begin_layout LyX-Code
28030     PORTA = c;    /* dump character c to PORTA */
28031 \end_layout
28032
28033 \begin_layout LyX-Code
28034
28035 \newline
28036
28037 \newline
28038 void main(void)
28039 \end_layout
28040
28041 \begin_layout LyX-Code
28042 {
28043 \end_layout
28044
28045 \begin_layout LyX-Code
28046     stdout = STREAM_USER;    /* this is not necessary, since stdout points
28047 \end_layout
28048
28049 \begin_layout LyX-Code
28050                               * by default to STREAM_USER */
28051 \end_layout
28052
28053 \begin_layout LyX-Code
28054     printf (
28055 \begin_inset Quotes sld
28056 \end_inset
28057
28058 This is a printf test
28059 \backslash
28060 n
28061 \begin_inset Quotes srd
28062 \end_inset
28063
28064 );
28065 \end_layout
28066
28067 \begin_layout LyX-Code
28068 }
28069 \end_layout
28070
28071 \begin_layout LyX-Code
28072
28073 \end_layout
28074
28075 \begin_layout Subsubsection
28076 Printing functions
28077 \end_layout
28078
28079 \begin_layout Standard
28080 PIC16 contains an implementation of the printf-family of functions.
28081  There exist the following functions:
28082 \end_layout
28083
28084 \begin_layout LyX-Code
28085 extern unsigned int sprintf(char *buf, char *fmt, ...);
28086 \end_layout
28087
28088 \begin_layout LyX-Code
28089 extern unsigned int vsprintf(char *buf, char *fmt, va_list ap);
28090 \end_layout
28091
28092 \begin_layout LyX-Code
28093
28094 \end_layout
28095
28096 \begin_layout LyX-Code
28097 extern unsigned int printf(char *fmt, ...);
28098 \end_layout
28099
28100 \begin_layout LyX-Code
28101 extern unsigned int vprintf(char *fmt, va_lista ap);
28102 \end_layout
28103
28104 \begin_layout LyX-Code
28105
28106 \end_layout
28107
28108 \begin_layout LyX-Code
28109 extern unsigned int fprintf(FILE *fp, char *fmt, ...);
28110 \end_layout
28111
28112 \begin_layout LyX-Code
28113 extern unsigned int vfprintf(FILE *fp, char *fmt, va_list ap);
28114 \end_layout
28115
28116 \begin_layout Standard
28117 For sprintf and vsprintf 
28118 \emph on
28119 buf 
28120 \emph default
28121 should normally be a data pointer where the resulting string will be placed.
28122  No range checking is done so the user should allocate the necessery buffer.
28123  For fprintf and vfprintf 
28124 \emph on
28125 fp
28126 \emph default
28127  should be a stream pointer (i.e.
28128  stdout, STREAM_MSSP, etc...).
28129 \end_layout
28130
28131 \begin_layout Subsubsection
28132 Signals
28133 \end_layout
28134
28135 \begin_layout Standard
28136 The PIC18F family of microcontrollers supports a number of interrupt sources.
28137  A list of these interrupts is shown in the following table:
28138 \end_layout
28139
28140 \begin_layout Standard
28141 \align center
28142 \begin_inset Tabular
28143 <lyxtabular version="3" rows="11" columns="4">
28144 <features>
28145 <column alignment="left" valignment="top" leftline="true" width="0">
28146 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28147 <column alignment="left" valignment="top" leftline="true" width="0">
28148 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28149 <row topline="true" bottomline="true">
28150 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28151 \begin_inset Text
28152
28153 \begin_layout Standard
28154 signal name
28155 \end_layout
28156
28157 \end_inset
28158 </cell>
28159 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28160 \begin_inset Text
28161
28162 \begin_layout Standard
28163 description
28164 \end_layout
28165
28166 \end_inset
28167 </cell>
28168 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28169 \begin_inset Text
28170
28171 \begin_layout Standard
28172 signal name
28173 \end_layout
28174
28175 \end_inset
28176 </cell>
28177 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28178 \begin_inset Text
28179
28180 \begin_layout Standard
28181 descritpion
28182 \end_layout
28183
28184 \end_inset
28185 </cell>
28186 </row>
28187 <row topline="true">
28188 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28189 \begin_inset Text
28190
28191 \begin_layout Standard
28192 SIG_RB
28193 \end_layout
28194
28195 \end_inset
28196 </cell>
28197 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28198 \begin_inset Text
28199
28200 \begin_layout Standard
28201 PORTB change interrupt
28202 \end_layout
28203
28204 \end_inset
28205 </cell>
28206 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28207 \begin_inset Text
28208
28209 \begin_layout Standard
28210 SIG_EE
28211 \end_layout
28212
28213 \end_inset
28214 </cell>
28215 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28216 \begin_inset Text
28217
28218 \begin_layout Standard
28219 EEPROM/FLASH write complete interrupt
28220 \end_layout
28221
28222 \end_inset
28223 </cell>
28224 </row>
28225 <row topline="true">
28226 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28227 \begin_inset Text
28228
28229 \begin_layout Standard
28230 SIG_INT0
28231 \end_layout
28232
28233 \end_inset
28234 </cell>
28235 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28236 \begin_inset Text
28237
28238 \begin_layout Standard
28239 INT0 external interrupt
28240 \end_layout
28241
28242 \end_inset
28243 </cell>
28244 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28245 \begin_inset Text
28246
28247 \begin_layout Standard
28248 SIG_BCOL
28249 \end_layout
28250
28251 \end_inset
28252 </cell>
28253 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28254 \begin_inset Text
28255
28256 \begin_layout Standard
28257 Bus collision interrupt
28258 \end_layout
28259
28260 \end_inset
28261 </cell>
28262 </row>
28263 <row topline="true">
28264 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28265 \begin_inset Text
28266
28267 \begin_layout Standard
28268 SIG_INT1
28269 \end_layout
28270
28271 \end_inset
28272 </cell>
28273 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28274 \begin_inset Text
28275
28276 \begin_layout Standard
28277 INT1 external interrupt
28278 \end_layout
28279
28280 \end_inset
28281 </cell>
28282 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28283 \begin_inset Text
28284
28285 \begin_layout Standard
28286 SIG_LVD
28287 \end_layout
28288
28289 \end_inset
28290 </cell>
28291 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28292 \begin_inset Text
28293
28294 \begin_layout Standard
28295 Low voltage detect interrupt
28296 \end_layout
28297
28298 \end_inset
28299 </cell>
28300 </row>
28301 <row topline="true">
28302 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28303 \begin_inset Text
28304
28305 \begin_layout Standard
28306 SIG_INT2
28307 \end_layout
28308
28309 \end_inset
28310 </cell>
28311 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28312 \begin_inset Text
28313
28314 \begin_layout Standard
28315 INT2 external interrupt
28316 \end_layout
28317
28318 \end_inset
28319 </cell>
28320 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28321 \begin_inset Text
28322
28323 \begin_layout Standard
28324 SIG_PSP
28325 \end_layout
28326
28327 \end_inset
28328 </cell>
28329 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28330 \begin_inset Text
28331
28332 \begin_layout Standard
28333 Parallel slave port interrupt
28334 \end_layout
28335
28336 \end_inset
28337 </cell>
28338 </row>
28339 <row topline="true">
28340 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28341 \begin_inset Text
28342
28343 \begin_layout Standard
28344 SIG_CCP1
28345 \end_layout
28346
28347 \end_inset
28348 </cell>
28349 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28350 \begin_inset Text
28351
28352 \begin_layout Standard
28353 CCP1 module interrupt
28354 \end_layout
28355
28356 \end_inset
28357 </cell>
28358 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28359 \begin_inset Text
28360
28361 \begin_layout Standard
28362 SIG_AD
28363 \end_layout
28364
28365 \end_inset
28366 </cell>
28367 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28368 \begin_inset Text
28369
28370 \begin_layout Standard
28371 AD convertion complete interrupt
28372 \end_layout
28373
28374 \end_inset
28375 </cell>
28376 </row>
28377 <row topline="true">
28378 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28379 \begin_inset Text
28380
28381 \begin_layout Standard
28382 SIG_CCP2
28383 \end_layout
28384
28385 \end_inset
28386 </cell>
28387 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28388 \begin_inset Text
28389
28390 \begin_layout Standard
28391 CCP2 module interrupt
28392 \end_layout
28393
28394 \end_inset
28395 </cell>
28396 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28397 \begin_inset Text
28398
28399 \begin_layout Standard
28400 SIG_RC
28401 \end_layout
28402
28403 \end_inset
28404 </cell>
28405 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28406 \begin_inset Text
28407
28408 \begin_layout Standard
28409 USART receive interrupt
28410 \end_layout
28411
28412 \end_inset
28413 </cell>
28414 </row>
28415 <row topline="true">
28416 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28417 \begin_inset Text
28418
28419 \begin_layout Standard
28420 SIG_TMR0
28421 \end_layout
28422
28423 \end_inset
28424 </cell>
28425 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28426 \begin_inset Text
28427
28428 \begin_layout Standard
28429 TMR0 overflow interrupt
28430 \end_layout
28431
28432 \end_inset
28433 </cell>
28434 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28435 \begin_inset Text
28436
28437 \begin_layout Standard
28438 SIG_TX
28439 \end_layout
28440
28441 \end_inset
28442 </cell>
28443 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28444 \begin_inset Text
28445
28446 \begin_layout Standard
28447 USART transmit interrupt
28448 \end_layout
28449
28450 \end_inset
28451 </cell>
28452 </row>
28453 <row topline="true">
28454 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28455 \begin_inset Text
28456
28457 \begin_layout Standard
28458 SIG_TMR1
28459 \end_layout
28460
28461 \end_inset
28462 </cell>
28463 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28464 \begin_inset Text
28465
28466 \begin_layout Standard
28467 TMR1 overflow interrupt
28468 \end_layout
28469
28470 \end_inset
28471 </cell>
28472 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28473 \begin_inset Text
28474
28475 \begin_layout Standard
28476 SIG_MSSP
28477 \end_layout
28478
28479 \end_inset
28480 </cell>
28481 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28482 \begin_inset Text
28483
28484 \begin_layout Standard
28485 SSP receive/transmit interrupt
28486 \end_layout
28487
28488 \end_inset
28489 </cell>
28490 </row>
28491 <row topline="true">
28492 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28493 \begin_inset Text
28494
28495 \begin_layout Standard
28496 SIG_TMR2
28497 \end_layout
28498
28499 \end_inset
28500 </cell>
28501 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28502 \begin_inset Text
28503
28504 \begin_layout Standard
28505 TMR2 matches PR2 interrupt
28506 \end_layout
28507
28508 \end_inset
28509 </cell>
28510 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28511 \begin_inset Text
28512
28513 \begin_layout Standard
28514
28515 \end_layout
28516
28517 \end_inset
28518 </cell>
28519 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28520 \begin_inset Text
28521
28522 \begin_layout Standard
28523
28524 \end_layout
28525
28526 \end_inset
28527 </cell>
28528 </row>
28529 <row topline="true" bottomline="true">
28530 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28531 \begin_inset Text
28532
28533 \begin_layout Standard
28534 SIG_TMR3
28535 \end_layout
28536
28537 \end_inset
28538 </cell>
28539 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28540 \begin_inset Text
28541
28542 \begin_layout Standard
28543 TMR3 overflow interrupt
28544 \end_layout
28545
28546 \end_inset
28547 </cell>
28548 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28549 \begin_inset Text
28550
28551 \begin_layout Standard
28552
28553 \end_layout
28554
28555 \end_inset
28556 </cell>
28557 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28558 \begin_inset Text
28559
28560 \begin_layout Standard
28561
28562 \end_layout
28563
28564 \end_inset
28565 </cell>
28566 </row>
28567 </lyxtabular>
28568
28569 \end_inset
28570
28571
28572 \end_layout
28573
28574 \begin_layout Standard
28575 The prototypes for these names are defined in the header file 
28576 \emph on
28577 signal.h
28578 \emph default
28579  .
28580 \end_layout
28581
28582 \begin_layout Standard
28583 In order to simplify signal handling, a number of macros is provided:
28584 \end_layout
28585
28586 \begin_layout List
28587 \labelwidthstring 00.00.0000
28588 DEF_INTHIGH(name) begin the definition of the interrupt dispatch table for
28589  high priority interrupts.
28590  
28591 \emph on
28592 name
28593 \emph default
28594  is the function name to use.
28595 \end_layout
28596
28597 \begin_layout List
28598 \labelwidthstring 00.00.0000
28599 DEF_INTLOW(name) begin the definition of the interrupt dispatch table fo
28600  low priority interrupt.
28601  
28602 \emph on
28603 name
28604 \emph default
28605  is the function name to use.
28606 \end_layout
28607
28608 \begin_layout List
28609 \labelwidthstring 00.00.0000
28610 DEF_HANDLER(sig,handler) define a handler for signal 
28611 \emph on
28612 sig.
28613 \end_layout
28614
28615 \begin_layout List
28616 \labelwidthstring 00.00.0000
28617 END_DEF end the declaration of the dispatch table.
28618 \end_layout
28619
28620 \begin_layout Standard
28621 Additionally there are two more macros to simplify the declaration of the
28622  signal handler:
28623 \end_layout
28624
28625 \begin_layout List
28626 \labelwidthstring 00.00.0000
28627
28628 \series medium
28629 SIGHANDLER(handler) 
28630 \series default
28631 this declares the function prototype for the 
28632 \emph on
28633 handler
28634 \emph default
28635  function.
28636 \end_layout
28637
28638 \begin_layout List
28639 \labelwidthstring 00.00.0000
28640 SIGHANDLERNAKED(handler) same as SIGHANDLER() but declares a naked function.
28641 \end_layout
28642
28643 \begin_layout Standard
28644 An example of using the macros above is shown below:
28645 \end_layout
28646
28647 \begin_layout LyX-Code
28648 #include <pic18fregs.h>
28649 \end_layout
28650
28651 \begin_layout LyX-Code
28652 #include <signal.h>
28653 \newline
28654
28655 \newline
28656 DEF_INTHIGH(high_int)
28657 \end_layout
28658
28659 \begin_layout LyX-Code
28660 DEF_HANDLER(SIG_TMR0, _tmr0_handler)
28661 \end_layout
28662
28663 \begin_layout LyX-Code
28664 DEF_HANDLER(SIG_BCOL, _bcol_handler)
28665 \end_layout
28666
28667 \begin_layout LyX-Code
28668 END_DEF
28669 \newline
28670
28671 \newline
28672 SIGHANDLER(_tmr0_handler)
28673 \end_layout
28674
28675 \begin_layout LyX-Code
28676 {
28677 \end_layout
28678
28679 \begin_layout LyX-Code
28680   /* action to be taken when timer 0 overflows */
28681 \end_layout
28682
28683 \begin_layout LyX-Code
28684 }
28685 \newline
28686
28687 \newline
28688 SIGHANDLERNAKED(_bcol_handler)
28689 \end_layout
28690
28691 \begin_layout LyX-Code
28692 {
28693 \end_layout
28694
28695 \begin_layout LyX-Code
28696   _asm
28697 \end_layout
28698
28699 \begin_layout LyX-Code
28700     /* action to be taken when bus collision occurs */
28701 \end_layout
28702
28703 \begin_layout LyX-Code
28704     retfie
28705 \end_layout
28706
28707 \begin_layout LyX-Code
28708  _endasm;
28709 \end_layout
28710
28711 \begin_layout LyX-Code
28712 }
28713 \end_layout
28714
28715 \begin_layout Standard
28716
28717 \series bold
28718 NOTES:
28719 \series default
28720  Special care should be taken when using the above scheme:
28721 \end_layout
28722
28723 \begin_layout Itemize
28724 do not place a colon (;) at the end of the DEF_* and END_DEF macros.
28725 \end_layout
28726
28727 \begin_layout Itemize
28728 when declaring SIGHANDLERNAKED handler never forget to use 
28729 \emph on
28730 retfie
28731 \emph default
28732  for proper returning.
28733 \end_layout
28734
28735 \begin_layout Subsection
28736 PIC16 Port -- Tips
28737 \end_layout
28738
28739 \begin_layout Standard
28740 Here you can find some general tips for compiling programs with SDCC/pic16.
28741 \end_layout
28742
28743 \begin_layout Subsubsection
28744 Stack size
28745 \end_layout
28746
28747 \begin_layout Standard
28748 The default stack
28749 \begin_inset LatexCommand \index{PIC16!stack}
28750
28751 \end_inset
28752
28753  size (that is 64 bytes) probably is enough for many programs.
28754  One must take care that when there are many levels of function nesting,
28755  or there is excessive usage of stack, its size should be extended.
28756  An example of such a case is the printf/sprintf family of functions.
28757  If you encounter problems like not being able to print integers, then you
28758  need to set the stack size around the maximum (256 for small stack model).
28759  The following diagram shows what happens when calling printf to print an
28760  integer:
28761 \end_layout
28762
28763 \begin_layout LyX-Code
28764 printf () --> ltoa () --> ultoa () --> divschar ()
28765 \end_layout
28766
28767 \begin_layout Standard
28768 It is should be understood that stack is easily consumed when calling complicate
28769 d functions.
28770  Using command line arguments like -
28771 \begin_inset ERT
28772 status collapsed
28773
28774 \begin_layout Standard
28775
28776
28777 \backslash
28778 /
28779 \end_layout
28780
28781 \end_inset
28782
28783 -fommit-frame-pointer might reduce stack usage by not creating unnecessery
28784  stack frames.
28785  Other ways to reduce stack usage may exist.
28786 \end_layout
28787
28788 \begin_layout Subsection
28789 Known Bugs
28790 \end_layout
28791
28792 \begin_layout Standard
28793 The PIC16 Port currently does not pass SDCC's regression test
28794 \begin_inset LatexCommand \index{Regression test (PIC16)}
28795
28796 \end_inset
28797
28798  suite (see section 
28799 \begin_inset LatexCommand \ref{sec:Quality-control}
28800
28801 \end_inset
28802
28803 ) and thus the snapshot build regression tests for the PIC16 target are
28804  currently disabled for all hosts
28805 \emph on
28806 .
28807 \end_layout
28808
28809 \begin_layout Chapter
28810 Debugging
28811 \end_layout
28812
28813 \begin_layout Standard
28814 There are several approaches to debugging your code.
28815  This chapter is meant to show your options and to give detail on some of
28816  them:
28817 \newline
28818
28819 \newline
28820 When writing your code:
28821 \end_layout
28822
28823 \begin_layout Itemize
28824 write your code with debugging in mind (avoid duplicating code, put conceptually
28825  similar variables into structs, use structured code, have strategic points
28826  within your code where all variables are consistent, ...)
28827 \end_layout
28828
28829 \begin_layout Itemize
28830 run a syntax-checking tool like splint
28831 \begin_inset LatexCommand \index{splint (syntax checking tool)}
28832
28833 \end_inset
28834
28835
28836 \begin_inset LatexCommand \index{lint (syntax checking tool)}
28837
28838 \end_inset
28839
28840  (see -
28841 \begin_inset ERT
28842 status collapsed
28843
28844 \begin_layout Standard
28845
28846
28847 \backslash
28848 /
28849 \end_layout
28850
28851 \end_inset
28852
28853 -more-pedantic 
28854 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
28855
28856 \end_inset
28857
28858 ) over the code.
28859 \end_layout
28860
28861 \begin_layout Itemize
28862 for the high level code use a C-compiler (like f.e.
28863  GCC) to compile run and debug the code on your host.
28864  See (see -
28865 \begin_inset ERT
28866 status collapsed
28867
28868 \begin_layout Standard
28869
28870
28871 \backslash
28872 /
28873 \end_layout
28874
28875 \end_inset
28876
28877 -more-pedantic 
28878 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
28879
28880 \end_inset
28881
28882 ) on how to handle syntax extensions like __xdata, __at(), ...
28883  
28884 \end_layout
28885
28886 \begin_layout Itemize
28887 use another C-compiler to compile code for your target.
28888  Always an option but not recommended:) And not very likely to help you.
28889  If you seriously consider walking this path you should at least occasionally
28890  check portability of your code.
28891  Most commercial compiler vendors will offer an evaluation version so you
28892  can test compile your code or snippets of your code.
28893 \end_layout
28894
28895 \begin_layout Standard
28896 Debugging on a simulator:
28897 \end_layout
28898
28899 \begin_layout Itemize
28900 there is a separate section about SDCDB (section 
28901 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
28902
28903 \end_inset
28904
28905 ) below.
28906 \end_layout
28907
28908 \begin_layout Itemize
28909 or (8051 specific) use a freeware/commercial simulator which interfaces
28910  to the AOMF
28911 \begin_inset LatexCommand \index{AOMF, AOMF51}
28912
28913 \end_inset
28914
28915  file (see 
28916 \begin_inset LatexCommand \ref{OMF file}
28917
28918 \end_inset
28919
28920 ) optionally generated by SDCC.
28921 \end_layout
28922
28923 \begin_layout Standard
28924 Debugging On-target: 
28925 \end_layout
28926
28927 \begin_layout Itemize
28928 use a MCU port pin to serially output debug data to the RS232 port of your
28929  host.
28930  You'll probably want some level shifting device typically involving a MAX232
28931  or similar IC.
28932  If the hardware serial port of the MCU is not available search for 'Software
28933  UART' in your favourite search machine.
28934 \end_layout
28935
28936 \begin_layout Itemize
28937 use an on-target monitor.
28938  In this context a monitor is a small program which usually accepts commands
28939  via a serial line and allows to set program counter, to single step through
28940  a program and read/write memory locations.
28941  For the 8051 good examples of monitors are paulmon and cmon51 (see section
28942  
28943 \begin_inset LatexCommand \ref{sec:Related-open-source-tools}
28944
28945 \end_inset
28946
28947 ).
28948 \end_layout
28949
28950 \begin_layout Itemize
28951 toggle MCU port pins at strategic points within your code and use an oscilloscop
28952 e.
28953  A 
28954 \emph on
28955 digital oscilloscope
28956 \emph default
28957
28958 \begin_inset LatexCommand \index{Oscilloscope}
28959
28960 \end_inset
28961
28962  with deep trace memory is really helpful especially if you have to debug
28963  a realtime application.
28964  If you need to monitor more pins than your oscilloscope provides you can
28965  sometimes get away with a small R-2R network.
28966  On a single channel oscilloscope you could f.e.
28967  monitor 2 push-pull driven pins by connecting one via a 10\InsetSpace ~
28968 k
28969 \begin_inset Formula $\Omega$
28970 \end_inset
28971
28972  resistor and the other one by a 5\InsetSpace ~
28973 k
28974 \begin_inset Formula $\Omega$
28975 \end_inset
28976
28977  resistor to the oscilloscope probe (check output drive capability of the
28978  pins you want to monitor).
28979  If you need to monitor many more pins a 
28980 \emph on
28981 logic analyzer
28982 \emph default
28983  will be handy.
28984 \end_layout
28985
28986 \begin_layout Itemize
28987 use an ICE (
28988 \emph on
28989 i
28990 \emph default
28991
28992 \emph on
28993 c
28994 \emph default
28995 ircuit 
28996 \emph on
28997 e
28998 \emph default
28999 mulator
29000 \begin_inset LatexCommand \index{ICE (in circuit emulator)}
29001
29002 \end_inset
29003
29004 ).
29005  Usually very expensive.
29006  And very nice to have too.
29007  And usually locks you (for years...) to the devices the ICE can emulate.
29008  
29009 \end_layout
29010
29011 \begin_layout Itemize
29012 use a remote debugger.
29013  In most 8-bit systems the symbol information is not available on the target,
29014  and a complete debugger is too bulky for the target system.
29015  Therefore usually a debugger on the host system connects to an on-target
29016  debugging stub which accepts only primitive commands.
29017  
29018 \newline
29019 Terms to enter into your favourite search engine could be 'remote debugging',
29020  'gdb stub' or 'inferior debugger'.
29021  (is there one?)
29022 \end_layout
29023
29024 \begin_layout Itemize
29025 use an on target hardware debugger.
29026  Some of the more modern MCUs include hardware support for setting break
29027  points and monitoring/changing variables by using dedicated hardware pins.
29028  This facility doesn't require additional code to run on the target and
29029  
29030 \emph on
29031 usually
29032 \emph default
29033  doesn't affect runtime behaviour until a breakpoint is hit.
29034  For the mcs51 most hardware debuggers use the AOMF
29035 \begin_inset LatexCommand \index{AOMF, AOMF51}
29036
29037 \end_inset
29038
29039  file (see 
29040 \begin_inset LatexCommand \ref{OMF file}
29041
29042 \end_inset
29043
29044 ) as input file.
29045  
29046 \end_layout
29047
29048 \begin_layout Standard
29049 Last not least:
29050 \end_layout
29051
29052 \begin_layout Itemize
29053 if you are not familiar with any of the following terms you're likely to
29054  run into problems rather sooner than later: 
29055 \emph on
29056 volatile
29057 \emph default
29058
29059 \emph on
29060 atomic
29061 \emph default
29062
29063 \emph on
29064 memory map
29065 \emph default
29066
29067 \emph on
29068 overlay
29069 \emph default
29070 .
29071  As an embedded programmer you 
29072 \emph on
29073 have
29074 \emph default
29075  to know them so why not look them up 
29076 \emph on
29077 before
29078 \emph default
29079  you have problems?)
29080 \end_layout
29081
29082 \begin_layout Itemize
29083 tell someone else about your problem (actually this is a surprisingly effective
29084  means to hunt down the bug even if the listener is not familiar with your
29085  environment).
29086  As 'failure to communicate' is probably one of the job-induced deformations
29087  of an embedded programmer this is highly encouraged.
29088 \end_layout
29089
29090 \begin_layout Section
29091 Debugging with SDCDB
29092 \begin_inset LatexCommand \label{cha:Debugging-with-SDCDB}
29093
29094 \end_inset
29095
29096
29097 \begin_inset LatexCommand \index{SDCDB (debugger)}
29098
29099 \end_inset
29100
29101  
29102 \end_layout
29103
29104 \begin_layout Standard
29105 SDCC is distributed with a source level debugger
29106 \begin_inset LatexCommand \index{Debugger}
29107
29108 \end_inset
29109
29110 .
29111  The debugger uses a command line interface, the command repertoire of the
29112  debugger has been kept as close to gdb
29113 \begin_inset LatexCommand \index{gdb}
29114
29115 \end_inset
29116
29117  (the GNU debugger) as possible.
29118  The configuration and build process is part of the standard compiler installati
29119 on, which also builds and installs the debugger in the target directory
29120  specified during configuration.
29121  The debugger allows you debug BOTH at the C source and at the ASM source
29122  level.
29123 \end_layout
29124
29125 \begin_layout Subsection
29126 Compiling for Debugging
29127 \end_layout
29128
29129 \begin_layout Standard
29130 The -
29131 \begin_inset ERT
29132 status collapsed
29133
29134 \begin_layout Standard
29135
29136
29137 \backslash
29138 /
29139 \end_layout
29140
29141 \end_inset
29142
29143 -debug
29144 \begin_inset LatexCommand \index{-\/-debug}
29145
29146 \end_inset
29147
29148  option must be specified for all files for which debug information is to
29149  be generated.
29150  The compiler generates a .adb file for each of these files.
29151  The linker creates the .cdb
29152 \begin_inset LatexCommand \index{<file>.cdb}
29153
29154 \end_inset
29155
29156  file from the .adb
29157 \begin_inset LatexCommand \index{<file>.adb}
29158
29159 \end_inset
29160
29161  files and the address information.
29162  This .cdb is used by the debugger.
29163 \end_layout
29164
29165 \begin_layout Subsection
29166 How the Debugger Works
29167 \end_layout
29168
29169 \begin_layout Standard
29170 When the -
29171 \begin_inset ERT
29172 status collapsed
29173
29174 \begin_layout Standard
29175
29176
29177 \backslash
29178 /
29179 \end_layout
29180
29181 \end_inset
29182
29183 -debug option is specified the compiler generates extra symbol information
29184  some of which are put into the assembler source and some are put into the
29185  .adb file.
29186  Then the linker creates the .cdb file from the individual .adb files with
29187  the address information for the symbols.
29188  The debugger reads the symbolic information generated by the compiler &
29189  the address information generated by the linker.
29190  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
29191  execution is controlled by the debugger.
29192  When a command is issued for the debugger, it translates it into appropriate
29193  commands for the simulator.
29194  (Currently SDCDM only connects to the simulator but 
29195 \emph on
29196 newcdb
29197 \emph default
29198  at 
29199 \begin_inset LatexCommand \url{http://ec2drv.sf.net/}
29200
29201 \end_inset
29202
29203  is an effort to connect directly to the hardware.) 
29204 \end_layout
29205
29206 \begin_layout Subsection
29207 Starting the Debugger SDCDB
29208 \end_layout
29209
29210 \begin_layout Standard
29211 The debugger can be started using the following command line.
29212  (Assume the file you are debugging has the file name foo).
29213 \newline
29214
29215 \newline
29216
29217 \family sans
29218 \series bold
29219 sdcdb foo
29220 \newline
29221
29222 \family default
29223 \series default
29224
29225 \newline
29226 The debugger will look for the following files.
29227 \end_layout
29228
29229 \begin_layout Itemize
29230 foo.c - the source file.
29231 \end_layout
29232
29233 \begin_layout Itemize
29234 foo.cdb - the debugger symbol information file.
29235 \end_layout
29236
29237 \begin_layout Itemize
29238 foo.ihx - the Intel hex format
29239 \begin_inset LatexCommand \index{Intel hex format}
29240
29241 \end_inset
29242
29243  object file.
29244 \end_layout
29245
29246 \begin_layout Subsection
29247 SDCDB Command Line Options
29248 \end_layout
29249
29250 \begin_layout Itemize
29251 -
29252 \begin_inset ERT
29253 status collapsed
29254
29255 \begin_layout Standard
29256
29257
29258 \backslash
29259 /
29260 \end_layout
29261
29262 \end_inset
29263
29264 -directory=<source file directory> this option can used to specify the directory
29265  search list.
29266  The debugger will look into the directory list specified for source, cdb
29267  & ihx files.
29268  The items in the directory list must be separated by ':', e.g.
29269  if the source files can be in the directories /home/src1 and /home/src2,
29270  the -
29271 \begin_inset ERT
29272 status collapsed
29273
29274 \begin_layout Standard
29275
29276
29277 \backslash
29278 /
29279 \end_layout
29280
29281 \end_inset
29282
29283 -directory option should be -
29284 \begin_inset ERT
29285 status collapsed
29286
29287 \begin_layout Standard
29288
29289
29290 \backslash
29291 /
29292 \end_layout
29293
29294 \end_inset
29295
29296 -directory=/home/src1:/home/src2.
29297  Note there can be no spaces in the option.
29298  
29299 \end_layout
29300
29301 \begin_layout Itemize
29302 -cd <directory> - change to the <directory>.
29303 \end_layout
29304
29305 \begin_layout Itemize
29306 -fullname - used by GUI front ends.
29307 \end_layout
29308
29309 \begin_layout Itemize
29310 -cpu <cpu-type> - this argument is passed to the simulator please see the
29311  simulator docs for details.
29312 \end_layout
29313
29314 \begin_layout Itemize
29315 -X <Clock frequency > this options is passed to the simulator please see
29316  the simulator docs for details.
29317 \end_layout
29318
29319 \begin_layout Itemize
29320 -s <serial port file> passed to simulator see the simulator docs for details.
29321 \end_layout
29322
29323 \begin_layout Itemize
29324 -S <serial in,out> passed to simulator see the simulator docs for details.
29325 \end_layout
29326
29327 \begin_layout Itemize
29328 -k <port number> passed to simulator see the simulator docs for details.
29329 \end_layout
29330
29331 \begin_layout Subsection
29332 SDCDB Debugger Commands
29333 \end_layout
29334
29335 \begin_layout Standard
29336 As mentioned earlier the command interface for the debugger has been deliberatel
29337 y kept as close the GNU debugger gdb, as possible.
29338  This will help the integration with existing graphical user interfaces
29339  (like ddd, xxgdb or xemacs) existing for the GNU debugger.
29340  If you use a graphical user interface for the debugger you can skip this
29341  section.
29342 \end_layout
29343
29344 \begin_layout Subsubsection*
29345 break [line | file:line | function | file:function]
29346 \end_layout
29347
29348 \begin_layout Standard
29349 Set breakpoint at specified line or function:
29350 \newline
29351
29352 \newline
29353
29354 \family sans
29355 \series bold
29356 sdcdb>break 100 
29357 \newline
29358 sdcdb>break foo.c:100
29359 \newline
29360 sdcdb>break funcfoo
29361 \newline
29362 sdcdb>break foo.c:funcfoo
29363 \end_layout
29364
29365 \begin_layout Subsubsection*
29366 clear [line | file:line | function | file:function ]
29367 \end_layout
29368
29369 \begin_layout Standard
29370 Clear breakpoint at specified line or function:
29371 \newline
29372
29373 \newline
29374
29375 \family sans
29376 \series bold
29377 sdcdb>clear 100
29378 \newline
29379 sdcdb>clear foo.c:100
29380 \newline
29381 sdcdb>clear funcfoo
29382 \newline
29383 sdcdb>clear foo.c:funcfoo
29384 \end_layout
29385
29386 \begin_layout Subsubsection*
29387 continue
29388 \end_layout
29389
29390 \begin_layout Standard
29391 Continue program being debugged, after breakpoint.
29392 \end_layout
29393
29394 \begin_layout Subsubsection*
29395 finish
29396 \end_layout
29397
29398 \begin_layout Standard
29399 Execute till the end of the current function.
29400 \end_layout
29401
29402 \begin_layout Subsubsection*
29403 delete [n]
29404 \end_layout
29405
29406 \begin_layout Standard
29407 Delete breakpoint number 'n'.
29408  If used without any option clear ALL user defined break points.
29409 \end_layout
29410
29411 \begin_layout Subsubsection*
29412 info [break | stack | frame | registers ]
29413 \end_layout
29414
29415 \begin_layout Itemize
29416 info break - list all breakpoints
29417 \end_layout
29418
29419 \begin_layout Itemize
29420 info stack - show the function call stack.
29421 \end_layout
29422
29423 \begin_layout Itemize
29424 info frame - show information about the current execution frame.
29425 \end_layout
29426
29427 \begin_layout Itemize
29428 info registers - show content of all registers.
29429 \end_layout
29430
29431 \begin_layout Subsubsection*
29432 step
29433 \end_layout
29434
29435 \begin_layout Standard
29436 Step program until it reaches a different source line.
29437  Note: pressing <return> repeats the last command.
29438 \end_layout
29439
29440 \begin_layout Subsubsection*
29441 next
29442 \end_layout
29443
29444 \begin_layout Standard
29445 Step program, proceeding through subroutine calls.
29446 \end_layout
29447
29448 \begin_layout Subsubsection*
29449 run
29450 \end_layout
29451
29452 \begin_layout Standard
29453 Start debugged program.
29454 \end_layout
29455
29456 \begin_layout Subsubsection*
29457 ptype variable 
29458 \end_layout
29459
29460 \begin_layout Standard
29461 Print type information of the variable.
29462 \end_layout
29463
29464 \begin_layout Subsubsection*
29465 print variable
29466 \end_layout
29467
29468 \begin_layout Standard
29469 print value of variable.
29470 \end_layout
29471
29472 \begin_layout Subsubsection*
29473 file filename
29474 \end_layout
29475
29476 \begin_layout Standard
29477 load the given file name.
29478  Note this is an alternate method of loading file for debugging.
29479 \end_layout
29480
29481 \begin_layout Subsubsection*
29482 frame
29483 \end_layout
29484
29485 \begin_layout Standard
29486 print information about current frame.
29487 \end_layout
29488
29489 \begin_layout Subsubsection*
29490 set srcmode
29491 \end_layout
29492
29493 \begin_layout Standard
29494 Toggle between C source & assembly source.
29495 \end_layout
29496
29497 \begin_layout Subsubsection*
29498 ! simulator command
29499 \end_layout
29500
29501 \begin_layout Standard
29502 Send the string following '!' to the simulator, the simulator response is
29503  displayed.
29504  Note the debugger does not interpret the command being sent to the simulator,
29505  so if a command like 'go' is sent the debugger can loose its execution
29506  context and may display incorrect values.
29507 \end_layout
29508
29509 \begin_layout Subsubsection*
29510 quit
29511 \end_layout
29512
29513 \begin_layout Standard
29514 "Watch me now.
29515  Iam going Down.
29516  My name is Bobby Brown"
29517 \end_layout
29518
29519 \begin_layout Subsection
29520 Interfacing SDCDB with DDD
29521 \end_layout
29522
29523 \begin_layout Standard
29524 \begin_inset Note Note
29525 status collapsed
29526
29527 \begin_layout Standard
29528 The screenshot was converted from png to eps with: 
29529 \begin_inset Quotes sld
29530 \end_inset
29531
29532 bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps
29533 \begin_inset Quotes srd
29534 \end_inset
29535
29536  which produces a pretty compact eps file which is free from compression
29537  artifacts.
29538 \end_layout
29539
29540 \begin_layout Standard
29541 The screenshot was included in sdccman.lyx cvs version 1.120 but later removed
29542  as this broke the build system on Sourceforge (pdf-file was broken.
29543  pdflatex does not accept eps files).
29544 \end_layout
29545
29546 \end_inset
29547
29548
29549 \end_layout
29550
29551 \begin_layout Standard
29552 The 
29553 \emph on
29554 p
29555 \emph default
29556 ortable 
29557 \emph on
29558 n
29559 \emph default
29560 etwork 
29561 \emph on
29562 g
29563 \emph default
29564 raphics File 
29565 \size footnotesize
29566
29567 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/doc/figures/ddd_example.png}
29568
29569 \end_inset
29570
29571
29572 \size default
29573  shows a screenshot of a debugging session with DDD
29574 \begin_inset LatexCommand \index{DDD (debugger)}
29575
29576 \end_inset
29577
29578  (Unix only) on a simulated 8032.
29579  The debugging session might not run as smoothly as the screenshot suggests.
29580  The debugger allows setting of breakpoints, displaying and changing variables,
29581  single stepping through C and assembler code.
29582  
29583 \newline
29584 The source was compiled with 
29585 \family sans
29586 \series bold
29587
29588 \newline
29589
29590 \newline
29591 sdcc -
29592 \family default
29593 \series default
29594
29595 \begin_inset ERT
29596 status collapsed
29597
29598 \begin_layout Standard
29599
29600
29601 \backslash
29602 /
29603 \end_layout
29604
29605 \end_inset
29606
29607
29608 \family sans
29609 \series bold
29610 -debug ddd_example.c
29611 \family default
29612 \series default
29613  
29614 \family sans
29615 \series bold
29616
29617 \newline
29618
29619 \family default
29620 \series default
29621
29622 \newline
29623 and DDD was invoked with 
29624 \family sans
29625 \series bold
29626
29627 \newline
29628
29629 \newline
29630 ddd -debugger "sdcdb -cpu 8032 ddd_example"
29631 \end_layout
29632
29633 \begin_layout Standard
29634 \begin_inset Note Note
29635 status open
29636
29637 \begin_layout Standard
29638 Check that the double quotes or an apostroph within the command line survive
29639  the LyX tool chain.
29640  Previously the apostrophs got slanted in the PDF output so a cut and paste
29641  did not work.
29642 \end_layout
29643
29644 \end_inset
29645
29646
29647 \end_layout
29648
29649 \begin_layout Subsection
29650 Interfacing SDCDB with XEmacs
29651 \begin_inset LatexCommand \index{XEmacs}
29652
29653 \end_inset
29654
29655
29656 \begin_inset LatexCommand \index{Emacs}
29657
29658 \end_inset
29659
29660
29661 \end_layout
29662
29663 \begin_layout Standard
29664 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
29665  sdcdb.el and sdcdbsrc.el.
29666  These two files can be found in the $(prefix)/bin directory after the installat
29667 ion is complete.
29668  These files need to be loaded into XEmacs for the interface to work.
29669  This can be done at XEmacs startup time by inserting the following into
29670  your '.xemacs' file (which can be found in your HOME directory): 
29671 \newline
29672
29673 \newline
29674
29675 \family typewriter
29676 (load-file sdcdbsrc.el) 
29677 \family default
29678
29679 \newline
29680
29681 \newline
29682 .xemacs is a lisp file so the () around the command is REQUIRED.
29683  The files can also be loaded dynamically while XEmacs is running, set the
29684  environment variable 'EMACSLOADPATH' to the installation bin directory
29685  (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
29686  To start the interface enter the following command: 
29687 \newline
29688
29689 \newline
29690
29691 \family sans
29692 \series bold
29693 ESC-x sdcdbsrc
29694 \family default
29695 \series default
29696
29697 \newline
29698
29699 \newline
29700 You will prompted to enter the file name to be debugged.
29701  
29702 \newline
29703
29704 \newline
29705 The command line options that are passed to the simulator directly are
29706  bound to default values in the file sdcdbsrc.el.
29707  The variables are listed below, these values maybe changed as required.
29708 \end_layout
29709
29710 \begin_layout Itemize
29711 sdcdbsrc-cpu-type '51
29712 \end_layout
29713
29714 \begin_layout Itemize
29715 sdcdbsrc-frequency '11059200
29716 \end_layout
29717
29718 \begin_layout Itemize
29719 sdcdbsrc-serial nil
29720 \end_layout
29721
29722 \begin_layout Standard
29723 The following is a list of key mapping for the debugger interface.
29724 \end_layout
29725
29726 \begin_layout Standard
29727 \InsetSpace ~
29728
29729 \family typewriter
29730
29731 \newline
29732 ;;\InsetSpace ~
29733 Current Listing :: 
29734 \newline
29735 ;;key\InsetSpace ~
29736 \InsetSpace ~
29737 \InsetSpace ~
29738 \InsetSpace ~
29739 \InsetSpace ~
29740 \InsetSpace ~
29741 \InsetSpace ~
29742 \InsetSpace ~
29743 \InsetSpace ~
29744 \InsetSpace ~
29745 \InsetSpace ~
29746 \InsetSpace ~
29747 \InsetSpace ~
29748 \InsetSpace ~
29749 binding\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 \InsetSpace ~
29768 \InsetSpace ~
29769 \InsetSpace ~
29770 \InsetSpace ~
29771 Comment 
29772 \newline
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 \InsetSpace ~
29806 \InsetSpace ~
29807 \InsetSpace ~
29808 \InsetSpace ~
29809 -------
29810 \newline
29811 ;; 
29812 \newline
29813 ;;\InsetSpace ~
29814 n\InsetSpace ~
29815 \InsetSpace ~
29816 \InsetSpace ~
29817 \InsetSpace ~
29818 \InsetSpace ~
29819 \InsetSpace ~
29820 \InsetSpace ~
29821 \InsetSpace ~
29822 \InsetSpace ~
29823 \InsetSpace ~
29824 \InsetSpace ~
29825 \InsetSpace ~
29826 \InsetSpace ~
29827 \InsetSpace ~
29828 \InsetSpace ~
29829 sdcdb-next-fro
29830 m-src\InsetSpace ~
29831 \InsetSpace ~
29832 \InsetSpace ~
29833 \InsetSpace ~
29834 \InsetSpace ~
29835 \InsetSpace ~
29836 \InsetSpace ~
29837 \InsetSpace ~
29838 \InsetSpace ~
29839 \InsetSpace ~
29840 SDCDB next command 
29841 \newline
29842 ;;\InsetSpace ~
29843 b\InsetSpace ~
29844 \InsetSpace ~
29845 \InsetSpace ~
29846 \InsetSpace ~
29847 \InsetSpace ~
29848 \InsetSpace ~
29849 \InsetSpace ~
29850 \InsetSpace ~
29851 \InsetSpace ~
29852 \InsetSpace ~
29853 \InsetSpace ~
29854 \InsetSpace ~
29855 \InsetSpace ~
29856 \InsetSpace ~
29857 \InsetSpace ~
29858 sdcdb-back-from-src\InsetSpace ~
29859 \InsetSpace ~
29860 \InsetSpace ~
29861 \InsetSpace ~
29862 \InsetSpace ~
29863 \InsetSpace ~
29864 \InsetSpace ~
29865 \InsetSpace ~
29866 \InsetSpace ~
29867 \InsetSpace ~
29868 SDCDB back command 
29869 \newline
29870 ;;\InsetSpace ~
29871 c\InsetSpace ~
29872 \InsetSpace ~
29873 \InsetSpace ~
29874 \InsetSpace ~
29875 \InsetSpace ~
29876 \InsetSpace ~
29877 \InsetSpace ~
29878 \InsetSpace ~
29879 \InsetSpace ~
29880 \InsetSpace ~
29881 \InsetSpace ~
29882 \InsetSpace ~
29883 \InsetSpace ~
29884 \InsetSpace ~
29885 \InsetSpace ~
29886 sdcdb-cont-f
29887 rom-src\InsetSpace ~
29888 \InsetSpace ~
29889 \InsetSpace ~
29890 \InsetSpace ~
29891 \InsetSpace ~
29892 \InsetSpace ~
29893 \InsetSpace ~
29894 \InsetSpace ~
29895 \InsetSpace ~
29896 \InsetSpace ~
29897 SDCDB continue command
29898 \newline
29899 ;;\InsetSpace ~
29900 s\InsetSpace ~
29901 \InsetSpace ~
29902 \InsetSpace ~
29903 \InsetSpace ~
29904 \InsetSpace ~
29905 \InsetSpace ~
29906 \InsetSpace ~
29907 \InsetSpace ~
29908 \InsetSpace ~
29909 \InsetSpace ~
29910 \InsetSpace ~
29911 \InsetSpace ~
29912 \InsetSpace ~
29913 \InsetSpace ~
29914 \InsetSpace ~
29915 sdcdb-step-from-src\InsetSpace ~
29916 \InsetSpace ~
29917 \InsetSpace ~
29918 \InsetSpace ~
29919 \InsetSpace ~
29920 \InsetSpace ~
29921 \InsetSpace ~
29922 \InsetSpace ~
29923 \InsetSpace ~
29924 \InsetSpace ~
29925 SDCDB step command 
29926 \newline
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 \InsetSpace ~
29940 \InsetSpace ~
29941 \InsetSpace ~
29942 \InsetSpace ~
29943 sdcdb-w
29944 hatis-c-sexp\InsetSpace ~
29945 \InsetSpace ~
29946 \InsetSpace ~
29947 \InsetSpace ~
29948 \InsetSpace ~
29949 \InsetSpace ~
29950 \InsetSpace ~
29951 \InsetSpace ~
29952 \InsetSpace ~
29953 \InsetSpace ~
29954 SDCDB ptypecommand for data at 
29955 \newline
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 \InsetSpace ~
30000 \InsetSpace ~
30001 \InsetSpace ~
30002 \InsetSpace ~
30003 buffer point 
30004 \newline
30005 ;;\InsetSpace ~
30006 x\InsetSpace ~
30007 \InsetSpace ~
30008 \InsetSpace ~
30009 \InsetSpace ~
30010 \InsetSpace ~
30011 \InsetSpace ~
30012 \InsetSpace ~
30013 \InsetSpace ~
30014 \InsetSpace ~
30015 \InsetSpace ~
30016 \InsetSpace ~
30017 \InsetSpace ~
30018 \InsetSpace ~
30019 \InsetSpace ~
30020 \InsetSpace ~
30021 sdcdbsrc-delete\InsetSpace ~
30022 \InsetSpace ~
30023 \InsetSpace ~
30024 \InsetSpace ~
30025 \InsetSpace ~
30026 \InsetSpace ~
30027 \InsetSpace ~
30028 \InsetSpace ~
30029 \InsetSpace ~
30030 \InsetSpace ~
30031 \InsetSpace ~
30032 \InsetSpace ~
30033 \InsetSpace ~
30034 \InsetSpace ~
30035 SDCD
30036 B Delete all breakpoints if no arg 
30037 \newline
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 \InsetSpace ~
30082 \InsetSpace ~
30083 \InsetSpace ~
30084 \InsetSpace ~
30085 given or delete arg (C-u arg x) 
30086 \newline
30087 ;;\InsetSpace ~
30088 m\InsetSpace ~
30089 \InsetSpace ~
30090 \InsetSpace ~
30091 \InsetSpace ~
30092 \InsetSpace ~
30093 \InsetSpace ~
30094 \InsetSpace ~
30095 \InsetSpace ~
30096 \InsetSpace ~
30097 \InsetSpace ~
30098 \InsetSpace ~
30099 \InsetSpace ~
30100 \InsetSpace ~
30101 \InsetSpace ~
30102 \InsetSpace ~
30103 sdcdbsrc
30104 -frame\InsetSpace ~
30105 \InsetSpace ~
30106 \InsetSpace ~
30107 \InsetSpace ~
30108 \InsetSpace ~
30109 \InsetSpace ~
30110 \InsetSpace ~
30111 \InsetSpace ~
30112 \InsetSpace ~
30113 \InsetSpace ~
30114 \InsetSpace ~
30115 \InsetSpace ~
30116 \InsetSpace ~
30117 \InsetSpace ~
30118 \InsetSpace ~
30119 SDCDB Display current frame if no arg, 
30120 \newline
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 \InsetSpace ~
30165 \InsetSpace ~
30166 \InsetSpace ~
30167 \InsetSpace ~
30168 given or display frame arg
30169  
30170 \newline
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 \InsetSpace ~
30215 \InsetSpace ~
30216 \InsetSpace ~
30217 \InsetSpace ~
30218 buffer point 
30219 \newline
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 \InsetSpace ~
30233 \InsetSpace ~
30234 \InsetSpace ~
30235 \InsetSpace ~
30236 sdcdbsrc-goto-sdcdb\InsetSpace ~
30237 \InsetSpace ~
30238 \InsetSpace ~
30239 \InsetSpace ~
30240 \InsetSpace ~
30241 \InsetSpace ~
30242 \InsetSpace ~
30243 \InsetSpace ~
30244 \InsetSpace ~
30245 \InsetSpace ~
30246 Goto the SDCDB output buffer 
30247 \newline
30248 ;;\InsetSpace ~
30249 p\InsetSpace ~
30250 \InsetSpace ~
30251 \InsetSpace ~
30252 \InsetSpace ~
30253 \InsetSpace ~
30254 \InsetSpace ~
30255 \InsetSpace ~
30256 \InsetSpace ~
30257 \InsetSpace ~
30258 \InsetSpace ~
30259 \InsetSpace ~
30260 \InsetSpace ~
30261 \InsetSpace ~
30262 \InsetSpace ~
30263 \InsetSpace ~
30264 sdcdb-prin
30265 t-c-sexp\InsetSpace ~
30266 \InsetSpace ~
30267 \InsetSpace ~
30268 \InsetSpace ~
30269 \InsetSpace ~
30270 \InsetSpace ~
30271 \InsetSpace ~
30272 \InsetSpace ~
30273 \InsetSpace ~
30274 \InsetSpace ~
30275 \InsetSpace ~
30276 SDCDB print command for data at 
30277 \newline
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 \InsetSpace ~
30322 \InsetSpace ~
30323 \InsetSpace ~
30324 \InsetSpace ~
30325 buffer point 
30326 \newline
30327 ;;\InsetSpace ~
30328 g\InsetSpace ~
30329 \InsetSpace ~
30330 \InsetSpace ~
30331 \InsetSpace ~
30332 \InsetSpace ~
30333 \InsetSpace ~
30334 \InsetSpace ~
30335 \InsetSpace ~
30336 \InsetSpace ~
30337 \InsetSpace ~
30338 \InsetSpace ~
30339 \InsetSpace ~
30340 \InsetSpace ~
30341 \InsetSpace ~
30342 \InsetSpace ~
30343 sdcdbsrc-goto-sdcdb\InsetSpace ~
30344 \InsetSpace ~
30345 \InsetSpace ~
30346 \InsetSpace ~
30347 \InsetSpace ~
30348 \InsetSpace ~
30349 \InsetSpace ~
30350 \InsetSpace ~
30351 \InsetSpace ~
30352 \InsetSpace ~
30353 Got
30354 o the SDCDB output buffer 
30355 \newline
30356 ;;\InsetSpace ~
30357 t\InsetSpace ~
30358 \InsetSpace ~
30359 \InsetSpace ~
30360 \InsetSpace ~
30361 \InsetSpace ~
30362 \InsetSpace ~
30363 \InsetSpace ~
30364 \InsetSpace ~
30365 \InsetSpace ~
30366 \InsetSpace ~
30367 \InsetSpace ~
30368 \InsetSpace ~
30369 \InsetSpace ~
30370 \InsetSpace ~
30371 \InsetSpace ~
30372 sdcdbsrc-mode\InsetSpace ~
30373 \InsetSpace ~
30374 \InsetSpace ~
30375 \InsetSpace ~
30376 \InsetSpace ~
30377 \InsetSpace ~
30378 \InsetSpace ~
30379 \InsetSpace ~
30380 \InsetSpace ~
30381 \InsetSpace ~
30382 \InsetSpace ~
30383 \InsetSpace ~
30384 \InsetSpace ~
30385 \InsetSpace ~
30386 \InsetSpace ~
30387 \InsetSpace ~
30388 Toggles Sdcdbsrc mode (turns it
30389  off) 
30390 \newline
30391 ;; 
30392 \newline
30393 ;;\InsetSpace ~
30394 C-c\InsetSpace ~
30395 C-f\InsetSpace ~
30396 \InsetSpace ~
30397 \InsetSpace ~
30398 \InsetSpace ~
30399 \InsetSpace ~
30400 \InsetSpace ~
30401 \InsetSpace ~
30402 \InsetSpace ~
30403 \InsetSpace ~
30404 sdcdb-finish-from-src\InsetSpace ~
30405 \InsetSpace ~
30406 \InsetSpace ~
30407 \InsetSpace ~
30408 \InsetSpace ~
30409 \InsetSpace ~
30410 \InsetSpace ~
30411 \InsetSpace ~
30412 SDCDB finish command 
30413 \newline
30414 ;; 
30415 \newline
30416 ;;\InsetSpace ~
30417 C-x\InsetSpace ~
30418 SPC\InsetSpace ~
30419 \InsetSpace ~
30420 \InsetSpace ~
30421 \InsetSpace ~
30422 \InsetSpace ~
30423 \InsetSpace ~
30424 \InsetSpace ~
30425 \InsetSpace ~
30426 \InsetSpace ~
30427 sdcdb-brea
30428 k\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 \InsetSpace ~
30443 \InsetSpace ~
30444 \InsetSpace ~
30445 \InsetSpace ~
30446 Set break for line with point 
30447 \newline
30448 ;;\InsetSpace ~
30449 ESC\InsetSpace ~
30450 t\InsetSpace ~
30451 \InsetSpace ~
30452 \InsetSpace ~
30453 \InsetSpace ~
30454 \InsetSpace ~
30455 \InsetSpace ~
30456 \InsetSpace ~
30457 \InsetSpace ~
30458 \InsetSpace ~
30459 \InsetSpace ~
30460 \InsetSpace ~
30461 sdcdbsrc-mode\InsetSpace ~
30462 \InsetSpace ~
30463 \InsetSpace ~
30464 \InsetSpace ~
30465 \InsetSpace ~
30466 \InsetSpace ~
30467 \InsetSpace ~
30468 \InsetSpace ~
30469 \InsetSpace ~
30470 \InsetSpace ~
30471 \InsetSpace ~
30472 \InsetSpace ~
30473 \InsetSpace ~
30474 \InsetSpace ~
30475 \InsetSpace ~
30476 \InsetSpace ~
30477 Toggle Sdcdbsrc mode 
30478 \newline
30479 ;;\InsetSpace ~
30480 ESC\InsetSpace ~
30481 m\InsetSpace ~
30482 \InsetSpace ~
30483 \InsetSpace ~
30484 \InsetSpace ~
30485 \InsetSpace ~
30486 \InsetSpace ~
30487 \InsetSpace ~
30488 \InsetSpace ~
30489 \InsetSpace ~
30490 \InsetSpace ~
30491 \InsetSpace ~
30492 sdc
30493 dbsrc-srcmode\InsetSpace ~
30494 \InsetSpace ~
30495 \InsetSpace ~
30496 \InsetSpace ~
30497 \InsetSpace ~
30498 \InsetSpace ~
30499 \InsetSpace ~
30500 \InsetSpace ~
30501 \InsetSpace ~
30502 \InsetSpace ~
30503 \InsetSpace ~
30504 \InsetSpace ~
30505 \InsetSpace ~
30506 Toggle list mode 
30507 \newline
30508 ;; 
30509 \newline
30510
30511 \family default
30512
30513 \newpage
30514
30515 \end_layout
30516
30517 \begin_layout Chapter
30518 TIPS
30519 \end_layout
30520
30521 \begin_layout Standard
30522 Here are a few guidelines that will help the compiler generate more efficient
30523  code, some of the tips are specific to this compiler others are generally
30524  good programming practice.
30525 \end_layout
30526
30527 \begin_layout Itemize
30528 Use the smallest data type to represent your data-value.
30529  If it is known in advance that the value is going to be less than 256 then
30530  use an 'unsigned char' instead of a 'short' or 'int'.
30531  Please note, that ANSI C requires both signed and unsigned chars to be
30532  promoted to 'signed int'
30533 \begin_inset LatexCommand \index{promotion to signed int}
30534
30535 \end_inset
30536
30537
30538 \begin_inset Marginal
30539 status collapsed
30540
30541 \begin_layout Standard
30542
30543 \series bold
30544 \InsetSpace ~
30545 !
30546 \end_layout
30547
30548 \end_inset
30549
30550  before doing any operation.
30551  This promotion
30552 \begin_inset LatexCommand \index{type promotion}
30553
30554 \end_inset
30555
30556
30557 \begin_inset LatexCommand \label{type promotion}
30558
30559 \end_inset
30560
30561  can be omitted, if the result is the same.
30562  The effect of the promotion rules together with the sign-extension is often
30563  surprising:
30564 \end_layout
30565
30566 \begin_deeper
30567 \begin_layout Verse
30568
30569 \family typewriter
30570 unsigned char uc = 0xfe;
30571 \newline
30572 if (uc * uc < 0) /* this is true! */
30573 \newline
30574 {
30575 \newline
30576 \InsetSpace ~
30577 \InsetSpace ~
30578 \InsetSpace ~
30579 \InsetSpace ~
30580 ....
30581 \newline
30582 }
30583 \end_layout
30584
30585 \begin_layout Standard
30586
30587 \family typewriter
30588 uc * uc
30589 \family default
30590  is evaluated as 
30591 \family typewriter
30592 (int) uc * (int) uc = (int) 0xfe * (int) 0xfe = (int) 0xfc04 = -1024
30593 \family default
30594 .
30595  
30596 \newline
30597 Another one:
30598 \end_layout
30599
30600 \begin_layout Verse
30601
30602 \family typewriter
30603 (unsigned char) -12 / (signed char) -3 = ...
30604 \end_layout
30605
30606 \begin_layout Standard
30607 No, the result is not 4:
30608 \end_layout
30609
30610 \begin_layout Verse
30611
30612 \family typewriter
30613 (int) (unsigned char) -12 / (int) (signed char) -3 =
30614 \newline
30615 (int) (unsigned char)
30616  0xf4 / (int) (signed char) 0xfd =
30617 \newline
30618 (int) 0x00f4 / (int) 0xfffd =
30619 \newline
30620 (int) 0x00f4
30621  / (int) 0xfffd =
30622 \newline
30623 (int) 244 / (int) -3 =
30624 \newline
30625 (int) -81 = (int) 0xffaf;
30626 \end_layout
30627
30628 \begin_layout Standard
30629 Don't complain, that gcc gives you a different result.
30630  gcc uses 32 bit ints, while SDCC uses 16 bit ints.
30631  Therefore the results are different.
30632 \newline
30633 From 
30634 \begin_inset Quotes sld
30635 \end_inset
30636
30637 comp.lang.c FAQ
30638 \begin_inset Quotes srd
30639 \end_inset
30640
30641 :
30642 \end_layout
30643
30644 \begin_layout Quote
30645
30646 \emph on
30647 If well-defined overflow characteristics are important and negative values
30648  are not, or if you want to steer clear of sign-extension problems when
30649  manipulating bits or bytes, use one of the corresponding unsigned types.
30650  (Beware when mixing signed and unsigned values in expressions, though.)
30651 \newline
30652 Although
30653  character types (especially unsigned char) can be used as "tiny" integers,
30654  doing so is sometimes more trouble than it's worth, due to unpredictable
30655  sign extension and increased code size.
30656 \end_layout
30657
30658 \end_deeper
30659 \begin_layout Itemize
30660 Use unsigned when it is known in advance that the value is not going to
30661  be negative.
30662  This helps especially if you are doing division or multiplication, bit-shifting
30663  or are using an array index.
30664 \end_layout
30665
30666 \begin_layout Itemize
30667 NEVER jump into a LOOP.
30668 \end_layout
30669
30670 \begin_layout Itemize
30671 Declare the variables to be local
30672 \begin_inset LatexCommand \index{local variables}
30673
30674 \end_inset
30675
30676  whenever possible, especially loop control variables (induction).
30677 \end_layout
30678
30679 \begin_layout Itemize
30680 Have a look at the assembly listing to get a 
30681 \begin_inset Quotes sld
30682 \end_inset
30683
30684 feeling
30685 \begin_inset Quotes srd
30686 \end_inset
30687
30688  for the code generation.
30689 \end_layout
30690
30691 \begin_layout Section
30692 Porting code from or to other compilers
30693 \begin_inset LatexCommand \label{sec:Porting-code-to-other-compilers}
30694
30695 \end_inset
30696
30697
30698 \end_layout
30699
30700 \begin_layout Itemize
30701 check whether endianness of the compilers differs and adapt where needed.
30702 \end_layout
30703
30704 \begin_layout Itemize
30705 check the device specific header files
30706 \begin_inset LatexCommand \index{Header files}
30707
30708 \end_inset
30709
30710
30711 \begin_inset LatexCommand \index{Include files}
30712
30713 \end_inset
30714
30715  for compiler specific syntax.
30716  Eventually include the file <compiler.h
30717 \begin_inset LatexCommand \index{compiler.h (include file)}
30718
30719 \end_inset
30720
30721
30722 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/compiler.h?view=markup}
30723
30724 \end_inset
30725
30726  to allow using common header files.
30727  (see f.e.
30728  cc2510fx.h 
30729 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/cc2510fx.h?view=markup}
30730
30731 \end_inset
30732
30733 ).
30734 \end_layout
30735
30736 \begin_layout Itemize
30737 check whether the startup code contains the correct initialization (watchdog,
30738  peripherals).
30739 \end_layout
30740
30741 \begin_layout Itemize
30742 check whether the sizes of short, int, long match.
30743 \end_layout
30744
30745 \begin_layout Itemize
30746 check if some 16 or 32 bit hardware registers require a specific addressing
30747  order (least significant or most significant byte first) and adapt if needed
30748  (
30749 \emph on
30750 first
30751 \emph default
30752  and 
30753 \emph on
30754 last
30755 \emph default
30756  relate to time and not to lower/upper memory location here, so this is
30757  
30758 \emph on
30759 not
30760 \emph default
30761  the same as endianness).
30762 \end_layout
30763
30764 \begin_layout Itemize
30765 check whether the keyword 
30766 \emph on
30767 volatile
30768 \emph default
30769  is used where needed.
30770  The compilers might differ in their optimization characteristics (as different
30771  versions of the same compiler might also use more clever optimizations
30772  this is good idea anyway).
30773  See section 
30774 \begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
30775
30776 \end_inset
30777
30778 .
30779 \end_layout
30780
30781 \begin_layout Itemize
30782 check that the compilers are not told to supress warnings.
30783 \end_layout
30784
30785 \begin_layout Itemize
30786 check and convert compiler specific extensions (interrupts, memory areas,
30787  pragmas etc.).
30788 \end_layout
30789
30790 \begin_layout Itemize
30791 check for differences in type promotion.
30792  Especially check for math operations on 
30793 \family typewriter
30794 char
30795 \family default
30796  or 
30797 \family typewriter
30798 unsigned char
30799 \family default
30800  variables.
30801  For the sake of C99 compatibility SDCC will probably promote these to 
30802 \family typewriter
30803 int
30804 \family default
30805  more often than other compilers.
30806  Eventually insert explicit casts to 
30807 \family typewriter
30808 (char) 
30809 \family default
30810 or
30811 \family typewriter
30812  (unsigned char)
30813 \family default
30814 .
30815  Also check that the ~\InsetSpace ~
30816 operator
30817 \begin_inset LatexCommand \index{\~\/ Operator}
30818
30819 \end_inset
30820
30821  is not used on 
30822 \family typewriter
30823 bit
30824 \begin_inset LatexCommand \index{bit}
30825
30826 \end_inset
30827
30828
30829 \family default
30830  variables, use the !\InsetSpace ~
30831 operator instead.
30832  See sections 
30833 \begin_inset LatexCommand \ref{type promotion}
30834
30835 \end_inset
30836
30837  and 
30838 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
30839
30840 \end_inset
30841
30842 .
30843 \end_layout
30844
30845 \begin_layout Itemize
30846 check the assembly code generated for interrupt routines (f.e.
30847  for calls to possibly non-reentrant library functions).
30848 \end_layout
30849
30850 \begin_layout Itemize
30851 check whether timing loops result in proper timing (or preferably consider
30852  a rewrite of the code with timer based delays instead).
30853 \end_layout
30854
30855 \begin_layout Itemize
30856 check for differences in printf parameters (some compilers push (va_arg
30857 \begin_inset LatexCommand \index{vararg, va\_arg}
30858
30859 \end_inset
30860
30861 ) char variables as 
30862 \family typewriter
30863 int
30864 \family default
30865  others push them as 
30866 \family typewriter
30867 char
30868 \family default
30869 .
30870  See section 
30871 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
30872
30873 \end_inset
30874
30875 ).
30876 \end_layout
30877
30878 \begin_layout Itemize
30879 check the resulting memory map
30880 \begin_inset LatexCommand \index{Memory map}
30881
30882 \end_inset
30883
30884 .
30885  Usage of different memory spaces: code, stack, data (for mcs51/ds390 additional
30886 ly idata, pdata, xdata).
30887  Eventually check if unexpected library functions are included.
30888 \end_layout
30889
30890 \begin_layout Section
30891 Tools
30892 \begin_inset LatexCommand \index{Tools}
30893
30894 \end_inset
30895
30896  included in the distribution
30897 \end_layout
30898
30899 \begin_layout Standard
30900 \align left
30901 \begin_inset Tabular
30902 <lyxtabular version="3" rows="12" columns="3">
30903 <features>
30904 <column alignment="left" valignment="top" leftline="true" width="0pt">
30905 <column alignment="left" valignment="top" leftline="true" width="0pt">
30906 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
30907 <row topline="true" bottomline="true">
30908 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30909 \begin_inset Text
30910
30911 \begin_layout Standard
30912
30913 \series bold
30914 Name
30915 \end_layout
30916
30917 \end_inset
30918 </cell>
30919 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30920 \begin_inset Text
30921
30922 \begin_layout Standard
30923
30924 \series bold
30925 Purpose
30926 \end_layout
30927
30928 \end_inset
30929 </cell>
30930 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30931 \begin_inset Text
30932
30933 \begin_layout Standard
30934
30935 \series bold
30936 Directory
30937 \end_layout
30938
30939 \end_inset
30940 </cell>
30941 </row>
30942 <row topline="true">
30943 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30944 \begin_inset Text
30945
30946 \begin_layout Standard
30947 uCsim
30948 \begin_inset LatexCommand \index{uCsim}
30949
30950 \end_inset
30951
30952
30953 \end_layout
30954
30955 \end_inset
30956 </cell>
30957 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30958 \begin_inset Text
30959
30960 \begin_layout Standard
30961 Simulator for various architectures
30962 \end_layout
30963
30964 \end_inset
30965 </cell>
30966 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30967 \begin_inset Text
30968
30969 \begin_layout Standard
30970 sdcc/sim/ucsim
30971 \end_layout
30972
30973 \end_inset
30974 </cell>
30975 </row>
30976 <row topline="true">
30977 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30978 \begin_inset Text
30979
30980 \begin_layout Standard
30981 keil2sdcc.pl
30982 \end_layout
30983
30984 \end_inset
30985 </cell>
30986 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30987 \begin_inset Text
30988
30989 \begin_layout Standard
30990 header file
30991 \begin_inset LatexCommand \index{Header files}
30992
30993 \end_inset
30994
30995
30996 \begin_inset LatexCommand \index{Include files}
30997
30998 \end_inset
30999
31000  conversion
31001 \end_layout
31002
31003 \end_inset
31004 </cell>
31005 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31006 \begin_inset Text
31007
31008 \begin_layout Standard
31009 sdcc/support/scripts
31010 \end_layout
31011
31012 \end_inset
31013 </cell>
31014 </row>
31015 <row topline="true">
31016 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31017 \begin_inset Text
31018
31019 \begin_layout Standard
31020 mh2h.c
31021 \end_layout
31022
31023 \end_inset
31024 </cell>
31025 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31026 \begin_inset Text
31027
31028 \begin_layout Standard
31029 header file conversion
31030 \end_layout
31031
31032 \end_inset
31033 </cell>
31034 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31035 \begin_inset Text
31036
31037 \begin_layout Standard
31038 sdcc/support/scripts
31039 \end_layout
31040
31041 \end_inset
31042 </cell>
31043 </row>
31044 <row topline="true">
31045 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31046 \begin_inset Text
31047
31048 \begin_layout Standard
31049 as-gbz80
31050 \end_layout
31051
31052 \end_inset
31053 </cell>
31054 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31055 \begin_inset Text
31056
31057 \begin_layout Standard
31058 Assembler
31059 \end_layout
31060
31061 \end_inset
31062 </cell>
31063 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31064 \begin_inset Text
31065
31066 \begin_layout Standard
31067
31068 \family roman
31069 \series medium
31070 \shape up
31071 \size normal
31072 \emph off
31073 \bar no
31074 \noun off
31075 \color none
31076 sdcc/bin
31077 \end_layout
31078
31079 \end_inset
31080 </cell>
31081 </row>
31082 <row topline="true">
31083 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31084 \begin_inset Text
31085
31086 \begin_layout Standard
31087 as-z80
31088 \end_layout
31089
31090 \end_inset
31091 </cell>
31092 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31093 \begin_inset Text
31094
31095 \begin_layout Standard
31096 Assembler
31097 \end_layout
31098
31099 \end_inset
31100 </cell>
31101 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31102 \begin_inset Text
31103
31104 \begin_layout Standard
31105
31106 \family roman
31107 \series medium
31108 \shape up
31109 \size normal
31110 \emph off
31111 \bar no
31112 \noun off
31113 \color none
31114 sdcc/bin
31115 \end_layout
31116
31117 \end_inset
31118 </cell>
31119 </row>
31120 <row topline="true">
31121 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31122 \begin_inset Text
31123
31124 \begin_layout Standard
31125 asx8051
31126 \end_layout
31127
31128 \end_inset
31129 </cell>
31130 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31131 \begin_inset Text
31132
31133 \begin_layout Standard
31134 Assembler
31135 \end_layout
31136
31137 \end_inset
31138 </cell>
31139 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31140 \begin_inset Text
31141
31142 \begin_layout Standard
31143
31144 \family roman
31145 \series medium
31146 \shape up
31147 \size normal
31148 \emph off
31149 \bar no
31150 \noun off
31151 \color none
31152 sdcc/bin
31153 \end_layout
31154
31155 \end_inset
31156 </cell>
31157 </row>
31158 <row topline="true">
31159 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31160 \begin_inset Text
31161
31162 \begin_layout Standard
31163 SDCDB
31164 \end_layout
31165
31166 \end_inset
31167 </cell>
31168 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31169 \begin_inset Text
31170
31171 \begin_layout Standard
31172 Simulator
31173 \end_layout
31174
31175 \end_inset
31176 </cell>
31177 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31178 \begin_inset Text
31179
31180 \begin_layout Standard
31181
31182 \family roman
31183 \series medium
31184 \shape up
31185 \size normal
31186 \emph off
31187 \bar no
31188 \noun off
31189 \color none
31190 sdcc/bin
31191 \end_layout
31192
31193 \end_inset
31194 </cell>
31195 </row>
31196 <row topline="true">
31197 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31198 \begin_inset Text
31199
31200 \begin_layout Standard
31201 aslink
31202 \end_layout
31203
31204 \end_inset
31205 </cell>
31206 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31207 \begin_inset Text
31208
31209 \begin_layout Standard
31210 Linker
31211 \end_layout
31212
31213 \end_inset
31214 </cell>
31215 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31216 \begin_inset Text
31217
31218 \begin_layout Standard
31219
31220 \family roman
31221 \series medium
31222 \shape up
31223 \size normal
31224 \emph off
31225 \bar no
31226 \noun off
31227 \color none
31228 sdcc/bin
31229 \end_layout
31230
31231 \end_inset
31232 </cell>
31233 </row>
31234 <row topline="true">
31235 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31236 \begin_inset Text
31237
31238 \begin_layout Standard
31239 link-z80
31240 \end_layout
31241
31242 \end_inset
31243 </cell>
31244 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31245 \begin_inset Text
31246
31247 \begin_layout Standard
31248 Linker
31249 \end_layout
31250
31251 \end_inset
31252 </cell>
31253 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31254 \begin_inset Text
31255
31256 \begin_layout Standard
31257
31258 \family roman
31259 \series medium
31260 \shape up
31261 \size normal
31262 \emph off
31263 \bar no
31264 \noun off
31265 \color none
31266 sdcc/bin
31267 \end_layout
31268
31269 \end_inset
31270 </cell>
31271 </row>
31272 <row topline="true">
31273 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31274 \begin_inset Text
31275
31276 \begin_layout Standard
31277 link-gbz80
31278 \end_layout
31279
31280 \end_inset
31281 </cell>
31282 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31283 \begin_inset Text
31284
31285 \begin_layout Standard
31286 Linker
31287 \end_layout
31288
31289 \end_inset
31290 </cell>
31291 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31292 \begin_inset Text
31293
31294 \begin_layout Standard
31295
31296 \family roman
31297 \series medium
31298 \shape up
31299 \size normal
31300 \emph off
31301 \bar no
31302 \noun off
31303 \color none
31304 sdcc/bin
31305 \end_layout
31306
31307 \end_inset
31308 </cell>
31309 </row>
31310 <row topline="true" bottomline="true">
31311 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31312 \begin_inset Text
31313
31314 \begin_layout Standard
31315 packihx
31316 \end_layout
31317
31318 \end_inset
31319 </cell>
31320 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31321 \begin_inset Text
31322
31323 \begin_layout Standard
31324 Intel Hex packer 
31325 \begin_inset LatexCommand \index{packihx (tool)}
31326
31327 \end_inset
31328
31329
31330 \end_layout
31331
31332 \end_inset
31333 </cell>
31334 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31335 \begin_inset Text
31336
31337 \begin_layout Standard
31338
31339 \family roman
31340 \series medium
31341 \shape up
31342 \size normal
31343 \emph off
31344 \bar no
31345 \noun off
31346 \color none
31347 sdcc/bin
31348 \end_layout
31349
31350 \end_inset
31351 </cell>
31352 </row>
31353 </lyxtabular>
31354
31355 \end_inset
31356
31357
31358 \newline
31359
31360 \end_layout
31361
31362 \begin_layout Section
31363 Documentation
31364 \begin_inset LatexCommand \index{Documentation}
31365
31366 \end_inset
31367
31368  included in the distribution
31369 \end_layout
31370
31371 \begin_layout Standard
31372 \align left
31373 \begin_inset Tabular
31374 <lyxtabular version="3" rows="10" columns="2">
31375 <features>
31376 <column alignment="block" valignment="top" leftline="true" width="40col%">
31377 <column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
31378 <row topline="true" bottomline="true" endhead="true">
31379 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31380 \begin_inset Text
31381
31382 \begin_layout Standard
31383
31384 \series bold
31385 Subject / Title
31386 \end_layout
31387
31388 \end_inset
31389 </cell>
31390 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31391 \begin_inset Text
31392
31393 \begin_layout Standard
31394
31395 \series bold
31396 Filename / Where to get
31397 \end_layout
31398
31399 \end_inset
31400 </cell>
31401 </row>
31402 <row topline="true">
31403 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31404 \begin_inset Text
31405
31406 \begin_layout Standard
31407 SDCC Compiler User Guide
31408 \end_layout
31409
31410 \end_inset
31411 </cell>
31412 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31413 \begin_inset Text
31414
31415 \begin_layout Standard
31416 You're reading it right now
31417 \emph on
31418  \InsetSpace ~
31419 \InsetSpace ~
31420 \InsetSpace ~
31421
31422 \hfill
31423 online at:
31424 \emph default
31425
31426 \newline
31427
31428 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
31429
31430 \end_inset
31431
31432
31433 \end_layout
31434
31435 \end_inset
31436 </cell>
31437 </row>
31438 <row topline="true">
31439 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31440 \begin_inset Text
31441
31442 \begin_layout Standard
31443 Changelog of SDCC
31444 \end_layout
31445
31446 \end_inset
31447 </cell>
31448 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31449 \begin_inset Text
31450
31451 \begin_layout Standard
31452 sdcc/Changelog
31453 \emph on
31454  \InsetSpace ~
31455 \InsetSpace ~
31456 \InsetSpace ~
31457
31458 \hfill
31459 online at:
31460 \emph default
31461
31462 \newline
31463
31464 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog}
31465
31466 \end_inset
31467
31468
31469 \end_layout
31470
31471 \end_inset
31472 </cell>
31473 </row>
31474 <row topline="true">
31475 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31476 \begin_inset Text
31477
31478 \begin_layout Standard
31479 ASXXXX
31480 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
31481
31482 \end_inset
31483
31484
31485 \begin_inset LatexCommand \index{Assembler documentation}
31486
31487 \end_inset
31488
31489  Assemblers and
31490 \newline
31491 ASLINK
31492 \begin_inset LatexCommand \index{aslink}
31493
31494 \end_inset
31495
31496
31497 \begin_inset LatexCommand \index{Linker documentation}
31498
31499 \end_inset
31500
31501  Relocating Linker
31502 \end_layout
31503
31504 \end_inset
31505 </cell>
31506 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31507 \begin_inset Text
31508
31509 \begin_layout Standard
31510 sdcc/as/doc/asxhtm.html 
31511 \emph on
31512 \InsetSpace ~
31513 \InsetSpace ~
31514 \InsetSpace ~
31515
31516 \hfill
31517 online at:
31518 \emph default
31519
31520 \newline
31521
31522 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
31523
31524 \end_inset
31525
31526
31527 \end_layout
31528
31529 \end_inset
31530 </cell>
31531 </row>
31532 <row topline="true">
31533 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31534 \begin_inset Text
31535
31536 \begin_layout Standard
31537 SDCC regression test
31538 \begin_inset LatexCommand \index{Regression test}
31539
31540 \end_inset
31541
31542
31543 \end_layout
31544
31545 \end_inset
31546 </cell>
31547 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31548 \begin_inset Text
31549
31550 \begin_layout Standard
31551 sdcc/doc/test_suite_spec.pdf 
31552 \emph on
31553 \InsetSpace ~
31554 \InsetSpace ~
31555 \InsetSpace ~
31556
31557 \hfill
31558 online at:
31559 \emph default
31560
31561 \newline
31562
31563 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
31564
31565 \end_inset
31566
31567
31568 \end_layout
31569
31570 \end_inset
31571 </cell>
31572 </row>
31573 <row topline="true">
31574 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31575 \begin_inset Text
31576
31577 \begin_layout Standard
31578 Various notes
31579 \end_layout
31580
31581 \end_inset
31582 </cell>
31583 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31584 \begin_inset Text
31585
31586 \begin_layout Standard
31587 sdcc/doc/* 
31588 \emph on
31589 \InsetSpace ~
31590 \InsetSpace ~
31591 \InsetSpace ~
31592
31593 \hfill
31594 online at:
31595 \emph default
31596
31597 \newline
31598
31599 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/doc/}
31600
31601 \end_inset
31602
31603
31604 \end_layout
31605
31606 \end_inset
31607 </cell>
31608 </row>
31609 <row topline="true">
31610 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31611 \begin_inset Text
31612
31613 \begin_layout Standard
31614 Notes on debugging with SDCDB
31615 \begin_inset LatexCommand \index{SDCDB (debugger)}
31616
31617 \end_inset
31618
31619
31620 \end_layout
31621
31622 \end_inset
31623 </cell>
31624 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31625 \begin_inset Text
31626
31627 \begin_layout Standard
31628 sdcc/debugger/README 
31629 \emph on
31630 \InsetSpace ~
31631 \InsetSpace ~
31632 \InsetSpace ~
31633
31634 \hfill
31635 online at
31636 \emph default
31637 :
31638 \newline
31639
31640 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README}
31641
31642 \end_inset
31643
31644
31645 \end_layout
31646
31647 \end_inset
31648 </cell>
31649 </row>
31650 <row topline="true">
31651 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31652 \begin_inset Text
31653
31654 \begin_layout Standard
31655 uCsim
31656 \begin_inset LatexCommand \index{uCsim}
31657
31658 \end_inset
31659
31660  Software simulator for microcontrollers
31661 \end_layout
31662
31663 \end_inset
31664 </cell>
31665 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31666 \begin_inset Text
31667
31668 \begin_layout Standard
31669
31670 \family roman
31671 \series medium
31672 \shape up
31673 \size normal
31674 \emph off
31675 \bar no
31676 \noun off
31677 \color none
31678 sdcc/sim/ucsim/doc
31679 \family default
31680 \series default
31681 \shape default
31682 \size default
31683 \emph default
31684 \bar default
31685 \noun default
31686 /index.html 
31687 \emph on
31688 \InsetSpace ~
31689 \InsetSpace ~
31690 \InsetSpace ~
31691
31692 \hfill
31693 online at:
31694 \emph default
31695
31696 \newline
31697
31698 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html}
31699
31700 \end_inset
31701
31702
31703 \end_layout
31704
31705 \end_inset
31706 </cell>
31707 </row>
31708 <row topline="true">
31709 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31710 \begin_inset Text
31711
31712 \begin_layout Standard
31713 Temporary notes on the pic16
31714 \begin_inset LatexCommand \index{PIC16}
31715
31716 \end_inset
31717
31718  port
31719 \end_layout
31720
31721 \end_inset
31722 </cell>
31723 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31724 \begin_inset Text
31725
31726 \begin_layout Standard
31727 sdcc/src/pic16/NOTES 
31728 \emph on
31729 \InsetSpace ~
31730 \InsetSpace ~
31731 \InsetSpace ~
31732
31733 \hfill
31734 online at:
31735 \newline
31736
31737 \emph default
31738
31739 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES}
31740
31741 \end_inset
31742
31743
31744 \end_layout
31745
31746 \end_inset
31747 </cell>
31748 </row>
31749 <row topline="true" bottomline="true">
31750 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31751 \begin_inset Text
31752
31753 \begin_layout Standard
31754 SDCC internal documentation (debugging file format)
31755 \end_layout
31756
31757 \end_inset
31758 </cell>
31759 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31760 \begin_inset Text
31761
31762 \begin_layout Standard
31763 sdcc/doc/
31764 \family roman
31765 \series medium
31766 \shape up
31767 \size normal
31768 \emph off
31769 \bar no
31770 \noun off
31771 \color none
31772 cdbfileformat.pd
31773 \family default
31774 \series default
31775 \shape default
31776 \size default
31777 \emph default
31778 \bar default
31779 \noun default
31780 f
31781 \emph on
31782  \InsetSpace ~
31783 \InsetSpace ~
31784 \InsetSpace ~
31785
31786 \hfill
31787 online at:
31788 \emph default
31789
31790 \newline
31791
31792 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/cdbfileformat.pdf}
31793
31794 \end_inset
31795
31796
31797 \end_layout
31798
31799 \end_inset
31800 </cell>
31801 </row>
31802 </lyxtabular>
31803
31804 \end_inset
31805
31806
31807 \newline
31808
31809 \end_layout
31810
31811 \begin_layout Section
31812 Related open source tools
31813 \begin_inset LatexCommand \label{sec:Related-open-source-tools}
31814
31815 \end_inset
31816
31817
31818 \begin_inset LatexCommand \index{Related tools}
31819
31820 \end_inset
31821
31822
31823 \end_layout
31824
31825 \begin_layout Standard
31826 \align left
31827 \begin_inset Tabular
31828 <lyxtabular version="3" rows="16" columns="3">
31829 <features>
31830 <column alignment="left" valignment="top" leftline="true" width="0pt">
31831 <column alignment="block" valignment="top" leftline="true" width="30line%">
31832 <column alignment="left" valignment="top" leftline="true" rightline="true" width="40col%">
31833 <row topline="true" bottomline="true">
31834 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31835 \begin_inset Text
31836
31837 \begin_layout Standard
31838
31839 \series bold
31840 Name
31841 \end_layout
31842
31843 \end_inset
31844 </cell>
31845 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31846 \begin_inset Text
31847
31848 \begin_layout Standard
31849
31850 \series bold
31851 Purpose
31852 \end_layout
31853
31854 \end_inset
31855 </cell>
31856 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31857 \begin_inset Text
31858
31859 \begin_layout Standard
31860
31861 \series bold
31862 Where to get
31863 \end_layout
31864
31865 \end_inset
31866 </cell>
31867 </row>
31868 <row topline="true">
31869 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31870 \begin_inset Text
31871
31872 \begin_layout Standard
31873 gpsim
31874 \begin_inset LatexCommand \index{gpsim (pic simulator)}
31875
31876 \end_inset
31877
31878
31879 \end_layout
31880
31881 \end_inset
31882 </cell>
31883 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31884 \begin_inset Text
31885
31886 \begin_layout Standard
31887 PIC simulator
31888 \end_layout
31889
31890 \end_inset
31891 </cell>
31892 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31893 \begin_inset Text
31894
31895 \begin_layout Standard
31896 \begin_inset LatexCommand \url{http://www.dattalo.com/gnupic/gpsim.html}
31897
31898 \end_inset
31899
31900
31901 \end_layout
31902
31903 \end_inset
31904 </cell>
31905 </row>
31906 <row topline="true">
31907 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31908 \begin_inset Text
31909
31910 \begin_layout Standard
31911 gputils
31912 \begin_inset LatexCommand \index{gputils (pic tools)}
31913
31914 \end_inset
31915
31916
31917 \end_layout
31918
31919 \end_inset
31920 </cell>
31921 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31922 \begin_inset Text
31923
31924 \begin_layout Standard
31925 GNU PIC utilities
31926 \end_layout
31927
31928 \end_inset
31929 </cell>
31930 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31931 \begin_inset Text
31932
31933 \begin_layout Standard
31934 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
31935
31936 \end_inset
31937
31938
31939 \end_layout
31940
31941 \end_inset
31942 </cell>
31943 </row>
31944 <row topline="true">
31945 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31946 \begin_inset Text
31947
31948 \begin_layout Standard
31949 flP5
31950 \end_layout
31951
31952 \end_inset
31953 </cell>
31954 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31955 \begin_inset Text
31956
31957 \begin_layout Standard
31958 PIC programmer
31959 \end_layout
31960
31961 \end_inset
31962 </cell>
31963 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31964 \begin_inset Text
31965
31966 \begin_layout Standard
31967 \begin_inset LatexCommand \url{http://freshmeat.net/projects/flp5/}
31968
31969 \end_inset
31970
31971
31972 \end_layout
31973
31974 \end_inset
31975 </cell>
31976 </row>
31977 <row topline="true">
31978 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31979 \begin_inset Text
31980
31981 \begin_layout Standard
31982 ec2drv/newcdb
31983 \end_layout
31984
31985 \end_inset
31986 </cell>
31987 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31988 \begin_inset Text
31989
31990 \begin_layout Standard
31991 Tools for Silicon Laboratories JTAG debug adapter, partly based on SDCDB
31992  (Unix only)
31993 \end_layout
31994
31995 \end_inset
31996 </cell>
31997 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31998 \begin_inset Text
31999
32000 \begin_layout Standard
32001 \begin_inset LatexCommand \url{http://sourceforge.net/projects/ec2drv}
32002
32003 \end_inset
32004
32005
32006 \end_layout
32007
32008 \end_inset
32009 </cell>
32010 </row>
32011 <row topline="true">
32012 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32013 \begin_inset Text
32014
32015 \begin_layout Standard
32016 indent
32017 \begin_inset LatexCommand \index{indent (source formatting tool)}
32018
32019 \end_inset
32020
32021
32022 \end_layout
32023
32024 \end_inset
32025 </cell>
32026 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32027 \begin_inset Text
32028
32029 \begin_layout Standard
32030 Formats C source - Master of the white spaces
32031 \end_layout
32032
32033 \end_inset
32034 </cell>
32035 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32036 \begin_inset Text
32037
32038 \begin_layout Standard
32039 \begin_inset LatexCommand \url{http://directory.fsf.org/GNU/indent.html}
32040
32041 \end_inset
32042
32043
32044 \end_layout
32045
32046 \end_inset
32047 </cell>
32048 </row>
32049 <row topline="true">
32050 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32051 \begin_inset Text
32052
32053 \begin_layout Standard
32054 srecord
32055 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
32056
32057 \end_inset
32058
32059
32060 \end_layout
32061
32062 \end_inset
32063 </cell>
32064 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32065 \begin_inset Text
32066
32067 \begin_layout Standard
32068 Object file conversion, checksumming, ...
32069 \end_layout
32070
32071 \end_inset
32072 </cell>
32073 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32074 \begin_inset Text
32075
32076 \begin_layout Standard
32077 \begin_inset LatexCommand \url{http://sourceforge.net/projects/srecord}
32078
32079 \end_inset
32080
32081
32082 \end_layout
32083
32084 \end_inset
32085 </cell>
32086 </row>
32087 <row topline="true">
32088 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32089 \begin_inset Text
32090
32091 \begin_layout Standard
32092 objdump
32093 \begin_inset LatexCommand \index{objdump (tool)}
32094
32095 \end_inset
32096
32097
32098 \end_layout
32099
32100 \end_inset
32101 </cell>
32102 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32103 \begin_inset Text
32104
32105 \begin_layout Standard
32106 Object file conversion, ...
32107 \end_layout
32108
32109 \end_inset
32110 </cell>
32111 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32112 \begin_inset Text
32113
32114 \begin_layout Standard
32115 Part of binutils (should be there anyway)
32116 \end_layout
32117
32118 \end_inset
32119 </cell>
32120 </row>
32121 <row topline="true">
32122 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32123 \begin_inset Text
32124
32125 \begin_layout Standard
32126 cmon51
32127 \end_layout
32128
32129 \end_inset
32130 </cell>
32131 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32132 \begin_inset Text
32133
32134 \begin_layout Standard
32135 8051 monitor (hex up-/download, single step, disassemble)
32136 \end_layout
32137
32138 \end_inset
32139 </cell>
32140 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32141 \begin_inset Text
32142
32143 \begin_layout Standard
32144 \begin_inset LatexCommand \url{http://sourceforge.net/projects/cmon51}
32145
32146 \end_inset
32147
32148
32149 \end_layout
32150
32151 \end_inset
32152 </cell>
32153 </row>
32154 <row topline="true">
32155 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32156 \begin_inset Text
32157
32158 \begin_layout Standard
32159 doxygen
32160 \begin_inset LatexCommand \index{doxygen (source documentation tool)}
32161
32162 \end_inset
32163
32164
32165 \end_layout
32166
32167 \end_inset
32168 </cell>
32169 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32170 \begin_inset Text
32171
32172 \begin_layout Standard
32173 Source code documentation system
32174 \end_layout
32175
32176 \end_inset
32177 </cell>
32178 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32179 \begin_inset Text
32180
32181 \begin_layout Standard
32182 \begin_inset LatexCommand \url{http://www.doxygen.org}
32183
32184 \end_inset
32185
32186
32187 \end_layout
32188
32189 \end_inset
32190 </cell>
32191 </row>
32192 <row topline="true">
32193 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32194 \begin_inset Text
32195
32196 \begin_layout Standard
32197 kdevelop
32198 \end_layout
32199
32200 \end_inset
32201 </cell>
32202 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32203 \begin_inset Text
32204
32205 \begin_layout Standard
32206 IDE (has anyone tried integrating SDCC & SDCDB? Unix only)
32207 \end_layout
32208
32209 \end_inset
32210 </cell>
32211 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32212 \begin_inset Text
32213
32214 \begin_layout Standard
32215 \begin_inset LatexCommand \url{http://www.kdevelop.org}
32216
32217 \end_inset
32218
32219
32220 \end_layout
32221
32222 \end_inset
32223 </cell>
32224 </row>
32225 <row topline="true">
32226 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32227 \begin_inset Text
32228
32229 \begin_layout Standard
32230 paulmon
32231 \end_layout
32232
32233 \end_inset
32234 </cell>
32235 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32236 \begin_inset Text
32237
32238 \begin_layout Standard
32239 8051 monitor (hex up-/download, single step, disassemble)
32240 \end_layout
32241
32242 \end_inset
32243 </cell>
32244 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32245 \begin_inset Text
32246
32247 \begin_layout Standard
32248 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/paulmon2.html}
32249
32250 \end_inset
32251
32252
32253 \end_layout
32254
32255 \end_inset
32256 </cell>
32257 </row>
32258 <row topline="true">
32259 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32260 \begin_inset Text
32261
32262 \begin_layout Standard
32263 splint
32264 \begin_inset LatexCommand \index{splint (syntax checking tool)}
32265
32266 \end_inset
32267
32268
32269 \end_layout
32270
32271 \end_inset
32272 </cell>
32273 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32274 \begin_inset Text
32275
32276 \begin_layout Standard
32277 Statically checks c sources (see 
32278 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
32279
32280 \end_inset
32281
32282 )
32283 \end_layout
32284
32285 \end_inset
32286 </cell>
32287 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32288 \begin_inset Text
32289
32290 \begin_layout Standard
32291 \begin_inset LatexCommand \url{http://www.splint.org}
32292
32293 \end_inset
32294
32295
32296 \end_layout
32297
32298 \end_inset
32299 </cell>
32300 </row>
32301 <row topline="true" bottomline="true">
32302 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32303 \begin_inset Text
32304
32305 \begin_layout Standard
32306 ddd
32307 \begin_inset LatexCommand \index{DDD (debugger)}
32308
32309 \end_inset
32310
32311
32312 \end_layout
32313
32314 \end_inset
32315 </cell>
32316 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32317 \begin_inset Text
32318
32319 \begin_layout Standard
32320 Debugger, serves nicely as GUI to SDCDB
32321 \begin_inset LatexCommand \index{SDCDB (debugger)}
32322
32323 \end_inset
32324
32325  (Unix only)
32326 \end_layout
32327
32328 \end_inset
32329 </cell>
32330 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32331 \begin_inset Text
32332
32333 \begin_layout Standard
32334 \begin_inset LatexCommand \url{http://www.gnu.org/software/ddd/}
32335
32336 \end_inset
32337
32338
32339 \end_layout
32340
32341 \end_inset
32342 </cell>
32343 </row>
32344 <row bottomline="true">
32345 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32346 \begin_inset Text
32347
32348 \begin_layout Standard
32349 d52
32350 \begin_inset LatexCommand \index{d52}
32351
32352 \end_inset
32353
32354
32355 \begin_inset LatexCommand \index{d52 (disassembler)}
32356
32357 \end_inset
32358
32359
32360 \end_layout
32361
32362 \end_inset
32363 </cell>
32364 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32365 \begin_inset Text
32366
32367 \begin_layout Standard
32368 Disassembler, can count instruction cycles
32369 \begin_inset LatexCommand \index{instruction cycles (count)}
32370
32371 \end_inset
32372
32373 , use with options -pnd
32374 \end_layout
32375
32376 \end_inset
32377 </cell>
32378 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32379 \begin_inset Text
32380
32381 \begin_layout Standard
32382 \begin_inset LatexCommand \url{http://www.8052.com/users/disasm/}
32383
32384 \end_inset
32385
32386
32387 \end_layout
32388
32389 \end_inset
32390 </cell>
32391 </row>
32392 <row bottomline="true">
32393 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32394 \begin_inset Text
32395
32396 \begin_layout Standard
32397 cmake
32398 \begin_inset LatexCommand \index{cmake}
32399
32400 \end_inset
32401
32402
32403 \end_layout
32404
32405 \end_inset
32406 </cell>
32407 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32408 \begin_inset Text
32409
32410 \begin_layout Standard
32411 Cross platform build system, generates Makefiles
32412 \begin_inset LatexCommand \index{Makefile}
32413
32414 \end_inset
32415
32416  and project workspaces
32417 \begin_inset LatexCommand \index{project workspace}
32418
32419 \end_inset
32420
32421
32422 \end_layout
32423
32424 \end_inset
32425 </cell>
32426 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32427 \begin_inset Text
32428
32429 \begin_layout Standard
32430 \begin_inset LatexCommand \url{http://www.cmake.org}
32431
32432 \end_inset
32433
32434  \InsetSpace ~
32435 \InsetSpace ~
32436 \InsetSpace ~
32437 \InsetSpace ~
32438 and a dedicated wiki entry: 
32439 \begin_inset LatexCommand \url{http://www.cmake.org/Wiki/CmakeSdcc}
32440
32441 \end_inset
32442
32443
32444 \end_layout
32445
32446 \end_inset
32447 </cell>
32448 </row>
32449 </lyxtabular>
32450
32451 \end_inset
32452
32453
32454 \newline
32455
32456 \end_layout
32457
32458 \begin_layout Section
32459 Related documentation / recommended reading
32460 \end_layout
32461
32462 \begin_layout Standard
32463 \align left
32464 \begin_inset Tabular
32465 <lyxtabular version="3" rows="7" columns="3">
32466 <features>
32467 <column alignment="left" valignment="top" leftline="true" width="0pt">
32468 <column alignment="left" valignment="top" leftline="true" width="0">
32469 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
32470 <row topline="true" bottomline="true">
32471 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32472 \begin_inset Text
32473
32474 \begin_layout Standard
32475
32476 \series bold
32477 Name
32478 \end_layout
32479
32480 \end_inset
32481 </cell>
32482 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32483 \begin_inset Text
32484
32485 \begin_layout Standard
32486
32487 \series bold
32488 Subject / Title
32489 \end_layout
32490
32491 \end_inset
32492 </cell>
32493 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32494 \begin_inset Text
32495
32496 \begin_layout Standard
32497
32498 \series bold
32499 Where to get
32500 \end_layout
32501
32502 \end_inset
32503 </cell>
32504 </row>
32505 <row topline="true">
32506 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32507 \begin_inset Text
32508
32509 \begin_layout Standard
32510
32511 \family roman
32512 \series medium
32513 \shape up
32514 \size normal
32515 \emph off
32516 \bar no
32517 \noun off
32518 \color none
32519 c-refcard.pdf
32520 \end_layout
32521
32522 \end_inset
32523 </cell>
32524 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32525 \begin_inset Text
32526
32527 \begin_layout Standard
32528 C Reference Card
32529 \begin_inset LatexCommand \index{C Reference card}
32530
32531 \end_inset
32532
32533 , 2 pages
32534 \end_layout
32535
32536 \end_inset
32537 </cell>
32538 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32539 \begin_inset Text
32540
32541 \begin_layout Standard
32542 \begin_inset LatexCommand \url{http://refcards.com/refcards/c/index.html}
32543
32544 \end_inset
32545
32546
32547 \end_layout
32548
32549 \end_inset
32550 </cell>
32551 </row>
32552 <row topline="true">
32553 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32554 \begin_inset Text
32555
32556 \begin_layout Standard
32557 c-faq
32558 \end_layout
32559
32560 \end_inset
32561 </cell>
32562 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32563 \begin_inset Text
32564
32565 \begin_layout Standard
32566 C-FAQ
32567 \begin_inset LatexCommand \index{C FAQ}
32568
32569 \end_inset
32570
32571
32572 \end_layout
32573
32574 \end_inset
32575 </cell>
32576 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32577 \begin_inset Text
32578
32579 \begin_layout Standard
32580 \begin_inset LatexCommand \url{http://www.c-faq.com}
32581
32582 \end_inset
32583
32584
32585 \end_layout
32586
32587 \end_inset
32588 </cell>
32589 </row>
32590 <row topline="true">
32591 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32592 \begin_inset Text
32593
32594 \begin_layout Standard
32595 ISO/IEC 9899:TC2
32596 \end_layout
32597
32598 \end_inset
32599 </cell>
32600 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32601 \begin_inset Text
32602
32603 \begin_layout Standard
32604 \begin_inset Quotes sld
32605 \end_inset
32606
32607 C-Standard
32608 \begin_inset Quotes srd
32609 \end_inset
32610
32611
32612 \end_layout
32613
32614 \end_inset
32615 </cell>
32616 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32617 \begin_inset Text
32618
32619 \begin_layout Standard
32620
32621 \size footnotesize
32622 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
32623
32624 \end_inset
32625
32626
32627 \end_layout
32628
32629 \end_inset
32630 </cell>
32631 </row>
32632 <row topline="true">
32633 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32634 \begin_inset Text
32635
32636 \begin_layout Standard
32637 ISO/IEC DTR 18037
32638 \end_layout
32639
32640 \end_inset
32641 </cell>
32642 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32643 \begin_inset Text
32644
32645 \begin_layout Standard
32646 \begin_inset Quotes sld
32647 \end_inset
32648
32649 Extensions for Embedded C
32650 \begin_inset Quotes srd
32651 \end_inset
32652
32653
32654 \end_layout
32655
32656 \end_inset
32657 </cell>
32658 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32659 \begin_inset Text
32660
32661 \begin_layout Standard
32662
32663 \size footnotesize
32664 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1021.pdf}
32665
32666 \end_inset
32667
32668
32669 \end_layout
32670
32671 \end_inset
32672 </cell>
32673 </row>
32674 <row topline="true">
32675 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32676 \begin_inset Text
32677
32678 \begin_layout Standard
32679
32680 \end_layout
32681
32682 \end_inset
32683 </cell>
32684 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32685 \begin_inset Text
32686
32687 \begin_layout Standard
32688 Latest datasheet of target CPU
32689 \end_layout
32690
32691 \end_inset
32692 </cell>
32693 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32694 \begin_inset Text
32695
32696 \begin_layout Standard
32697 vendor
32698 \end_layout
32699
32700 \end_inset
32701 </cell>
32702 </row>
32703 <row topline="true" bottomline="true">
32704 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32705 \begin_inset Text
32706
32707 \begin_layout Standard
32708
32709 \end_layout
32710
32711 \end_inset
32712 </cell>
32713 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32714 \begin_inset Text
32715
32716 \begin_layout Standard
32717 Revision history of datasheet
32718 \end_layout
32719
32720 \end_inset
32721 </cell>
32722 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32723 \begin_inset Text
32724
32725 \begin_layout Standard
32726 vendor
32727 \end_layout
32728
32729 \end_inset
32730 </cell>
32731 </row>
32732 </lyxtabular>
32733
32734 \end_inset
32735
32736
32737 \newline
32738
32739 \end_layout
32740
32741 \begin_layout Section
32742 Application notes specifically for SDCC
32743 \end_layout
32744
32745 \begin_layout Standard
32746 SDCC makes no claims about the completeness of this list and about up-to-datenes
32747 s or correctness of the application notes
32748 \begin_inset LatexCommand \index{Application notes}
32749
32750 \end_inset
32751
32752 .
32753 \end_layout
32754
32755 \begin_layout Standard
32756 \align left
32757
32758 \size footnotesize
32759 \begin_inset Tabular
32760 <lyxtabular version="3" rows="7" columns="3">
32761 <features>
32762 <column alignment="block" valignment="top" leftline="true" width="17col%">
32763 <column alignment="block" valignment="top" leftline="true" width="27col%">
32764 <column alignment="block" valignment="top" leftline="true" rightline="true" width="57col%">
32765 <row topline="true" bottomline="true">
32766 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32767 \begin_inset Text
32768
32769 \begin_layout Standard
32770
32771 \series bold
32772 \size footnotesize
32773 Vendor
32774 \end_layout
32775
32776 \end_inset
32777 </cell>
32778 <cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
32779 \begin_inset Text
32780
32781 \begin_layout Standard
32782
32783 \series bold
32784 \size footnotesize
32785 Subject / Title
32786 \end_layout
32787
32788 \end_inset
32789 </cell>
32790 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32791 \begin_inset Text
32792
32793 \begin_layout Standard
32794
32795 \series bold
32796 \size footnotesize
32797 Where to get
32798 \end_layout
32799
32800 \end_inset
32801 </cell>
32802 </row>
32803 <row topline="true">
32804 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32805 \begin_inset Text
32806
32807 \begin_layout Standard
32808
32809 \size footnotesize
32810 Maxim / Dallas
32811 \end_layout
32812
32813 \end_inset
32814 </cell>
32815 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32816 \begin_inset Text
32817
32818 \begin_layout Standard
32819
32820 \size footnotesize
32821 Using the SDCC Compiler for the DS80C400
32822 \begin_inset LatexCommand \index{DS80C400}
32823
32824 \end_inset
32825
32826
32827 \end_layout
32828
32829 \end_inset
32830 </cell>
32831 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32832 \begin_inset Text
32833
32834 \begin_layout Standard
32835
32836 \size footnotesize
32837 \begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3346.pdf}
32838
32839 \end_inset
32840
32841
32842 \end_layout
32843
32844 \end_inset
32845 </cell>
32846 </row>
32847 <row topline="true">
32848 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32849 \begin_inset Text
32850
32851 \begin_layout Standard
32852
32853 \size footnotesize
32854 Maxim / Dallas
32855 \end_layout
32856
32857 \end_inset
32858 </cell>
32859 <cell multicolumn="1" alignment="left" valignment="top" topline="true" leftline="true" usebox="none" width="30line%">
32860 \begin_inset Text
32861
32862 \begin_layout Standard
32863
32864 \size footnotesize
32865 Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450
32866 \begin_inset LatexCommand \index{DS89C4x0}
32867
32868 \end_inset
32869
32870  Family of Microcontrollers
32871 \end_layout
32872
32873 \end_inset
32874 </cell>
32875 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32876 \begin_inset Text
32877
32878 \begin_layout Standard
32879
32880 \size footnotesize
32881 \begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3477.pdf}
32882
32883 \end_inset
32884
32885
32886 \end_layout
32887
32888 \end_inset
32889 </cell>
32890 </row>
32891 <row topline="true">
32892 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32893 \begin_inset Text
32894
32895 \begin_layout Standard
32896
32897 \size footnotesize
32898 Silicon Laboratories / Cygnal
32899 \end_layout
32900
32901 \end_inset
32902 </cell>
32903 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32904 \begin_inset Text
32905
32906 \begin_layout Standard
32907
32908 \size footnotesize
32909 Integrating SDCC 8051 Tools Into The Silicon Labs IDE
32910 \begin_inset LatexCommand \index{IDE}
32911
32912 \end_inset
32913
32914
32915 \end_layout
32916
32917 \end_inset
32918 </cell>
32919 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32920 \begin_inset Text
32921
32922 \begin_layout Standard
32923
32924 \size footnotesize
32925 \begin_inset LatexCommand \url{http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/en/an198.pdf}
32926
32927 \end_inset
32928
32929
32930 \end_layout
32931
32932 \end_inset
32933 </cell>
32934 </row>
32935 <row topline="true">
32936 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32937 \begin_inset Text
32938
32939 \begin_layout Standard
32940
32941 \size footnotesize
32942 Ramtron / Goal Semiconductor
32943 \end_layout
32944
32945 \end_inset
32946 </cell>
32947 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32948 \begin_inset Text
32949
32950 \begin_layout Standard
32951
32952 \size footnotesize
32953 Interfacing SDCC to Syn and Textpad
32954 \end_layout
32955
32956 \end_inset
32957 </cell>
32958 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32959 \begin_inset Text
32960
32961 \begin_layout Standard
32962
32963 \size footnotesize
32964 \begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
32965
32966 \end_inset
32967
32968
32969 \end_layout
32970
32971 \end_inset
32972 </cell>
32973 </row>
32974 <row topline="true">
32975 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32976 \begin_inset Text
32977
32978 \begin_layout Standard
32979
32980 \size footnotesize
32981 Ramtron / Goal Semiconductor
32982 \end_layout
32983
32984 \end_inset
32985 </cell>
32986 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32987 \begin_inset Text
32988
32989 \begin_layout Standard
32990
32991 \size footnotesize
32992 Installing and Configuring SDCC and Crimson Editor 
32993 \end_layout
32994
32995 \end_inset
32996 </cell>
32997 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32998 \begin_inset Text
32999
33000 \begin_layout Standard
33001
33002 \size footnotesize
33003 \begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
33004
33005 \end_inset
33006
33007
33008 \end_layout
33009
33010 \end_inset
33011 </cell>
33012 </row>
33013 <row topline="true" bottomline="true">
33014 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33015 \begin_inset Text
33016
33017 \begin_layout Standard
33018
33019 \size footnotesize
33020 Texas Instruments
33021 \end_layout
33022
33023 \end_inset
33024 </cell>
33025 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33026 \begin_inset Text
33027
33028 \begin_layout Standard
33029
33030 \size footnotesize
33031 MSC12xx Programming with SDCC
33032 \end_layout
33033
33034 \end_inset
33035 </cell>
33036 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33037 \begin_inset Text
33038
33039 \begin_layout Standard
33040
33041 \size footnotesize
33042 \begin_inset LatexCommand \url{http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sbaa109&fileType=pdf}
33043
33044 \end_inset
33045
33046
33047 \end_layout
33048
33049 \end_inset
33050 </cell>
33051 </row>
33052 </lyxtabular>
33053
33054 \end_inset
33055
33056
33057 \end_layout
33058
33059 \begin_layout Section
33060 Some Questions
33061 \end_layout
33062
33063 \begin_layout Standard
33064 Some questions answered, some pointers given - it might be time to in turn
33065  ask 
33066 \emph on
33067 you
33068 \emph default
33069  some questions: 
33070 \end_layout
33071
33072 \begin_layout Itemize
33073 can you solve your project with the selected microcontroller? Would you
33074  find out early or rather late that your target is too small/slow/whatever?
33075  Can you switch to a slightly better device if it doesn't fit?
33076 \end_layout
33077
33078 \begin_layout Itemize
33079 should you solve the problem with an 8 bit CPU? Or would a 16/32 bit CPU
33080  and/or another programming language be more adequate? Would an operating
33081  system on the target device help?
33082 \end_layout
33083
33084 \begin_layout Itemize
33085 if you solved the problem, will the marketing department be happy?
33086 \end_layout
33087
33088 \begin_layout Itemize
33089 if the marketing department is happy, will customers be happy?
33090 \end_layout
33091
33092 \begin_layout Itemize
33093 if you're the project manager, marketing department and maybe even the customer
33094  in one person, have you tried to see the project from the outside?
33095 \end_layout
33096
33097 \begin_layout Itemize
33098 is the project done if you think it is done? Or is just that other interface/pro
33099 tocol/feature/configuration/option missing? How about website, manual(s),
33100  internationali(z|s)ation, packaging, labels, 2nd source for components,
33101  electromagnetic compatability/interference, documentation for production,
33102  production test software, update mechanism, patent issues?
33103 \end_layout
33104
33105 \begin_layout Itemize
33106 is your project adequately positioned in that magic triangle: fame, fortune,
33107  fun?
33108 \end_layout
33109
33110 \begin_layout Standard
33111 Maybe not all answers to these questions are known and some answers may
33112  even be 
33113 \emph on
33114 no
33115 \emph default
33116 , nevertheless knowing these questions may help you to avoid burnout
33117 \begin_inset Foot
33118 status open
33119
33120 \begin_layout Standard
33121 burnout is bad for electronic devices, programmers and motorcycle tyres
33122 \end_layout
33123
33124 \end_inset
33125
33126 .
33127  Chances are you didn't want to hear some of them...
33128 \end_layout
33129
33130 \begin_layout Chapter
33131 Support
33132 \begin_inset LatexCommand \index{Support}
33133
33134 \end_inset
33135
33136
33137 \end_layout
33138
33139 \begin_layout Standard
33140 SDCC has grown to be a large project.
33141  The compiler alone (without the preprocessor, assembler and linker) is
33142  well over 150,000 lines of code (blank stripped).
33143  The open source nature of this project is a key to its continued growth
33144  and support.
33145  You gain the benefit and support of many active software developers and
33146  end users.
33147  Is SDCC perfect? No, that's why we need your help.
33148  The developers take pride in fixing reported bugs.
33149  You can help by reporting the bugs and helping other SDCC users.
33150  There are lots of ways to contribute, and we encourage you to take part
33151  in making SDCC a great software package.
33152  
33153 \end_layout
33154
33155 \begin_layout Standard
33156 The SDCC project is hosted on the SDCC sourceforge site at 
33157 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/sdcc}
33158
33159 \end_inset
33160
33161 .
33162  You'll find the complete set of mailing lists
33163 \begin_inset LatexCommand \index{Mailing list(s)}
33164
33165 \end_inset
33166
33167 , forums, bug reporting system, patch submission
33168 \begin_inset LatexCommand \index{Patch submission}
33169
33170 \end_inset
33171
33172  system, download
33173 \begin_inset LatexCommand \index{download}
33174
33175 \end_inset
33176
33177  area and Subversion code repository
33178 \begin_inset LatexCommand \index{Subversion code repository}
33179
33180 \end_inset
33181
33182  there.
33183 \end_layout
33184
33185 \begin_layout Section
33186 Reporting Bugs
33187 \begin_inset LatexCommand \index{Bug reporting}
33188
33189 \end_inset
33190
33191
33192 \begin_inset LatexCommand \index{Reporting bugs}
33193
33194 \end_inset
33195
33196
33197 \end_layout
33198
33199 \begin_layout Standard
33200 The recommended way of reporting bugs is using the infrastructure of the
33201  sourceforge site.
33202  You can follow the status of bug reports there and have an overview about
33203  the known bugs.
33204 \end_layout
33205
33206 \begin_layout Standard
33207 Bug reports are automatically forwarded to the developer mailing list and
33208  will be fixed ASAP.
33209  When reporting a bug, it is very useful to include a small test program
33210  (the smaller the better) which reproduces the problem.
33211  If you can isolate the problem by looking at the generated assembly code,
33212  this can be very helpful.
33213  Compiling your program with the -
33214 \begin_inset ERT
33215 status collapsed
33216
33217 \begin_layout Standard
33218
33219
33220 \backslash
33221 /
33222 \end_layout
33223
33224 \end_inset
33225
33226 -dumpall
33227 \begin_inset LatexCommand \index{-\/-dumpall}
33228
33229 \end_inset
33230
33231  option can sometimes be useful in locating optimization problems.
33232  When reporting a bug please make sure you:
33233 \end_layout
33234
33235 \begin_layout Enumerate
33236 Attach the code you are compiling with SDCC.
33237  
33238 \end_layout
33239
33240 \begin_layout Enumerate
33241 Specify the exact command you use to run SDCC, or attach your Makefile.
33242  
33243 \end_layout
33244
33245 \begin_layout Enumerate
33246 Specify the SDCC version (type "
33247 \family sans
33248 \series bold
33249 sdcc -v
33250 \family default
33251 \series default
33252 "), your platform, and operating system.
33253  
33254 \end_layout
33255
33256 \begin_layout Enumerate
33257 Provide an exact copy of any error message or incorrect output.
33258  
33259 \end_layout
33260
33261 \begin_layout Enumerate
33262 Put something meaningful in the subject of your message.
33263 \end_layout
33264
33265 \begin_layout Standard
33266 Please attempt to include these 5 important parts, as applicable, in all
33267  requests for support or when reporting any problems or bugs with SDCC.
33268  Though this will make your message lengthy, it will greatly improve your
33269  chance that SDCC users and developers will be able to help you.
33270  Some SDCC developers are frustrated by bug reports without code provided
33271  that they can use to reproduce and ultimately fix the problem, so please
33272  be sure to provide sample code if you are reporting a bug! 
33273 \end_layout
33274
33275 \begin_layout Standard
33276 Please have a short check that you are using a recent version of SDCC and
33277  the bug is not yet known.
33278  This is the link for reporting bugs: 
33279 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=100599}
33280
33281 \end_inset
33282
33283 .
33284  With SDCC on average having more than 200 downloads
33285 \begin_inset LatexCommand \index{download}
33286
33287 \end_inset
33288
33289  on sourceforge per day
33290 \begin_inset Foot
33291 status open
33292
33293 \begin_layout Standard
33294 220 daily downloads on average Jan-Sept 2006 and about 150 daily downloads
33295  between 2002 and 2005.
33296  This does not include other methods of distribution.
33297 \end_layout
33298
33299 \end_inset
33300
33301  there must be some users.
33302  So it's not exactly easy to find a new bug.
33303  If you find one we need it: 
33304 \emph on
33305 reporting bugs is good
33306 \emph default
33307 .
33308 \end_layout
33309
33310 \begin_layout Section
33311 Requesting Features
33312 \begin_inset LatexCommand \label{sub:Requesting-Features}
33313
33314 \end_inset
33315
33316
33317 \begin_inset LatexCommand \index{Feature request}
33318
33319 \end_inset
33320
33321
33322 \begin_inset LatexCommand \index{Requesting features}
33323
33324 \end_inset
33325
33326
33327 \end_layout
33328
33329 \begin_layout Standard
33330 Like bug reports feature requests are forwarded to the developer mailing
33331  list.
33332  This is the link for requesting features: 
33333 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
33334
33335 \end_inset
33336
33337 .
33338 \end_layout
33339
33340 \begin_layout Section
33341 Submitting patches
33342 \end_layout
33343
33344 \begin_layout Standard
33345 Like bug reports contributed patches are forwarded to the developer mailing
33346  list.
33347  This is the link for submitting patches
33348 \begin_inset LatexCommand \index{Patch submission}
33349
33350 \end_inset
33351
33352
33353 \begin_inset LatexCommand \url{http://sourceforge.net/tracker/?group_id=599&atid=300599}
33354
33355 \end_inset
33356
33357 .
33358 \end_layout
33359
33360 \begin_layout Standard
33361 You need to specify some parameters to the 
33362 \family typewriter
33363 diff
33364 \family default
33365  command for the patches to be useful.
33366  If you modified more than one file a patch created f.e.
33367  with 
33368 \family sans
33369 \series bold
33370
33371 \begin_inset Quotes sld
33372 \end_inset
33373
33374 diff -Naur unmodified_directory modified_directory >my_changes.patch
33375 \begin_inset Quotes srd
33376 \end_inset
33377
33378
33379 \family default
33380 \series default
33381  will be fine, otherwise 
33382 \family sans
33383 \series bold
33384
33385 \begin_inset Quotes sld
33386 \end_inset
33387
33388 diff -u sourcefile.c.orig sourcefile.c >my_changes.patch
33389 \begin_inset Quotes srd
33390 \end_inset
33391
33392
33393 \series default
33394  
33395 \family default
33396 will do.
33397 \end_layout
33398
33399 \begin_layout Section
33400 Getting Help
33401 \end_layout
33402
33403 \begin_layout Standard
33404 These links should take you directly to the 
33405 \begin_inset LatexCommand \url[Mailing lists]{http://sourceforge.net/mail/?group_id=599}
33406
33407 \end_inset
33408
33409
33410 \begin_inset Foot
33411 status open
33412
33413 \begin_layout Standard
33414 Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
33415  automated messages (mid 2003)
33416 \end_layout
33417
33418 \end_inset
33419
33420  and the 
33421 \begin_inset LatexCommand \url[Forums]{http://sourceforge.net/forum/?group_id=599}
33422
33423 \end_inset
33424
33425 , lists
33426 \begin_inset LatexCommand \index{Mailing list(s)}
33427
33428 \end_inset
33429
33430  and forums are archived and searchable so if you are lucky someone already
33431  had a similar problem.
33432  While mails to the lists themselves are delivered promptly their web front
33433  end on sourceforge sometimes shows a severe time lag (up to several weeks),
33434  if you're seriously using SDCC please consider subscribing to the lists.
33435 \end_layout
33436
33437 \begin_layout Section
33438 ChangeLog
33439 \end_layout
33440
33441 \begin_layout Standard
33442 You can follow the status of the Subversion version
33443 \begin_inset LatexCommand \index{version}
33444
33445 \end_inset
33446
33447  of SDCC by watching the Changelog
33448 \begin_inset LatexCommand \index{Changelog}
33449
33450 \end_inset
33451
33452  in the Subversion repository
33453 \size footnotesize
33454  
33455 \begin_inset LatexCommand \htmlurl{http://sdcc.svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/ChangeLog}
33456
33457 \end_inset
33458
33459 .
33460 \end_layout
33461
33462 \begin_layout Section
33463 Subversion Source Code Repository
33464 \end_layout
33465
33466 \begin_layout Standard
33467 The output of 
33468 \family sans
33469 \series bold
33470 sdcc -
33471 \family default
33472
33473 \begin_inset ERT
33474 status open
33475
33476 \begin_layout Standard
33477
33478
33479 \backslash
33480 /
33481 \end_layout
33482
33483 \end_inset
33484
33485
33486 \family sans
33487 -version
33488 \family default
33489 \series default
33490  or the filenames of the snapshot versions of SDCC include date and its
33491  Subversion
33492 \begin_inset LatexCommand \index{Subversion code repository}
33493
33494 \end_inset
33495
33496  number.
33497  Subversion allows to download the source of recent or previous versions
33498  
33499 \begin_inset LatexCommand \url{http://sourceforge.net/svn/?group_id=599}
33500
33501 \end_inset
33502
33503  (by number or by date).
33504  An on-line source code browser and detailled instructions are also available
33505  there.
33506  SDCC versions starting from 1999 up to now are available (currently the
33507  versions prior to the conversion from cvs
33508 \begin_inset LatexCommand \index{cvs|see{Subversion}}
33509
33510 \end_inset
33511
33512  to Subversion (April 2006) are either by accessible by Subversion or by
33513  cvs).
33514 \end_layout
33515
33516 \begin_layout Section
33517 Release policy
33518 \begin_inset LatexCommand \index{Release policy}
33519
33520 \end_inset
33521
33522
33523 \end_layout
33524
33525 \begin_layout Standard
33526 Historically there often were long delays between official releases and
33527  the sourceforge download area tends to get not updated at all.
33528  Excuses in the past might have referred to problems with live range analysis,
33529  but as this was fixed a while ago, the current problem is that another
33530  excuse has to be found.
33531  Kidding aside, we have to get better there! On the other hand there are
33532  daily snapshots available at 
33533 \begin_inset LatexCommand \htmlurl[snap]{http://sdcc.sourceforge.net/snap.php}
33534
33535 \end_inset
33536
33537 , and you can always build the very last version (hopefully with many bugs
33538  fixed, and features added) from the source code available at 
33539 \begin_inset LatexCommand \htmlurl[Source]{http://sdcc.sourceforge.net/snap.php#Source}
33540
33541 \end_inset
33542
33543 .
33544  The SDCC Wiki
33545 \begin_inset LatexCommand \index{wiki}
33546
33547 \end_inset
33548
33549
33550 \begin_inset LatexCommand \index{SDCC Wiki}
33551
33552 \end_inset
33553
33554  at 
33555 \begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/}
33556
33557 \end_inset
33558
33559  also holds some information about past and future releases.
33560 \end_layout
33561
33562 \begin_layout Section
33563 Examples
33564 \begin_inset LatexCommand \index{Examples}
33565
33566 \end_inset
33567
33568
33569 \end_layout
33570
33571 \begin_layout Standard
33572 You'll find some small examples in the directory 
33573 \emph on
33574 sdcc/device/examples/.
33575  
33576 \emph default
33577 More examples and libraries are available at
33578 \emph on
33579  The SDCC Open Knowledge Resource 
33580 \begin_inset LatexCommand \url{http://sdccokr.dl9sec.de/}
33581
33582 \end_inset
33583
33584  
33585 \emph default
33586 web site or at 
33587 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/}
33588
33589 \end_inset
33590
33591 .
33592 \end_layout
33593
33594 \begin_layout Standard
33595 \begin_inset Note Note
33596 status collapsed
33597
33598 \begin_layout Standard
33599 I did insert a reference to Paul's web site here although it seems rather
33600  dedicated to a specific 8032 board (I think it's okay because it f.e.
33601  shows LCD/Harddisc interface and has a free 8051 monitor.
33602  Independent 8032 board vendors face hard competition of heavily subsidized
33603  development boards anyway).
33604 \end_layout
33605
33606 \begin_layout Standard
33607 Maybe we should include some links to real world applications.
33608  Preferably pointer to pointers (one for each architecture) so this stays
33609  manageable here?
33610 \end_layout
33611
33612 \end_inset
33613
33614
33615 \end_layout
33616
33617 \begin_layout Section
33618 Quality control
33619 \begin_inset LatexCommand \label{sec:Quality-control}
33620
33621 \end_inset
33622
33623
33624 \begin_inset LatexCommand \index{Quality control}
33625
33626 \end_inset
33627
33628
33629 \end_layout
33630
33631 \begin_layout Standard
33632 The compiler is passed through snaphot build compile and build checks.
33633  The so called 
33634 \shape italic
33635 regression tests
33636 \shape default
33637
33638 \begin_inset LatexCommand \index{Regression test}
33639
33640 \end_inset
33641
33642  check that SDCC itself compiles flawlessly on several host platforms (i386,
33643  Opteron, 64 bit Alpha, ppc64, Mac OS X on ppc and i386, Solaris on Sparc)
33644  and checks the quality of the code generated by SDCC by running the code
33645  for several target platforms through simulators.
33646  The regression test suite comprises more than 100 files which expand to
33647  more than 500 test cases which include more than 4500 tests.
33648  The results of these tests are published daily on SDCC's snapshot page
33649  (click on the red or green symbols on the right side of 
33650 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
33651
33652 \end_inset
33653
33654 ).
33655 \end_layout
33656
33657 \begin_layout Standard
33658 There is a separate document 
33659 \shape italic
33660 test_suite.pdf 
33661 \begin_inset LatexCommand \index{Test suite}
33662
33663 \end_inset
33664
33665
33666 \shape default
33667  
33668 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
33669
33670 \end_inset
33671
33672  about the regression test suite.
33673 \end_layout
33674
33675 \begin_layout Standard
33676 You'll find the test code in the directory 
33677 \shape italic
33678 sdcc/support/regression
33679 \shape default
33680 .
33681  You can run these tests manually by running 
33682 \family sans
33683 make
33684 \family default
33685  in this directory (or f.e.
33686  
33687 \family sans
33688 \series bold
33689
33690 \begin_inset Quotes sld
33691 \end_inset
33692
33693 make test-mcs51
33694 \begin_inset Quotes srd
33695 \end_inset
33696
33697
33698 \family default
33699 \series default
33700  if you don't want to run the complete tests).
33701  The test code might also be interesting if you want to look for examples
33702 \begin_inset LatexCommand \index{Examples}
33703
33704 \end_inset
33705
33706  checking corner cases of SDCC or if you plan to submit patches
33707 \begin_inset LatexCommand \index{Patch submission}
33708
33709 \end_inset
33710
33711 .
33712 \end_layout
33713
33714 \begin_layout Standard
33715 The PIC14 port uses a different set of regression tests 
33716 \begin_inset LatexCommand \index{Regression test (PIC14)}
33717
33718 \end_inset
33719
33720 , you'll find them in the directory 
33721 \shape italic
33722 sdcc/src/regression
33723 \shape default
33724 .
33725 \end_layout
33726
33727 \begin_layout Section
33728 Use of SDCC in Education
33729 \end_layout
33730
33731 \begin_layout Standard
33732 In short: 
33733 \emph on
33734 highly
33735 \emph default
33736  encouraged
33737 \begin_inset Foot
33738 status open
33739
33740 \begin_layout Standard
33741 the phrase "use in education" might evoke the association "
33742 \emph on
33743 only
33744 \emph default
33745  fit for use in education".
33746  This connotation is not intended but nevertheless risked as the licensing
33747  of SDCC makes it difficult to offer educational discounts
33748 \end_layout
33749
33750 \end_inset
33751
33752 .
33753  If your rationales are to:
33754 \end_layout
33755
33756 \begin_layout Enumerate
33757 give students a chance to understand the 
33758 \emph on
33759 complete
33760 \emph default
33761  steps of code generation
33762 \end_layout
33763
33764 \begin_layout Enumerate
33765 have a curriculum that can be extended for years.
33766  Then you could use an fpga board as target and your curriculum will seamlessly
33767  extend from logic synthesis (
33768 \begin_inset LatexCommand \url[http://www.opencores.org]{opencores.org}
33769
33770 \end_inset
33771
33772
33773 \begin_inset LatexCommand \url[Oregano]{http://www.oregano.at/ip/ip01.htm}
33774
33775 \end_inset
33776
33777 ), over assembly programming, to C to FPGA compilers (
33778 \begin_inset LatexCommand \url[FPGAC]{http://sf.net/projects/fpgac}
33779
33780 \end_inset
33781
33782 ) and to C.
33783 \end_layout
33784
33785 \begin_layout Enumerate
33786 be able to insert excursions about skills like using a revision control
33787  system, submitting/applying patches, using a type-setting (as opposed to
33788  word-processing) engine LyX/LaTeX, using 
33789 \begin_inset LatexCommand \url[SourceForge]{http://www.sf.net}
33790
33791 \end_inset
33792
33793 , following some 
33794 \begin_inset LatexCommand \url[netiquette]{http://en.wikipedia.org/wiki/Netiquette}
33795
33796 \end_inset
33797
33798 , understanding BSD/LGPL/GPL/Proprietary licensing, growth models of Open
33799  Source Software, CPU simulation, compiler regression tests
33800 \begin_inset LatexCommand \index{Regression test}
33801
33802 \end_inset
33803
33804 .
33805  
33806 \newline
33807 And if there should be a shortage of ideas then you can always point students
33808  to the ever-growing feature request list 
33809 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
33810
33811 \end_inset
33812
33813 .
33814 \end_layout
33815
33816 \begin_layout Enumerate
33817 not tie students to a specific host platform and instead allow them to use
33818  a host platform of 
33819 \emph on
33820 their
33821 \emph default
33822  choice (among them Alpha, i386, i386_64, Mac OS X, Mips, Sparc, Windows
33823  and eventually 
33824 \begin_inset LatexCommand \url[OLPC]{http://www.laptop.org}
33825
33826 \end_inset
33827
33828 )
33829 \end_layout
33830
33831 \begin_layout Enumerate
33832 not encourage students to use illegal copies of educational software
33833 \end_layout
33834
33835 \begin_layout Enumerate
33836 be immune to licensing/availability/price changes of the chosen tool chain
33837 \end_layout
33838
33839 \begin_layout Enumerate
33840 be able to change to a new target platform without having to adopt a new
33841  tool chain
33842 \end_layout
33843
33844 \begin_layout Enumerate
33845 have complete control over and insight into the tool chain
33846 \end_layout
33847
33848 \begin_layout Enumerate
33849 make your students aware about the pros and cons of open source software
33850  development
33851 \end_layout
33852
33853 \begin_layout Enumerate
33854 give back to the public as you are probably at least partially publically
33855  funded
33856 \end_layout
33857
33858 \begin_layout Enumerate
33859 give students a chance to publically prove their skills and to possibly
33860  see a world wide impact
33861 \end_layout
33862
33863 \begin_layout Standard
33864 then SDCC is probably among the first choices.
33865  Well, probably SDCC might be the only choice.
33866 \newpage
33867
33868 \end_layout
33869
33870 \begin_layout Chapter
33871 SDCC Technical Data
33872 \end_layout
33873
33874 \begin_layout Section
33875 Optimizations
33876 \begin_inset LatexCommand \index{Optimizations}
33877
33878 \end_inset
33879
33880
33881 \end_layout
33882
33883 \begin_layout Standard
33884 SDCC performs a host of standard optimizations in addition to some MCU specific
33885  optimizations.
33886  
33887 \end_layout
33888
33889 \begin_layout Subsection
33890 Sub-expression Elimination
33891 \begin_inset LatexCommand \index{Subexpression elimination}
33892
33893 \end_inset
33894
33895
33896 \end_layout
33897
33898 \begin_layout Standard
33899 The compiler does local and 
33900 \emph on
33901 g
33902 \emph default
33903 lobal 
33904 \emph on
33905 c
33906 \emph default
33907 ommon 
33908 \emph on
33909 s
33910 \emph default
33911 ubexpression 
33912 \emph on
33913 e
33914 \emph default
33915 limination, e.g.: 
33916 \end_layout
33917
33918 \begin_layout Verse
33919
33920 \family typewriter
33921 i = x + y + 1; 
33922 \newline
33923 j = x + y;
33924 \end_layout
33925
33926 \begin_layout Standard
33927 will be translated to
33928 \end_layout
33929
33930 \begin_layout Verse
33931
33932 \family typewriter
33933 iTemp = x + y; 
33934 \newline
33935 i = iTemp + 1; 
33936 \newline
33937 j = iTemp;
33938 \end_layout
33939
33940 \begin_layout Standard
33941 Some subexpressions are not as obvious as the above example, e.g.:
33942 \end_layout
33943
33944 \begin_layout Verse
33945
33946 \family typewriter
33947 a->b[i].c = 10; 
33948 \newline
33949 a->b[i].d = 11;
33950 \end_layout
33951
33952 \begin_layout Standard
33953 In this case the address arithmetic a->b[i] will be computed only once;
33954  the equivalent code in C would be.
33955 \end_layout
33956
33957 \begin_layout Verse
33958
33959 \family typewriter
33960 iTemp = a->b[i]; 
33961 \newline
33962 iTemp.c = 10; 
33963 \newline
33964 iTemp.d = 11;
33965 \end_layout
33966
33967 \begin_layout Standard
33968 The compiler will try to keep these temporary variables in registers.
33969 \end_layout
33970
33971 \begin_layout Subsection
33972 Dead-Code Elimination
33973 \begin_inset LatexCommand \index{Dead-code elimination}
33974
33975 \end_inset
33976
33977
33978 \end_layout
33979
33980 \begin_layout Verse
33981
33982 \family typewriter
33983 int global;
33984 \newline
33985
33986 \newline
33987 void f () { 
33988 \newline
33989 \InsetSpace ~
33990 \InsetSpace ~
33991 int i; 
33992 \newline
33993 \InsetSpace ~
33994 \InsetSpace ~
33995 i = 1; \InsetSpace ~
33996 \InsetSpace ~
33997 \InsetSpace ~
33998 \InsetSpace ~
33999 \InsetSpace ~
34000 /* dead store */ 
34001 \newline
34002 \InsetSpace ~
34003 \InsetSpace ~
34004 global = 1;\InsetSpace ~
34005 /* dead
34006  store */ 
34007 \newline
34008 \InsetSpace ~
34009 \InsetSpace ~
34010 global = 2; 
34011 \newline
34012 \InsetSpace ~
34013 \InsetSpace ~
34014 return; 
34015 \newline
34016 \InsetSpace ~
34017 \InsetSpace ~
34018 global = 3;\InsetSpace ~
34019 /* unreachable */ 
34020 \newline
34021 }
34022 \end_layout
34023
34024 \begin_layout Standard
34025 will be changed to
34026 \end_layout
34027
34028 \begin_layout Verse
34029
34030 \family typewriter
34031 int global;
34032 \newline
34033
34034 \newline
34035 void f () {
34036 \newline
34037 \InsetSpace ~
34038 \InsetSpace ~
34039 global = 2; 
34040 \newline
34041 }
34042 \end_layout
34043
34044 \begin_layout Subsection
34045 Copy-Propagation
34046 \begin_inset LatexCommand \index{Copy propagation}
34047
34048 \end_inset
34049
34050
34051 \end_layout
34052
34053 \begin_layout Verse
34054
34055 \family typewriter
34056 int f() { 
34057 \newline
34058 \InsetSpace ~
34059 \InsetSpace ~
34060 int i, j; 
34061 \newline
34062 \InsetSpace ~
34063 \InsetSpace ~
34064 i = 10; 
34065 \newline
34066 \InsetSpace ~
34067 \InsetSpace ~
34068 j = i; 
34069 \newline
34070 \InsetSpace ~
34071 \InsetSpace ~
34072 return j; 
34073 \newline
34074 }
34075 \end_layout
34076
34077 \begin_layout Standard
34078 will be changed to 
34079 \end_layout
34080
34081 \begin_layout Verse
34082
34083 \family typewriter
34084 int f() { 
34085 \newline
34086 \InsetSpace ~
34087 \InsetSpace ~
34088 int i, j; 
34089 \newline
34090 \InsetSpace ~
34091 \InsetSpace ~
34092 i = 10; 
34093 \newline
34094 \InsetSpace ~
34095 \InsetSpace ~
34096 j = 10; 
34097 \newline
34098 \InsetSpace ~
34099 \InsetSpace ~
34100 return 10; 
34101 \newline
34102 }
34103 \end_layout
34104
34105 \begin_layout Standard
34106 Note: the dead stores created by this copy propagation will be eliminated
34107  by dead-code elimination.
34108 \end_layout
34109
34110 \begin_layout Subsection
34111 Loop Optimizations
34112 \begin_inset LatexCommand \index{Loop optimization}
34113
34114 \end_inset
34115
34116
34117 \begin_inset LatexCommand \label{sub:Loop-Optimizations}
34118
34119 \end_inset
34120
34121
34122 \end_layout
34123
34124 \begin_layout Standard
34125 Two types of loop optimizations are done by SDCC 
34126 \emph on
34127 loop invariant
34128 \emph default
34129  lifting and
34130 \emph on
34131  strength reduction
34132 \emph default
34133  of loop induction variables.
34134  In addition to the strength reduction the optimizer marks the induction
34135  variables and the register allocator tries to keep the induction variables
34136  in registers for the duration of the loop.
34137  Because of this preference of the register allocator
34138 \begin_inset LatexCommand \index{Register allocation}
34139
34140 \end_inset
34141
34142 , loop induction optimization causes an increase in register pressure, which
34143  may cause unwanted spilling of other temporary variables into the stack
34144 \begin_inset LatexCommand \index{stack}
34145
34146 \end_inset
34147
34148  / data space.
34149  The compiler will generate a warning message when it is forced to allocate
34150  extra space either on the stack or data space.
34151  If this extra space allocation is undesirable then induction optimization
34152  can be eliminated either for the entire source file (with -
34153 \begin_inset ERT
34154 status collapsed
34155
34156 \begin_layout Standard
34157
34158
34159 \backslash
34160 /
34161 \end_layout
34162
34163 \end_inset
34164
34165 -noinduction option) or for a given function only using #pragma\InsetSpace ~
34166 noinduction
34167 \begin_inset LatexCommand \index{\#pragma noinduction}
34168
34169 \end_inset
34170
34171 .
34172 \newline
34173
34174 \newline
34175 Loop Invariant:
34176 \end_layout
34177
34178 \begin_layout Verse
34179
34180 \family typewriter
34181 for (i = 0 ; i < 100 ; i ++) 
34182 \newline
34183 \InsetSpace ~
34184 \InsetSpace ~
34185 \InsetSpace ~
34186 \InsetSpace ~
34187 f += k + l;
34188 \end_layout
34189
34190 \begin_layout Standard
34191 changed to
34192 \end_layout
34193
34194 \begin_layout Verse
34195
34196 \family typewriter
34197 itemp = k + l; 
34198 \newline
34199 for (i = 0; i < 100; i++) 
34200 \newline
34201 \InsetSpace ~
34202 \InsetSpace ~
34203 \InsetSpace ~
34204 \InsetSpace ~
34205 f += itemp;
34206 \end_layout
34207
34208 \begin_layout Standard
34209 As mentioned previously some loop invariants are not as apparent, all static
34210  address computations are also moved out of the loop.
34211 \newline
34212
34213 \newline
34214 Strength Reduction
34215 \begin_inset LatexCommand \index{Strength reduction}
34216
34217 \end_inset
34218
34219 , this optimization substitutes an expression by a cheaper expression:
34220 \end_layout
34221
34222 \begin_layout Verse
34223
34224 \family typewriter
34225 for (i=0;i < 100; i++)
34226 \newline
34227 \InsetSpace ~
34228 \InsetSpace ~
34229 \InsetSpace ~
34230 \InsetSpace ~
34231 ar[i*5] = i*3;
34232 \end_layout
34233
34234 \begin_layout Standard
34235 changed to
34236 \end_layout
34237
34238 \begin_layout Verse
34239
34240 \family typewriter
34241 itemp1 = 0; 
34242 \newline
34243 itemp2 = 0; 
34244 \newline
34245 for (i=0;i< 100;i++) { 
34246 \newline
34247 \InsetSpace ~
34248 \InsetSpace ~
34249 \InsetSpace ~
34250 \InsetSpace ~
34251 ar[itemp1] = itemp2; 
34252 \newline
34253 \InsetSpace ~
34254 \InsetSpace ~
34255 \InsetSpace ~
34256 \InsetSpace ~
34257 itemp1
34258  += 5; 
34259 \newline
34260 \InsetSpace ~
34261 \InsetSpace ~
34262 \InsetSpace ~
34263 \InsetSpace ~
34264 itemp2 += 3; 
34265 \newline
34266 }
34267 \end_layout
34268
34269 \begin_layout Standard
34270 The more expensive multiplication
34271 \begin_inset LatexCommand \index{Multiplication}
34272
34273 \end_inset
34274
34275  is changed to a less expensive addition.
34276 \end_layout
34277
34278 \begin_layout Subsection
34279 Loop Reversing
34280 \begin_inset LatexCommand \index{Loop reversing}
34281
34282 \end_inset
34283
34284
34285 \end_layout
34286
34287 \begin_layout Standard
34288 This optimization is done to reduce the overhead of checking loop boundaries
34289  for every iteration.
34290  Some simple loops can be reversed and implemented using a 
34291 \begin_inset Quotes eld
34292 \end_inset
34293
34294 decrement and jump if not zero
34295 \begin_inset Quotes erd
34296 \end_inset
34297
34298  instruction.
34299  SDCC checks for the following criterion to determine if a loop is reversible
34300  (note: more sophisticated compilers use data-dependency analysis to make
34301  this determination, SDCC uses a more simple minded analysis).
34302 \end_layout
34303
34304 \begin_layout Itemize
34305 The 'for' loop is of the form 
34306 \newline
34307
34308 \newline
34309
34310 \family typewriter
34311 for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
34312  += 1])
34313 \newline
34314 \InsetSpace ~
34315 \InsetSpace ~
34316 \InsetSpace ~
34317 \InsetSpace ~
34318 <for body>
34319 \end_layout
34320
34321 \begin_layout Itemize
34322 The <for body> does not contain 
34323 \begin_inset Quotes eld
34324 \end_inset
34325
34326 continue
34327 \begin_inset Quotes erd
34328 \end_inset
34329
34330  or 'break
34331 \begin_inset Quotes erd
34332 \end_inset
34333
34334 .
34335 \end_layout
34336
34337 \begin_layout Itemize
34338 All goto's are contained within the loop.
34339 \end_layout
34340
34341 \begin_layout Itemize
34342 No function calls within the loop.
34343 \end_layout
34344
34345 \begin_layout Itemize
34346 The loop control variable <sym> is not assigned any value within the loop
34347 \end_layout
34348
34349 \begin_layout Itemize
34350 The loop control variable does NOT participate in any arithmetic operation
34351  within the loop.
34352 \end_layout
34353
34354 \begin_layout Itemize
34355 There are NO switch statements in the loop.
34356 \end_layout
34357
34358 \begin_layout Subsection
34359 Algebraic Simplifications
34360 \end_layout
34361
34362 \begin_layout Standard
34363 SDCC does numerous algebraic simplifications, the following is a small sub-set
34364  of these optimizations.
34365 \end_layout
34366
34367 \begin_layout Verse
34368
34369 \family typewriter
34370 i = j + 0;\InsetSpace ~
34371 \InsetSpace ~
34372 \InsetSpace ~
34373 \InsetSpace ~
34374  /* changed to: */\InsetSpace ~
34375 \InsetSpace ~
34376 \InsetSpace ~
34377 \InsetSpace ~
34378  i = j; 
34379 \newline
34380 i /= 2;\InsetSpace ~
34381 \InsetSpace ~
34382 \InsetSpace ~
34383 \InsetSpace ~
34384 \InsetSpace ~
34385 \InsetSpace ~
34386 \InsetSpace ~
34387  /* changed to: */\InsetSpace ~
34388 \InsetSpace ~
34389 \InsetSpace ~
34390 \InsetSpace ~
34391  i >>= 1; 
34392 \newline
34393 i
34394  = j - j;\InsetSpace ~
34395 \InsetSpace ~
34396 \InsetSpace ~
34397 \InsetSpace ~
34398  /* changed to: */\InsetSpace ~
34399 \InsetSpace ~
34400 \InsetSpace ~
34401 \InsetSpace ~
34402  i = 0; 
34403 \newline
34404 i = j / 1;\InsetSpace ~
34405 \InsetSpace ~
34406 \InsetSpace ~
34407 \InsetSpace ~
34408  /* changed to: */\InsetSpace ~
34409 \InsetSpace ~
34410 \InsetSpace ~
34411 \InsetSpace ~
34412  i = j;
34413 \end_layout
34414
34415 \begin_layout Standard
34416 Note the subexpressions
34417 \begin_inset LatexCommand \index{Subexpression}
34418
34419 \end_inset
34420
34421  given above are generally introduced by macro expansions or as a result
34422  of copy/constant propagation.
34423 \end_layout
34424
34425 \begin_layout Subsection
34426 'switch' Statements
34427 \begin_inset LatexCommand \label{sub:'switch'-Statements}
34428
34429 \end_inset
34430
34431
34432 \begin_inset LatexCommand \index{switch statement}
34433
34434 \end_inset
34435
34436
34437 \end_layout
34438
34439 \begin_layout Standard
34440 SDCC can optimize switch statements to jump tables
34441 \begin_inset LatexCommand \index{jump tables}
34442
34443 \end_inset
34444
34445 .
34446  It makes the decision based on an estimate of the generated code size.
34447  SDCC is quite liberal in the requirements for jump table generation: 
34448 \end_layout
34449
34450 \begin_layout Itemize
34451 The labels need not be in order, and the starting number need not be one
34452  or zero, the case labels are in numerical sequence or not too many case
34453  labels are missing.
34454 \end_layout
34455
34456 \begin_deeper
34457 \begin_layout Verse
34458
34459 \family typewriter
34460 switch(i) {\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 \InsetSpace ~
34483 \InsetSpace ~
34484 \InsetSpace ~
34485 \InsetSpace ~
34486 switch (i) { 
34487 \newline
34488 \InsetSpace ~
34489 \InsetSpace ~
34490 \InsetSpace ~
34491 case 4: ...\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 \InsetSpace ~
34514 \InsetSpace ~
34515 \InsetSpace ~
34516 \InsetSpace ~
34517 case 0: ...
34518  
34519 \newline
34520 \InsetSpace ~
34521 \InsetSpace ~
34522 \InsetSpace ~
34523 case 5: ...\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 \InsetSpace ~
34546 \InsetSpace ~
34547 \InsetSpace ~
34548 \InsetSpace ~
34549 case 1: ...
34550  
34551 \newline
34552 \InsetSpace ~
34553 \InsetSpace ~
34554 \InsetSpace ~
34555 case 3: ...\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 \InsetSpace ~
34578 \InsetSpace ~
34579 \InsetSpace ~
34580 \InsetSpace ~
34581
34582 \newline
34583 \InsetSpace ~
34584 \InsetSpace ~
34585 \InsetSpace ~
34586 case 6: ...\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 \InsetSpace ~
34609 \InsetSpace ~
34610 \InsetSpace ~
34611 \InsetSpace ~
34612 case 3: ...
34613  
34614 \newline
34615 \InsetSpace ~
34616 \InsetSpace ~
34617 \InsetSpace ~
34618 case 7: ...\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 \InsetSpace ~
34641 \InsetSpace ~
34642 \InsetSpace ~
34643 \InsetSpace ~
34644 case 4: ...
34645  
34646 \newline
34647 \InsetSpace ~
34648 \InsetSpace ~
34649 \InsetSpace ~
34650 case 8: ...\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 \InsetSpace ~
34673 \InsetSpace ~
34674 \InsetSpace ~
34675 \InsetSpace ~
34676 case 5: ...
34677  
34678 \newline
34679 \InsetSpace ~
34680 \InsetSpace ~
34681 \InsetSpace ~
34682 case 9: ...\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 \InsetSpace ~
34705 \InsetSpace ~
34706 \InsetSpace ~
34707 \InsetSpace ~
34708 case 6: ...
34709  
34710 \newline
34711 \InsetSpace ~
34712 \InsetSpace ~
34713 \InsetSpace ~
34714 case 10: ...\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 \InsetSpace ~
34736 \InsetSpace ~
34737 \InsetSpace ~
34738 \InsetSpace ~
34739 case 7: ...
34740  
34741 \newline
34742 \InsetSpace ~
34743 \InsetSpace ~
34744 \InsetSpace ~
34745 case 11: ...\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 \InsetSpace ~
34767 \InsetSpace ~
34768 \InsetSpace ~
34769 \InsetSpace ~
34770 case 8: ...
34771  
34772 \newline
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 \InsetSpace ~
34806 \InsetSpace ~
34807 \InsetSpace ~
34808 \InsetSpace ~
34809 }
34810 \end_layout
34811
34812 \begin_layout Standard
34813 Both the above switch statements will be implemented using a jump-table.
34814  The example to the right side is slightly more efficient as the check for
34815  the lower boundary of the jump-table is not needed.
34816 \end_layout
34817
34818 \end_deeper
34819 \begin_layout Itemize
34820 The number of case labels is not larger than supported by the target architectur
34821 e.
34822 \end_layout
34823
34824 \begin_layout Itemize
34825 If the case labels are not in numerical sequence ('gaps' between cases)
34826  SDCC checks whether a jump table with additionally inserted dummy cases
34827  is still attractive.
34828  
34829 \end_layout
34830
34831 \begin_layout Itemize
34832 If the starting number is not zero and a check for the lower boundary of
34833  the jump-table can thus be eliminated SDCC might insert dummy cases 0,
34834  ...
34835  .
34836 \end_layout
34837
34838 \begin_layout Standard
34839 Switch statements which have large gaps in the numeric sequence or those
34840  that have too many case labels can be split into more than one switch statement
34841  for efficient code generation, e.g.:
34842 \end_layout
34843
34844 \begin_layout Verse
34845
34846 \family typewriter
34847 switch (i) { 
34848 \newline
34849 \InsetSpace ~
34850 \InsetSpace ~
34851 case 1: ...
34852  
34853 \newline
34854 \InsetSpace ~
34855 \InsetSpace ~
34856 case 2: ...
34857  
34858 \newline
34859 \InsetSpace ~
34860 \InsetSpace ~
34861 case 3: ...
34862  
34863 \newline
34864 \InsetSpace ~
34865 \InsetSpace ~
34866 case 4: ...
34867  
34868 \newline
34869 \InsetSpace ~
34870 \InsetSpace ~
34871 case 5: ...
34872  
34873 \newline
34874 \InsetSpace ~
34875 \InsetSpace ~
34876 case 6: ...
34877  
34878 \newline
34879 \InsetSpace ~
34880 \InsetSpace ~
34881 case 7: ...
34882  
34883 \newline
34884 \InsetSpace ~
34885 \InsetSpace ~
34886 case 101: ...
34887  
34888 \newline
34889 \InsetSpace ~
34890 \InsetSpace ~
34891 case 102: ...
34892  
34893 \newline
34894 \InsetSpace ~
34895 \InsetSpace ~
34896 case 103: ...
34897  
34898 \newline
34899 \InsetSpace ~
34900 \InsetSpace ~
34901 case 104: ...
34902  
34903 \newline
34904 \InsetSpace ~
34905 \InsetSpace ~
34906 case 105: ...
34907  
34908 \newline
34909 \InsetSpace ~
34910 \InsetSpace ~
34911 case 106: ...
34912  
34913 \newline
34914 \InsetSpace ~
34915 \InsetSpace ~
34916 case 107: ...
34917  
34918 \newline
34919 }
34920 \end_layout
34921
34922 \begin_layout Standard
34923 If the above switch statement is broken down into two switch statements
34924 \end_layout
34925
34926 \begin_layout Verse
34927
34928 \family typewriter
34929 switch (i) { 
34930 \newline
34931 \InsetSpace ~
34932 \InsetSpace ~
34933 case 1: ...
34934  
34935 \newline
34936 \InsetSpace ~
34937 \InsetSpace ~
34938 case 2: ...
34939  
34940 \newline
34941 \InsetSpace ~
34942 \InsetSpace ~
34943 case 3: ...
34944  
34945 \newline
34946 \InsetSpace ~
34947 \InsetSpace ~
34948 case 4: ...
34949  
34950 \newline
34951 \InsetSpace ~
34952 \InsetSpace ~
34953 case 5: ...
34954  
34955 \newline
34956 \InsetSpace ~
34957 \InsetSpace ~
34958 case 6: ...
34959  
34960 \newline
34961 \InsetSpace ~
34962 \InsetSpace ~
34963 case 7: ...
34964  
34965 \newline
34966 }
34967 \end_layout
34968
34969 \begin_layout Standard
34970 and
34971 \end_layout
34972
34973 \begin_layout Verse
34974
34975 \family typewriter
34976 switch (i) { 
34977 \newline
34978 \InsetSpace ~
34979 \InsetSpace ~
34980 case 101: ...
34981  
34982 \newline
34983 \InsetSpace ~
34984 \InsetSpace ~
34985 case 102: ...
34986  
34987 \newline
34988 \InsetSpace ~
34989 \InsetSpace ~
34990 case 103: ...
34991  
34992 \newline
34993 \InsetSpace ~
34994 \InsetSpace ~
34995 case 104: ...
34996  
34997 \newline
34998 \InsetSpace ~
34999 \InsetSpace ~
35000 case 105: ...
35001  
35002 \newline
35003 \InsetSpace ~
35004 \InsetSpace ~
35005 case 106: ...
35006  
35007 \newline
35008 \InsetSpace ~
35009 \InsetSpace ~
35010 case 107: ...
35011  
35012 \newline
35013 }
35014 \end_layout
35015
35016 \begin_layout Standard
35017 then both the switch statements will be implemented using jump-tables whereas
35018  the unmodified switch statement will not be.
35019 \end_layout
35020
35021 \begin_layout Standard
35022 \begin_inset Note Note
35023 status collapsed
35024
35025 \begin_layout Standard
35026 There might be reasons which SDCC cannot know about to either favour or
35027  not favour jump tables.
35028  If the target system has to be as quick for the last switch case as for
35029  the first (pro jump table), or if the switch argument is known to be zero
35030  in the majority of the cases (contra jump table).
35031 \end_layout
35032
35033 \end_inset
35034
35035
35036 \end_layout
35037
35038 \begin_layout Standard
35039 The pragma nojtbound
35040 \begin_inset LatexCommand \index{\#pragma nojtbound}
35041
35042 \end_inset
35043
35044  can be used to turn off checking the 
35045 \emph on
35046 j
35047 \emph default
35048 ump 
35049 \emph on
35050 t
35051 \emph default
35052 able 
35053 \emph on
35054 bound
35055 \emph default
35056 aries.
35057  It has no effect if a default label is supplied.
35058  Use of this pragma is dangerous: if the switch
35059 \begin_inset LatexCommand \index{switch statement}
35060
35061 \end_inset
35062
35063  argument is not matched by a case statement the processor will happily
35064  jump into Nirvana.
35065 \end_layout
35066
35067 \begin_layout Subsection
35068 Bit-shifting Operations
35069 \begin_inset LatexCommand \index{Bit shifting}
35070
35071 \end_inset
35072
35073 .
35074 \end_layout
35075
35076 \begin_layout Standard
35077 Bit shifting is one of the most frequently used operation in embedded programmin
35078 g.
35079  SDCC tries to implement bit-shift operations in the most efficient way
35080  possible, e.g.:
35081 \end_layout
35082
35083 \begin_layout Verse
35084
35085 \family typewriter
35086 unsigned char i;
35087 \newline
35088 ...
35089  
35090 \newline
35091 i >>= 4; 
35092 \newline
35093 ...
35094 \end_layout
35095
35096 \begin_layout Standard
35097 generates the following code:
35098 \end_layout
35099
35100 \begin_layout Verse
35101
35102 \family typewriter
35103 mov\InsetSpace ~
35104  a,_i 
35105 \newline
35106 swap a 
35107 \newline
35108 anl\InsetSpace ~
35109  a,#0x0f 
35110 \newline
35111 mov\InsetSpace ~
35112  _i,a
35113 \end_layout
35114
35115 \begin_layout Standard
35116 In general SDCC will never setup a loop if the shift count is known.
35117  Another example:
35118 \end_layout
35119
35120 \begin_layout Verse
35121
35122 \family typewriter
35123 unsigned int i; 
35124 \newline
35125 ...
35126  
35127 \newline
35128 i >>= 9; 
35129 \newline
35130 ...
35131 \end_layout
35132
35133 \begin_layout Standard
35134 will generate:
35135 \end_layout
35136
35137 \begin_layout Verse
35138
35139 \family typewriter
35140 mov\InsetSpace ~
35141 \InsetSpace ~
35142 a,(_i + 1) 
35143 \newline
35144 mov\InsetSpace ~
35145 \InsetSpace ~
35146 (_i + 1),#0x00 
35147 \newline
35148 clr\InsetSpace ~
35149 \InsetSpace ~
35150
35151 \newline
35152 rrc\InsetSpace ~
35153 \InsetSpace ~
35154
35155 \newline
35156 mov\InsetSpace ~
35157 \InsetSpace ~
35158 _i,a
35159 \end_layout
35160
35161 \begin_layout Subsection
35162 Bit-rotation
35163 \begin_inset LatexCommand \index{Bit rotation}
35164
35165 \end_inset
35166
35167
35168 \end_layout
35169
35170 \begin_layout Standard
35171 A special case of the bit-shift operation is bit rotation
35172 \begin_inset LatexCommand \index{rotating bits}
35173
35174 \end_inset
35175
35176 , SDCC recognizes the following expression to be a left bit-rotation:
35177 \end_layout
35178
35179 \begin_layout Verse
35180
35181 \family typewriter
35182 \series bold
35183 unsigned
35184 \series default
35185 \InsetSpace ~
35186 \InsetSpace ~
35187 char i;\InsetSpace ~
35188 \InsetSpace ~
35189 \InsetSpace ~
35190 \InsetSpace ~
35191 \InsetSpace ~
35192 \InsetSpace ~
35193 \InsetSpace ~
35194 \InsetSpace ~
35195 \InsetSpace ~
35196 \InsetSpace ~
35197 \InsetSpace ~
35198 /* unsigned is needed for rotation */ 
35199 \newline
35200 ...
35201  
35202 \newline
35203 i = ((i << 1) | (i >> 7)); 
35204 \family default
35205
35206 \newline
35207
35208 \family typewriter
35209 ...
35210 \end_layout
35211
35212 \begin_layout Standard
35213 will generate the following code:
35214 \end_layout
35215
35216 \begin_layout Verse
35217
35218 \family typewriter
35219 mov\InsetSpace ~
35220 \InsetSpace ~
35221 a,_i 
35222 \newline
35223 rl\InsetSpace ~
35224 \InsetSpace ~
35225 \InsetSpace ~
35226
35227 \newline
35228 mov\InsetSpace ~
35229 \InsetSpace ~
35230 _i,a
35231 \end_layout
35232
35233 \begin_layout Standard
35234 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
35235 ns of this case will also be recognized as bit-rotation, i.e.: 
35236 \end_layout
35237
35238 \begin_layout Verse
35239
35240 \family typewriter
35241 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
35242 \end_layout
35243
35244 \begin_layout Subsection
35245 Nibble and Byte Swapping
35246 \end_layout
35247
35248 \begin_layout Standard
35249 Other special cases of the bit-shift operations are nibble or byte swapping
35250 \begin_inset LatexCommand \index{swapping nibbles/bytes}
35251
35252 \end_inset
35253
35254 , SDCC recognizes the following expressions:
35255 \end_layout
35256
35257 \begin_layout Verse
35258
35259 \family typewriter
35260 \series bold
35261 unsigned
35262 \series default
35263 \InsetSpace ~
35264 \InsetSpace ~
35265 char i; 
35266 \newline
35267
35268 \series bold
35269 unsigned
35270 \series default
35271 \InsetSpace ~
35272 \InsetSpace ~
35273 int j; 
35274 \newline
35275 ...
35276  
35277 \newline
35278 i = ((i << 4) | (i >> 4)); 
35279 \family default
35280
35281 \newline
35282
35283 \family typewriter
35284 j = ((j << 8) | (j >> 8)); 
35285 \end_layout
35286
35287 \begin_layout Standard
35288 and generates a swap instruction for the nibble swapping
35289 \begin_inset LatexCommand \index{Nibble swapping}
35290
35291 \end_inset
35292
35293  or move instructions for the byte swapping
35294 \begin_inset LatexCommand \index{Byte swapping}
35295
35296 \end_inset
35297
35298 .
35299  The 
35300 \begin_inset Quotes sld
35301 \end_inset
35302
35303 j
35304 \begin_inset Quotes srd
35305 \end_inset
35306
35307  example can be used to convert from little to big-endian or vice versa.
35308  If you want to change the endianness of a 
35309 \emph on
35310 signed
35311 \emph default
35312  integer you have to cast to 
35313 \family typewriter
35314 (unsigned int)
35315 \family default
35316  first.
35317 \end_layout
35318
35319 \begin_layout Standard
35320 Note that SDCC stores numbers in little-endian
35321 \begin_inset Foot
35322 status open
35323
35324 \begin_layout Standard
35325 Usually 8-bit processors don't care much about endianness.
35326  This is not the case for the standard 8051 which only has an instruction
35327  to increment its 
35328 \emph on
35329 dptr
35330 \emph default
35331
35332 \begin_inset LatexCommand \index{DPTR}
35333
35334 \end_inset
35335
35336 -datapointer
35337 \emph on
35338  
35339 \emph default
35340 so little-endian is the more efficient byte order.
35341 \end_layout
35342
35343 \end_inset
35344
35345
35346 \begin_inset LatexCommand \index{little-endian}
35347
35348 \end_inset
35349
35350
35351 \begin_inset LatexCommand \index{Endianness}
35352
35353 \end_inset
35354
35355  format (i.e.
35356  lowest order first).
35357 \end_layout
35358
35359 \begin_layout Subsection
35360 Highest Order Bit
35361 \begin_inset LatexCommand \index{Highest Order Bit}
35362
35363 \end_inset
35364
35365  / Any Order Bit
35366 \begin_inset LatexCommand \index{Any Order Bit}
35367
35368 \end_inset
35369
35370
35371 \end_layout
35372
35373 \begin_layout Standard
35374 It is frequently required to obtain the highest order bit of an integral
35375  type (long, int, short or char types).
35376  Also obtaining any other order bit is not uncommon.
35377  SDCC recognizes the following expressions to yield the highest order bit
35378  and generates optimized code for it, e.g.:
35379 \end_layout
35380
35381 \begin_layout Verse
35382
35383 \family typewriter
35384 unsigned int gint; 
35385 \newline
35386
35387 \newline
35388 foo () { 
35389 \newline
35390 \InsetSpace ~
35391 \InsetSpace ~
35392 unsigned char hob1, aob1; 
35393 \newline
35394 \InsetSpace ~
35395 \InsetSpace ~
35396 bit hob2, hob3, aob2,
35397  aob3; 
35398 \newline
35399 \InsetSpace ~
35400 \InsetSpace ~
35401 ...
35402  
35403 \newline
35404 \InsetSpace ~
35405 \InsetSpace ~
35406 hob1 = (gint >> 15) & 1; 
35407 \newline
35408 \InsetSpace ~
35409 \InsetSpace ~
35410 hob2 = (gint >> 15) & 1; 
35411 \newline
35412 \InsetSpace ~
35413 \InsetSpace ~
35414 hob3 = gint & 0x8000;
35415  
35416 \newline
35417 \InsetSpace ~
35418 \InsetSpace ~
35419 aob1 = (gint >> 9) & 1; 
35420 \newline
35421 \InsetSpace ~
35422 \InsetSpace ~
35423 aob2 = (gint >> 8) & 1; 
35424 \newline
35425 \InsetSpace ~
35426 \InsetSpace ~
35427 aob3 = gint & 0x0800; 
35428 \newline
35429 \InsetSpace ~
35430 \InsetSpace ~
35431 ..
35432  
35433 \newline
35434 }
35435 \end_layout
35436
35437 \begin_layout Standard
35438 will generate the following code:
35439 \end_layout
35440
35441 \begin_layout Verse
35442
35443 \family typewriter
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 \InsetSpace ~
35466 \InsetSpace ~
35467 \InsetSpace ~
35468 \InsetSpace ~
35469  61 ;\InsetSpace ~
35470  hob.c 7 
35471 \newline
35472 000A E5*01\InsetSpace ~
35473 \InsetSpace ~
35474 \InsetSpace ~
35475 \InsetSpace ~
35476 \InsetSpace ~
35477 \InsetSpace ~
35478 \InsetSpace ~
35479 \InsetSpace ~
35480 \InsetSpace ~
35481 \InsetSpace ~
35482 \InsetSpace ~
35483 \InsetSpace ~
35484 \InsetSpace ~
35485 \InsetSpace ~
35486 \InsetSpace ~
35487  62\InsetSpace ~
35488 \InsetSpace ~
35489 \InsetSpace ~
35490 \InsetSpace ~
35491 \InsetSpace ~
35492 \InsetSpace ~
35493 \InsetSpace ~
35494 \InsetSpace ~
35495  mov\InsetSpace ~
35496 \InsetSpace ~
35497  a,(_gint + 1) 
35498 \newline
35499 000C 23\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 \InsetSpace ~
35514 \InsetSpace ~
35515 \InsetSpace ~
35516 \InsetSpace ~
35517  63\InsetSpace ~
35518 \InsetSpace ~
35519 \InsetSpace ~
35520 \InsetSpace ~
35521 \InsetSpace ~
35522 \InsetSpace ~
35523 \InsetSpace ~
35524 \InsetSpace ~
35525  rl\InsetSpace ~
35526 \InsetSpace ~
35527 \InsetSpace ~
35528  a 
35529 \newline
35530 000D 54 01\InsetSpace ~
35531 \InsetSpace ~
35532 \InsetSpace ~
35533 \InsetSpace ~
35534 \InsetSpace ~
35535 \InsetSpace ~
35536 \InsetSpace ~
35537 \InsetSpace ~
35538 \InsetSpace ~
35539 \InsetSpace ~
35540 \InsetSpace ~
35541 \InsetSpace ~
35542 \InsetSpace ~
35543 \InsetSpace ~
35544 \InsetSpace ~
35545
35546  64\InsetSpace ~
35547 \InsetSpace ~
35548 \InsetSpace ~
35549 \InsetSpace ~
35550 \InsetSpace ~
35551 \InsetSpace ~
35552 \InsetSpace ~
35553 \InsetSpace ~
35554  anl\InsetSpace ~
35555 \InsetSpace ~
35556  a,#0x01 
35557 \newline
35558 000F F5*02\InsetSpace ~
35559 \InsetSpace ~
35560 \InsetSpace ~
35561 \InsetSpace ~
35562 \InsetSpace ~
35563 \InsetSpace ~
35564 \InsetSpace ~
35565 \InsetSpace ~
35566 \InsetSpace ~
35567 \InsetSpace ~
35568 \InsetSpace ~
35569 \InsetSpace ~
35570 \InsetSpace ~
35571 \InsetSpace ~
35572 \InsetSpace ~
35573  65\InsetSpace ~
35574 \InsetSpace ~
35575 \InsetSpace ~
35576 \InsetSpace ~
35577 \InsetSpace ~
35578 \InsetSpace ~
35579 \InsetSpace ~
35580 \InsetSpace ~
35581  mov\InsetSpace ~
35582 \InsetSpace ~
35583  _foo_hob1_1_1,a 
35584 \newline
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 \InsetSpace ~
35607 \InsetSpace ~
35608 \InsetSpace ~
35609 \InsetSpace ~
35610  66 ;\InsetSpace ~
35611  hob.c 8 
35612 \newline
35613 0011 E5*01\InsetSpace ~
35614 \InsetSpace ~
35615 \InsetSpace ~
35616 \InsetSpace ~
35617 \InsetSpace ~
35618 \InsetSpace ~
35619 \InsetSpace ~
35620 \InsetSpace ~
35621 \InsetSpace ~
35622 \InsetSpace ~
35623 \InsetSpace ~
35624 \InsetSpace ~
35625 \InsetSpace ~
35626 \InsetSpace ~
35627 \InsetSpace ~
35628
35629  67\InsetSpace ~
35630 \InsetSpace ~
35631 \InsetSpace ~
35632 \InsetSpace ~
35633 \InsetSpace ~
35634 \InsetSpace ~
35635 \InsetSpace ~
35636 \InsetSpace ~
35637  mov\InsetSpace ~
35638 \InsetSpace ~
35639  a,(_gint + 1) 
35640 \newline
35641 0013 33\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 \InsetSpace ~
35656 \InsetSpace ~
35657 \InsetSpace ~
35658 \InsetSpace ~
35659  68\InsetSpace ~
35660 \InsetSpace ~
35661 \InsetSpace ~
35662 \InsetSpace ~
35663 \InsetSpace ~
35664 \InsetSpace ~
35665 \InsetSpace ~
35666 \InsetSpace ~
35667  rlc\InsetSpace ~
35668 \InsetSpace ~
35669  a 
35670 \newline
35671 0014 92*00\InsetSpace ~
35672 \InsetSpace ~
35673 \InsetSpace ~
35674 \InsetSpace ~
35675 \InsetSpace ~
35676 \InsetSpace ~
35677 \InsetSpace ~
35678 \InsetSpace ~
35679 \InsetSpace ~
35680 \InsetSpace ~
35681 \InsetSpace ~
35682 \InsetSpace ~
35683 \InsetSpace ~
35684 \InsetSpace ~
35685 \InsetSpace ~
35686  69\InsetSpace ~
35687 \InsetSpace ~
35688 \InsetSpace ~
35689 \InsetSpace ~
35690 \InsetSpace ~
35691 \InsetSpace ~
35692 \InsetSpace ~
35693 \InsetSpace ~
35694  mov\InsetSpace ~
35695 \InsetSpace ~
35696  _foo_hob2_1_1,c
35697  
35698 \newline
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 \InsetSpace ~
35721 \InsetSpace ~
35722 \InsetSpace ~
35723 \InsetSpace ~
35724  66 ;\InsetSpace ~
35725  hob.c 9 
35726 \newline
35727 0016 E5*01\InsetSpace ~
35728 \InsetSpace ~
35729 \InsetSpace ~
35730 \InsetSpace ~
35731 \InsetSpace ~
35732 \InsetSpace ~
35733 \InsetSpace ~
35734 \InsetSpace ~
35735 \InsetSpace ~
35736 \InsetSpace ~
35737 \InsetSpace ~
35738 \InsetSpace ~
35739 \InsetSpace ~
35740 \InsetSpace ~
35741 \InsetSpace ~
35742  67\InsetSpace ~
35743 \InsetSpace ~
35744 \InsetSpace ~
35745 \InsetSpace ~
35746 \InsetSpace ~
35747 \InsetSpace ~
35748 \InsetSpace ~
35749 \InsetSpace ~
35750  mov\InsetSpace ~
35751 \InsetSpace ~
35752  a,(_gint + 1) 
35753 \newline
35754 0018 33\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 \InsetSpace ~
35769 \InsetSpace ~
35770 \InsetSpace ~
35771 \InsetSpace ~
35772  68\InsetSpace ~
35773 \InsetSpace ~
35774 \InsetSpace ~
35775 \InsetSpace ~
35776 \InsetSpace ~
35777 \InsetSpace ~
35778 \InsetSpace ~
35779 \InsetSpace ~
35780  rlc\InsetSpace ~
35781 \InsetSpace ~
35782  a 
35783 \newline
35784 0019 92*01\InsetSpace ~
35785 \InsetSpace ~
35786 \InsetSpace ~
35787 \InsetSpace ~
35788 \InsetSpace ~
35789 \InsetSpace ~
35790 \InsetSpace ~
35791 \InsetSpace ~
35792 \InsetSpace ~
35793 \InsetSpace ~
35794 \InsetSpace ~
35795 \InsetSpace ~
35796 \InsetSpace ~
35797 \InsetSpace ~
35798 \InsetSpace ~
35799
35800  69\InsetSpace ~
35801 \InsetSpace ~
35802 \InsetSpace ~
35803 \InsetSpace ~
35804 \InsetSpace ~
35805 \InsetSpace ~
35806 \InsetSpace ~
35807 \InsetSpace ~
35808  mov\InsetSpace ~
35809 \InsetSpace ~
35810  _foo_hob3_1_1,c 
35811 \newline
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 \InsetSpace ~
35834 \InsetSpace ~
35835 \InsetSpace ~
35836 \InsetSpace ~
35837  70 ;\InsetSpace ~
35838  hob.c 10 
35839 \newline
35840 001B E5*01\InsetSpace ~
35841 \InsetSpace ~
35842 \InsetSpace ~
35843 \InsetSpace ~
35844 \InsetSpace ~
35845 \InsetSpace ~
35846 \InsetSpace ~
35847 \InsetSpace ~
35848 \InsetSpace ~
35849 \InsetSpace ~
35850 \InsetSpace ~
35851 \InsetSpace ~
35852 \InsetSpace ~
35853 \InsetSpace ~
35854 \InsetSpace ~
35855  71\InsetSpace ~
35856 \InsetSpace ~
35857 \InsetSpace ~
35858 \InsetSpace ~
35859 \InsetSpace ~
35860 \InsetSpace ~
35861 \InsetSpace ~
35862 \InsetSpace ~
35863  mov\InsetSpace ~
35864 \InsetSpace ~
35865  a,(_gint + 1) 
35866 \newline
35867 001D
35868  03\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 \InsetSpace ~
35883 \InsetSpace ~
35884 \InsetSpace ~
35885 \InsetSpace ~
35886  72\InsetSpace ~
35887 \InsetSpace ~
35888 \InsetSpace ~
35889 \InsetSpace ~
35890 \InsetSpace ~
35891 \InsetSpace ~
35892 \InsetSpace ~
35893 \InsetSpace ~
35894  rr\InsetSpace ~
35895 \InsetSpace ~
35896 \InsetSpace ~
35897  a 
35898 \newline
35899 001E 54 01\InsetSpace ~
35900 \InsetSpace ~
35901 \InsetSpace ~
35902 \InsetSpace ~
35903 \InsetSpace ~
35904 \InsetSpace ~
35905 \InsetSpace ~
35906 \InsetSpace ~
35907 \InsetSpace ~
35908 \InsetSpace ~
35909 \InsetSpace ~
35910 \InsetSpace ~
35911 \InsetSpace ~
35912 \InsetSpace ~
35913 \InsetSpace ~
35914  73\InsetSpace ~
35915 \InsetSpace ~
35916 \InsetSpace ~
35917 \InsetSpace ~
35918 \InsetSpace ~
35919 \InsetSpace ~
35920 \InsetSpace ~
35921 \InsetSpace ~
35922  anl\InsetSpace ~
35923 \InsetSpace ~
35924  a,#0x01 
35925 \newline
35926 0020 F5*03\InsetSpace ~
35927 \InsetSpace ~
35928 \InsetSpace ~
35929 \InsetSpace ~
35930 \InsetSpace ~
35931 \InsetSpace ~
35932 \InsetSpace ~
35933 \InsetSpace ~
35934 \InsetSpace ~
35935 \InsetSpace ~
35936 \InsetSpace ~
35937 \InsetSpace ~
35938 \InsetSpace ~
35939 \InsetSpace ~
35940 \InsetSpace ~
35941  74\InsetSpace ~
35942 \InsetSpace ~
35943 \InsetSpace ~
35944 \InsetSpace ~
35945 \InsetSpace ~
35946 \InsetSpace ~
35947 \InsetSpace ~
35948 \InsetSpace ~
35949  mov\InsetSpace ~
35950 \InsetSpace ~
35951  _foo_aob1_1_1,a
35952  
35953 \newline
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 \InsetSpace ~
35976 \InsetSpace ~
35977 \InsetSpace ~
35978 \InsetSpace ~
35979  75 ;\InsetSpace ~
35980  hob.c 11 
35981 \newline
35982 0022 E5*01\InsetSpace ~
35983 \InsetSpace ~
35984 \InsetSpace ~
35985 \InsetSpace ~
35986 \InsetSpace ~
35987 \InsetSpace ~
35988 \InsetSpace ~
35989 \InsetSpace ~
35990 \InsetSpace ~
35991 \InsetSpace ~
35992 \InsetSpace ~
35993 \InsetSpace ~
35994 \InsetSpace ~
35995 \InsetSpace ~
35996 \InsetSpace ~
35997  76\InsetSpace ~
35998 \InsetSpace ~
35999 \InsetSpace ~
36000 \InsetSpace ~
36001 \InsetSpace ~
36002 \InsetSpace ~
36003 \InsetSpace ~
36004 \InsetSpace ~
36005  mov\InsetSpace ~
36006 \InsetSpace ~
36007  a,(_gint + 1) 
36008 \newline
36009 0024 13\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 \InsetSpace ~
36024 \InsetSpace ~
36025 \InsetSpace ~
36026 \InsetSpace ~
36027  77\InsetSpace ~
36028 \InsetSpace ~
36029 \InsetSpace ~
36030 \InsetSpace ~
36031 \InsetSpace ~
36032 \InsetSpace ~
36033 \InsetSpace ~
36034 \InsetSpace ~
36035  rrc\InsetSpace ~
36036 \InsetSpace ~
36037  a 
36038 \newline
36039 0025 92*02\InsetSpace ~
36040 \InsetSpace ~
36041 \InsetSpace ~
36042 \InsetSpace ~
36043 \InsetSpace ~
36044 \InsetSpace ~
36045 \InsetSpace ~
36046 \InsetSpace ~
36047 \InsetSpace ~
36048 \InsetSpace ~
36049 \InsetSpace ~
36050 \InsetSpace ~
36051 \InsetSpace ~
36052 \InsetSpace ~
36053 \InsetSpace ~
36054
36055  78\InsetSpace ~
36056 \InsetSpace ~
36057 \InsetSpace ~
36058 \InsetSpace ~
36059 \InsetSpace ~
36060 \InsetSpace ~
36061 \InsetSpace ~
36062 \InsetSpace ~
36063  mov\InsetSpace ~
36064 \InsetSpace ~
36065  _foo_aob2_1_1,c 
36066 \newline
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 \InsetSpace ~
36089 \InsetSpace ~
36090 \InsetSpace ~
36091 \InsetSpace ~
36092  79 ;\InsetSpace ~
36093  hob.c 12 
36094 \newline
36095 0027 E5*01\InsetSpace ~
36096 \InsetSpace ~
36097 \InsetSpace ~
36098 \InsetSpace ~
36099 \InsetSpace ~
36100 \InsetSpace ~
36101 \InsetSpace ~
36102 \InsetSpace ~
36103 \InsetSpace ~
36104 \InsetSpace ~
36105 \InsetSpace ~
36106 \InsetSpace ~
36107 \InsetSpace ~
36108 \InsetSpace ~
36109 \InsetSpace ~
36110  80\InsetSpace ~
36111 \InsetSpace ~
36112 \InsetSpace ~
36113 \InsetSpace ~
36114 \InsetSpace ~
36115 \InsetSpace ~
36116 \InsetSpace ~
36117 \InsetSpace ~
36118  mov\InsetSpace ~
36119 \InsetSpace ~
36120  a,(_gint + 1) 
36121 \newline
36122 0029
36123  A2 E3\InsetSpace ~
36124 \InsetSpace ~
36125 \InsetSpace ~
36126 \InsetSpace ~
36127 \InsetSpace ~
36128 \InsetSpace ~
36129 \InsetSpace ~
36130 \InsetSpace ~
36131 \InsetSpace ~
36132 \InsetSpace ~
36133 \InsetSpace ~
36134 \InsetSpace ~
36135 \InsetSpace ~
36136 \InsetSpace ~
36137 \InsetSpace ~
36138  81\InsetSpace ~
36139 \InsetSpace ~
36140 \InsetSpace ~
36141 \InsetSpace ~
36142 \InsetSpace ~
36143 \InsetSpace ~
36144 \InsetSpace ~
36145 \InsetSpace ~
36146  mov\InsetSpace ~
36147 \InsetSpace ~
36148  c,acc[3] 
36149 \newline
36150 002B 92*03\InsetSpace ~
36151 \InsetSpace ~
36152 \InsetSpace ~
36153 \InsetSpace ~
36154 \InsetSpace ~
36155 \InsetSpace ~
36156 \InsetSpace ~
36157 \InsetSpace ~
36158 \InsetSpace ~
36159 \InsetSpace ~
36160 \InsetSpace ~
36161 \InsetSpace ~
36162 \InsetSpace ~
36163 \InsetSpace ~
36164 \InsetSpace ~
36165  82\InsetSpace ~
36166 \InsetSpace ~
36167 \InsetSpace ~
36168 \InsetSpace ~
36169 \InsetSpace ~
36170 \InsetSpace ~
36171 \InsetSpace ~
36172 \InsetSpace ~
36173  mov\InsetSpace ~
36174 \InsetSpace ~
36175  _foo_aob3_1_1,c 
36176 \end_layout
36177
36178 \begin_layout Standard
36179 Other variations of these cases however will 
36180 \emph on
36181 not
36182 \emph default
36183  be recognized.
36184  They are standard C expressions, so I heartily recommend these be the only
36185  way to get the highest order bit, (it is portable).
36186  Of course it will be recognized even if it is embedded in other expressions,
36187  e.g.:
36188 \end_layout
36189
36190 \begin_layout Verse
36191
36192 \family typewriter
36193 xyz = gint + ((gint >> 15) & 1);
36194 \end_layout
36195
36196 \begin_layout Standard
36197 will still be recognized.
36198 \end_layout
36199
36200 \begin_layout Subsection
36201 Higher Order Byte
36202 \begin_inset LatexCommand \index{Higher Order Byte}
36203
36204 \end_inset
36205
36206  / Higher Order Word
36207 \begin_inset LatexCommand \index{Higher Order Word}
36208
36209 \end_inset
36210
36211
36212 \end_layout
36213
36214 \begin_layout Standard
36215 It is also frequently required to obtain a higher order byte or word of
36216  a larger integral type (long, int or short types).
36217  SDCC recognizes the following expressions to yield the higher order byte
36218  or word and generates optimized code for it, e.g.:
36219 \end_layout
36220
36221 \begin_layout Verse
36222
36223 \family typewriter
36224 unsigned int gint; 
36225 \newline
36226 unsigned long int glong; 
36227 \newline
36228
36229 \newline
36230 foo () { 
36231 \newline
36232 \InsetSpace ~
36233 \InsetSpace ~
36234 unsigned char hob1,
36235  hob2; 
36236 \newline
36237 \InsetSpace ~
36238 \InsetSpace ~
36239 unsigned int how1, how2; 
36240 \newline
36241 \InsetSpace ~
36242 \InsetSpace ~
36243 ...
36244  
36245 \newline
36246 \InsetSpace ~
36247 \InsetSpace ~
36248 hob1 = (gint >> 8) & 0xFF; 
36249 \newline
36250 \InsetSpace ~
36251 \InsetSpace ~
36252 hob2 = glong >> 24; 
36253 \newline
36254 \InsetSpace ~
36255 \InsetSpace ~
36256 how1 = (glong >> 16) & 0xFFFF;
36257  
36258 \newline
36259 \InsetSpace ~
36260 \InsetSpace ~
36261 how2 = glong >> 8; 
36262 \newline
36263 \InsetSpace ~
36264 \InsetSpace ~
36265 ..
36266  
36267 \newline
36268 }
36269 \end_layout
36270
36271 \begin_layout Standard
36272 will generate the following code:
36273 \end_layout
36274
36275 \begin_layout Verse
36276
36277 \family typewriter
36278 \InsetSpace ~
36279 \InsetSpace ~
36280 \InsetSpace ~
36281 \InsetSpace ~
36282 \InsetSpace ~
36283 \InsetSpace ~
36284 \InsetSpace ~
36285 \InsetSpace ~
36286 \InsetSpace ~
36287 \InsetSpace ~
36288 \InsetSpace ~
36289 \InsetSpace ~
36290 \InsetSpace ~
36291 \InsetSpace ~
36292 \InsetSpace ~
36293 \InsetSpace ~
36294 \InsetSpace ~
36295 \InsetSpace ~
36296 \InsetSpace ~
36297 \InsetSpace ~
36298 \InsetSpace ~
36299 \InsetSpace ~
36300 \InsetSpace ~
36301 \InsetSpace ~
36302 \InsetSpace ~
36303  91 ;\InsetSpace ~
36304  hob.c 15 
36305 \newline
36306 0037 85*01*06\InsetSpace ~
36307 \InsetSpace ~
36308 \InsetSpace ~
36309 \InsetSpace ~
36310 \InsetSpace ~
36311 \InsetSpace ~
36312 \InsetSpace ~
36313 \InsetSpace ~
36314 \InsetSpace ~
36315 \InsetSpace ~
36316 \InsetSpace ~
36317 \InsetSpace ~
36318  92\InsetSpace ~
36319 \InsetSpace ~
36320 \InsetSpace ~
36321 \InsetSpace ~
36322 \InsetSpace ~
36323 \InsetSpace ~
36324 \InsetSpace ~
36325 \InsetSpace ~
36326  mov\InsetSpace ~
36327 \InsetSpace ~
36328  _foo_hob1_1_1,(_gint + 1) 
36329 \newline
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 \InsetSpace ~
36352 \InsetSpace ~
36353 \InsetSpace ~
36354 \InsetSpace ~
36355  93 ;\InsetSpace ~
36356  hob.c
36357  16 
36358 \newline
36359 003A 85*05*07\InsetSpace ~
36360 \InsetSpace ~
36361 \InsetSpace ~
36362 \InsetSpace ~
36363 \InsetSpace ~
36364 \InsetSpace ~
36365 \InsetSpace ~
36366 \InsetSpace ~
36367 \InsetSpace ~
36368 \InsetSpace ~
36369 \InsetSpace ~
36370 \InsetSpace ~
36371  94\InsetSpace ~
36372 \InsetSpace ~
36373 \InsetSpace ~
36374 \InsetSpace ~
36375 \InsetSpace ~
36376 \InsetSpace ~
36377 \InsetSpace ~
36378 \InsetSpace ~
36379  mov\InsetSpace ~
36380 \InsetSpace ~
36381  _foo_hob2_1_1,(_glong + 3) 
36382 \newline
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 \InsetSpace ~
36405 \InsetSpace ~
36406 \InsetSpace ~
36407 \InsetSpace ~
36408  95 ;\InsetSpace ~
36409  hob.c 17 
36410 \newline
36411 003D 85*04*08\InsetSpace ~
36412 \InsetSpace ~
36413 \InsetSpace ~
36414 \InsetSpace ~
36415 \InsetSpace ~
36416 \InsetSpace ~
36417 \InsetSpace ~
36418 \InsetSpace ~
36419 \InsetSpace ~
36420 \InsetSpace ~
36421 \InsetSpace ~
36422 \InsetSpace ~
36423
36424  96\InsetSpace ~
36425 \InsetSpace ~
36426 \InsetSpace ~
36427 \InsetSpace ~
36428 \InsetSpace ~
36429 \InsetSpace ~
36430 \InsetSpace ~
36431 \InsetSpace ~
36432  mov\InsetSpace ~
36433 \InsetSpace ~
36434  _foo_how1_1_1,(_glong + 2) 
36435 \newline
36436 0040 85*05*09\InsetSpace ~
36437 \InsetSpace ~
36438 \InsetSpace ~
36439 \InsetSpace ~
36440 \InsetSpace ~
36441 \InsetSpace ~
36442 \InsetSpace ~
36443 \InsetSpace ~
36444 \InsetSpace ~
36445 \InsetSpace ~
36446 \InsetSpace ~
36447 \InsetSpace ~
36448  97\InsetSpace ~
36449 \InsetSpace ~
36450 \InsetSpace ~
36451 \InsetSpace ~
36452 \InsetSpace ~
36453 \InsetSpace ~
36454 \InsetSpace ~
36455 \InsetSpace ~
36456  mov\InsetSpace ~
36457 \InsetSpace ~
36458  (_foo_how1_1_1 +
36459  1),(_glong + 3) 
36460 \newline
36461 0043 85*03*0A\InsetSpace ~
36462 \InsetSpace ~
36463 \InsetSpace ~
36464 \InsetSpace ~
36465 \InsetSpace ~
36466 \InsetSpace ~
36467 \InsetSpace ~
36468 \InsetSpace ~
36469 \InsetSpace ~
36470 \InsetSpace ~
36471 \InsetSpace ~
36472 \InsetSpace ~
36473  98\InsetSpace ~
36474 \InsetSpace ~
36475 \InsetSpace ~
36476 \InsetSpace ~
36477 \InsetSpace ~
36478 \InsetSpace ~
36479 \InsetSpace ~
36480 \InsetSpace ~
36481  mov\InsetSpace ~
36482 \InsetSpace ~
36483  _foo_how2_1_1,(_glong + 1) 
36484 \newline
36485 0046 85*04*0B\InsetSpace ~
36486 \InsetSpace ~
36487 \InsetSpace ~
36488 \InsetSpace ~
36489 \InsetSpace ~
36490 \InsetSpace ~
36491 \InsetSpace ~
36492 \InsetSpace ~
36493 \InsetSpace ~
36494 \InsetSpace ~
36495 \InsetSpace ~
36496 \InsetSpace ~
36497
36498  99\InsetSpace ~
36499 \InsetSpace ~
36500 \InsetSpace ~
36501 \InsetSpace ~
36502 \InsetSpace ~
36503 \InsetSpace ~
36504 \InsetSpace ~
36505 \InsetSpace ~
36506  mov\InsetSpace ~
36507 \InsetSpace ~
36508  (_foo_how2_1_1 + 1),(_glong + 2) 
36509 \end_layout
36510
36511 \begin_layout Standard
36512 Again, variations of these cases may 
36513 \emph on
36514 not
36515 \emph default
36516  be recognized.
36517  They are standard C expressions, so I heartily recommend these be the only
36518  way to get the higher order byte/word, (it is portable).
36519  Of course it will be recognized even if it is embedded in other expressions,
36520  e.g.:
36521 \end_layout
36522
36523 \begin_layout Verse
36524
36525 \family typewriter
36526 xyz = gint + ((gint >> 8) & 0xFF);
36527 \end_layout
36528
36529 \begin_layout Standard
36530 will still be recognized.
36531 \end_layout
36532
36533 \begin_layout Subsection
36534 Peephole Optimizer
36535 \begin_inset LatexCommand \label{sub:Peephole-Optimizer}
36536
36537 \end_inset
36538
36539
36540 \begin_inset LatexCommand \index{Peephole optimizer}
36541
36542 \end_inset
36543
36544
36545 \end_layout
36546
36547 \begin_layout Standard
36548 The compiler uses a rule based, pattern matching and re-writing mechanism
36549  for peep-hole optimization.
36550  It is inspired by 
36551 \emph on
36552 copt
36553 \emph default
36554  a peep-hole optimizer by Christopher W.
36555  Fraser (cwfraser\InsetSpace ~
36556 @\InsetSpace ~
36557 microsoft.com).
36558  A default set of rules are compiled into the compiler, additional rules
36559  may be added with the 
36560 \emph on
36561 -
36562 \begin_inset ERT
36563 status collapsed
36564
36565 \begin_layout Standard
36566
36567
36568 \backslash
36569 /
36570 \end_layout
36571
36572 \end_inset
36573
36574 -peep-file
36575 \begin_inset LatexCommand \index{-\/-peep-file}
36576
36577 \end_inset
36578
36579  <filename>
36580 \emph default
36581  option.
36582  The rule language is best illustrated with examples.
36583 \end_layout
36584
36585 \begin_layout Verse
36586
36587 \family typewriter
36588 replace { 
36589 \newline
36590 \InsetSpace ~
36591 \InsetSpace ~
36592 mov %1,a 
36593 \newline
36594 \InsetSpace ~
36595 \InsetSpace ~
36596 mov a,%1
36597 \newline
36598 } by {
36599 \newline
36600 \InsetSpace ~
36601 \InsetSpace ~
36602 mov %1,a
36603 \newline
36604 }
36605 \end_layout
36606
36607 \begin_layout Standard
36608 The above rule will change the following assembly
36609 \begin_inset LatexCommand \index{Assembler routines}
36610
36611 \end_inset
36612
36613  sequence:
36614 \end_layout
36615
36616 \begin_layout Verse
36617
36618 \family typewriter
36619 mov r1,a 
36620 \newline
36621 mov a,r1
36622 \end_layout
36623
36624 \begin_layout Standard
36625 to
36626 \end_layout
36627
36628 \begin_layout Verse
36629
36630 \family typewriter
36631 mov r1,a
36632 \end_layout
36633
36634 \begin_layout Standard
36635 Note: All occurrences of a 
36636 \emph on
36637 %n
36638 \emph default
36639  (pattern variable) must denote the same string.
36640  With the above rule, the assembly sequence:
36641 \end_layout
36642
36643 \begin_layout Verse
36644
36645 \family typewriter
36646 mov r1,a 
36647 \newline
36648 mov a,r2
36649 \end_layout
36650
36651 \begin_layout Standard
36652 will remain unmodified.
36653 \newline
36654
36655 \newline
36656 Other special case optimizations may be added by the
36657  user (via 
36658 \emph on
36659 -
36660 \begin_inset ERT
36661 status collapsed
36662
36663 \begin_layout Standard
36664
36665
36666 \backslash
36667 /
36668 \end_layout
36669
36670 \end_inset
36671
36672 -peep-file option
36673 \emph default
36674 ).
36675  E.g.
36676  some variants of the 8051 MCU
36677 \begin_inset LatexCommand \index{MCS51 variants}
36678
36679 \end_inset
36680
36681  allow only 
36682 \family typewriter
36683 ajmp
36684 \family default
36685  and 
36686 \family typewriter
36687 acall
36688 \family default
36689 .
36690  The following two rules will change all 
36691 \family typewriter
36692 ljmp
36693 \family default
36694  and 
36695 \family typewriter
36696 lcall
36697 \family default
36698  to 
36699 \family typewriter
36700 ajmp
36701 \family default
36702  and 
36703 \family typewriter
36704 acall
36705 \end_layout
36706
36707 \begin_layout Verse
36708
36709 \family typewriter
36710 replace { lcall %1 } by { acall %1 } 
36711 \newline
36712 replace { ljmp %1 } by { ajmp %1 }
36713 \end_layout
36714
36715 \begin_layout Standard
36716 (NOTE: from version 2.7.3 on, you can use option -
36717 \emph on
36718
36719 \begin_inset ERT
36720 status collapsed
36721
36722 \begin_layout Standard
36723
36724
36725 \backslash
36726 /
36727 \end_layout
36728
36729 \end_inset
36730
36731
36732 \emph default
36733 -acall-ajmp
36734 \begin_inset LatexCommand \index{-\/-acall-ajmp}
36735
36736 \end_inset
36737
36738 , which also takes care of aligning the interrupt vectors properly.)
36739 \newline
36740
36741 \end_layout
36742
36743 \begin_layout Standard
36744 The 
36745 \emph on
36746 inline-assembler code
36747 \emph default
36748  is also passed through the peep hole optimizer, thus the peephole optimizer
36749  can also be used as an assembly level macro expander.
36750  The rules themselves are MCU dependent whereas the rule language infra-structur
36751 e is MCU independent.
36752  Peephole optimization rules for other MCU can be easily programmed using
36753  the rule language.
36754 \newline
36755
36756 \newline
36757 The syntax for a rule is as follows:
36758 \end_layout
36759
36760 \begin_layout Verse
36761
36762 \family typewriter
36763 rule := replace [ restart ] '{' <assembly sequence> '
36764 \backslash
36765 n' 
36766 \newline
36767 \InsetSpace ~
36768  \InsetSpace ~
36769  \InsetSpace ~
36770  \InsetSpace ~
36771  \InsetSpace ~
36772  \InsetSpace ~
36773  \InsetSpace ~
36774  \InsetSpace ~
36775  \InsetSpace ~
36776  \InsetSpace ~
36777  \InsetSpace ~
36778  \InsetSpace ~
36779  \InsetSpace ~
36780  \InsetSpace ~
36781  '}' by '{' '
36782 \backslash
36783 n' 
36784 \newline
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  \InsetSpace ~
36798  \InsetSpace ~
36799  \InsetSpace ~
36800  \InsetSpace ~
36801  <assembly sequence> '
36802 \backslash
36803 n' 
36804 \newline
36805 \InsetSpace ~
36806  \InsetSpace ~
36807  \InsetSpace ~
36808  \InsetSpace ~
36809  \InsetSpace ~
36810  \InsetSpace ~
36811  \InsetSpace ~
36812  \InsetSpace ~
36813  \InsetSpace ~
36814  \InsetSpace ~
36815  \InsetSpace ~
36816  \InsetSpace ~
36817  \InsetSpace ~
36818  \InsetSpace ~
36819  '}' [if <functionName> ] '
36820 \backslash
36821 n' 
36822 \end_layout
36823
36824 \begin_layout Standard
36825 <assembly sequence> := assembly instruction (each instruction including
36826  labels must be on a separate line).
36827 \newline
36828
36829 \newline
36830 The optimizer will apply to the rules
36831  one by one from the top in the sequence of their appearance, it will terminate
36832  when all rules are exhausted.
36833  If the 'restart' option is specified, then the optimizer will start matching
36834  the rules again from the top, this option for a rule is expensive (performance)
36835 , it is intended to be used in situations where a transformation will trigger
36836  the same rule again.
36837  An example of this (not a good one, it has side effects) is the following
36838  rule:
36839 \end_layout
36840
36841 \begin_layout Verse
36842
36843 \family typewriter
36844 replace restart { 
36845 \newline
36846 \InsetSpace ~
36847 \InsetSpace ~
36848 pop %1 
36849 \newline
36850 \InsetSpace ~
36851 \InsetSpace ~
36852 push %1 } by { 
36853 \newline
36854 \InsetSpace ~
36855 \InsetSpace ~
36856 ; nop 
36857 \newline
36858 }
36859 \end_layout
36860
36861 \begin_layout Standard
36862 Note that the replace pattern cannot be a blank, but can be a comment line.
36863  Without the 'restart' option only the innermost 'pop' 'push' pair would
36864  be eliminated, i.e.:
36865 \end_layout
36866
36867 \begin_layout Verse
36868
36869 \family typewriter
36870 pop ar1 
36871 \newline
36872 pop ar2 
36873 \newline
36874 push ar2 
36875 \newline
36876 push ar1
36877 \end_layout
36878
36879 \begin_layout Standard
36880 would result in:
36881 \end_layout
36882
36883 \begin_layout Verse
36884
36885 \family typewriter
36886 pop ar1 
36887 \newline
36888 ; nop 
36889 \newline
36890 push ar1
36891 \end_layout
36892
36893 \begin_layout Standard
36894
36895 \emph on
36896 with
36897 \emph default
36898  the restart option the rule will be applied again to the resulting code
36899  and then all the pop-push pairs will be eliminated to yield:
36900 \end_layout
36901
36902 \begin_layout Verse
36903
36904 \family typewriter
36905 ; nop 
36906 \newline
36907 ; nop
36908 \end_layout
36909
36910 \begin_layout Standard
36911 A conditional function can be attached to a rule.
36912  Attaching rules are somewhat more involved, let me illustrate this with
36913  an example.
36914 \end_layout
36915
36916 \begin_layout Verse
36917
36918 \family typewriter
36919 replace { 
36920 \newline
36921 \InsetSpace ~
36922  \InsetSpace ~
36923  \InsetSpace ~
36924 ljmp %5 
36925 \newline
36926 %2:
36927 \newline
36928 } by { 
36929 \newline
36930 \InsetSpace ~
36931  \InsetSpace ~
36932  \InsetSpace ~
36933 sjmp %5 
36934 \newline
36935 %2:
36936 \newline
36937 } if labelInRange
36938 \end_layout
36939
36940 \begin_layout Standard
36941 The optimizer does a look-up of a function name table defined in function
36942  
36943 \emph on
36944 callFuncByName
36945 \emph default
36946  in the source file SDCCpeeph.c, with the name 
36947 \emph on
36948 labelInRange
36949 \emph default
36950 .
36951  If it finds a corresponding entry the function is called.
36952  Note there can be no parameters specified for these functions, in this
36953  case the use of 
36954 \emph on
36955 %5
36956 \emph default
36957  is crucial, since the function 
36958 \emph on
36959 labelInRange
36960 \emph default
36961  expects to find the label in that particular variable (the hash table containin
36962 g the variable bindings is passed as a parameter).
36963  If you want to code more such functions, take a close look at the function
36964  labelInRange and the calling mechanism in source file SDCCpeeph.c.
36965  Currently implemented are 
36966 \emph on
36967 labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
36968  24bitMode, portIsDS390, 24bitModeAndPortDS390 
36969 \emph default
36970 and
36971 \emph on
36972  notVolatile
36973 \emph default
36974 .
36975 \end_layout
36976
36977 \begin_layout Standard
36978 I know this whole thing is a little kludgey, but maybe some day we will
36979  have some better means.
36980  If you are looking at this file, you will see the default rules that are
36981  compiled into the compiler, you can add your own rules in the default set
36982  there if you get tired of specifying the -
36983 \begin_inset ERT
36984 status collapsed
36985
36986 \begin_layout Standard
36987
36988
36989 \backslash
36990 /
36991 \end_layout
36992
36993 \end_inset
36994
36995 -peep-file option.
36996 \end_layout
36997
36998 \begin_layout Section
36999 ANSI-Compliance
37000 \begin_inset LatexCommand \index{ANSI-compliance}
37001
37002 \end_inset
37003
37004
37005 \begin_inset LatexCommand \label{sub:ANSI-Compliance}
37006
37007 \end_inset
37008
37009
37010 \end_layout
37011
37012 \begin_layout Standard
37013 The latest publically available version of the standard 
37014 \emph on
37015 ISO/IEC 9899 - Programming languages - C
37016 \emph default
37017  should be available at: 
37018 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
37019
37020 \end_inset
37021
37022 .
37023 \newline
37024
37025 \end_layout
37026
37027 \begin_layout Standard
37028 Deviations from the compliance:
37029 \end_layout
37030
37031 \begin_layout Itemize
37032 functions are not reentrant
37033 \begin_inset LatexCommand \index{reentrant}
37034
37035 \end_inset
37036
37037  unless explicitly declared as such or the 
37038 \series bold
37039 -
37040 \begin_inset ERT
37041 status collapsed
37042
37043 \begin_layout Standard
37044
37045
37046 \backslash
37047 /
37048 \end_layout
37049
37050 \end_inset
37051
37052 -stack-auto
37053 \begin_inset LatexCommand \index{-\/-stack-auto}
37054
37055 \end_inset
37056
37057
37058 \series default
37059  command line option is specified.
37060 \end_layout
37061
37062 \begin_layout Itemize
37063 structures
37064 \begin_inset LatexCommand \index{struct}
37065
37066 \end_inset
37067
37068  and unions
37069 \begin_inset LatexCommand \index{union}
37070
37071 \end_inset
37072
37073  cannot be assigned values directly, cannot be passed as function parameters
37074  or assigned to each other and cannot be a return value
37075 \begin_inset LatexCommand \index{return value}
37076
37077 \end_inset
37078
37079  from a function, e.g.:
37080 \end_layout
37081
37082 \begin_deeper
37083 \begin_layout Verse
37084
37085 \family typewriter
37086 struct s { ...
37087  }; 
37088 \newline
37089 struct s s1, s2; 
37090 \newline
37091 foo() 
37092 \newline
37093
37094 \newline
37095 \InsetSpace ~
37096 \InsetSpace ~
37097 \InsetSpace ~
37098 \InsetSpace ~
37099 ...
37100  
37101 \newline
37102 \InsetSpace ~
37103 \InsetSpace ~
37104 \InsetSpace ~
37105 \InsetSpace ~
37106 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
37107 \newline
37108 \InsetSpace ~
37109 \InsetSpace ~
37110 \InsetSpace ~
37111 \InsetSpace ~
37112 ...
37113  
37114 \newline
37115 }
37116 \newline
37117
37118 \series bold
37119 struct
37120 \series default
37121  s foo1 (
37122 \series bold
37123 struct
37124 \series default
37125  s parms) /* invalid in SDCC although allowed in ANSI */
37126 \newline
37127
37128 \newline
37129 \InsetSpace ~
37130 \InsetSpace ~
37131 \InsetSpace ~
37132 \InsetSpace ~
37133 struct s rets;
37134  
37135 \newline
37136 \InsetSpace ~
37137 \InsetSpace ~
37138 \InsetSpace ~
37139 \InsetSpace ~
37140 ...
37141  
37142 \newline
37143 \InsetSpace ~
37144 \InsetSpace ~
37145 \InsetSpace ~
37146 \InsetSpace ~
37147 return rets; /* is invalid in SDCC although allowed in ANSI */ 
37148 \newline
37149 }
37150 \end_layout
37151
37152 \end_deeper
37153 \begin_layout Itemize
37154 initialization of structure arrays must be fully braced.
37155 \end_layout
37156
37157 \begin_deeper
37158 \begin_layout Verse
37159
37160 \family typewriter
37161 struct s { char x } a[] = {1, 2};\InsetSpace ~
37162 \InsetSpace ~
37163 \InsetSpace ~
37164 \InsetSpace ~
37165 \InsetSpace ~
37166 /* invalid in SDCC */
37167 \newline
37168 struct s { char x
37169  } a[] = {{1}, {2}}; /* OK */
37170 \end_layout
37171
37172 \end_deeper
37173 \begin_layout Itemize
37174 'long long
37175 \begin_inset LatexCommand \index{long long (not supported)}
37176
37177 \end_inset
37178
37179 ' (64 bit integers
37180 \begin_inset LatexCommand \index{int (64 bit) (not supported)}
37181
37182 \end_inset
37183
37184 ) not supported.
37185 \end_layout
37186
37187 \begin_layout Itemize
37188 'double
37189 \begin_inset LatexCommand \index{double (not supported)}
37190
37191 \end_inset
37192
37193 ' precision floating point 
37194 \begin_inset LatexCommand \index{Floating point support}
37195
37196 \end_inset
37197
37198 not supported.
37199 \end_layout
37200
37201 \begin_layout Itemize
37202 Old K&R style
37203 \begin_inset LatexCommand \index{K\&R style}
37204
37205 \end_inset
37206
37207  function declarations are NOT allowed.
37208 \end_layout
37209
37210 \begin_deeper
37211 \begin_layout Verse
37212
37213 \family typewriter
37214 foo(i,j) /* this old style of function declarations */ 
37215 \newline
37216 int i,j; /* is valid
37217  in ANSI but not valid in SDCC */ 
37218 \newline
37219
37220 \newline
37221 \InsetSpace ~
37222 \InsetSpace ~
37223 \InsetSpace ~
37224 \InsetSpace ~
37225 ...
37226  
37227 \newline
37228 }
37229 \end_layout
37230
37231 \end_deeper
37232 \begin_layout Itemize
37233 Most enhancements in C99 are not supported, e.g.:
37234 \end_layout
37235
37236 \begin_deeper
37237 \begin_layout Verse
37238
37239 \family typewriter
37240 for (
37241 \series bold
37242 int
37243 \series default
37244  i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
37245 \end_layout
37246
37247 \end_deeper
37248 \begin_layout Itemize
37249 But some have been added recently in SDCC 2.7.0.
37250  They must be considered alpha quality however.
37251 \end_layout
37252
37253 \begin_deeper
37254 \begin_layout Verse
37255
37256 \family typewriter
37257 \series bold
37258 inline
37259 \begin_inset LatexCommand \index{inline (not supported)}
37260
37261 \end_inset
37262
37263
37264 \series default
37265  int increment (int a) { return a+1; } /* inlines the increment without
37266  function call overhead */
37267 \newline
37268 int * 
37269 \series bold
37270 restrict
37271 \begin_inset LatexCommand \index{inline (not supported)}
37272
37273 \end_inset
37274
37275
37276 \series default
37277  p; /* accepted but ignored */
37278 \end_layout
37279
37280 \end_deeper
37281 \begin_layout Itemize
37282 Certain words that are valid identifiers in the standard may be reserved
37283  words in SDCC unless the 
37284 \series bold
37285 -
37286 \begin_inset ERT
37287 status collapsed
37288
37289 \begin_layout Standard
37290
37291
37292 \backslash
37293 /
37294 \end_layout
37295
37296 \end_inset
37297
37298 -std-c89
37299 \begin_inset LatexCommand \index{-\/-std-c89}
37300
37301 \end_inset
37302
37303  
37304 \series default
37305 or
37306 \series bold
37307  -
37308 \begin_inset ERT
37309 status collapsed
37310
37311 \begin_layout Standard
37312
37313
37314 \backslash
37315 /
37316 \end_layout
37317
37318 \end_inset
37319
37320 -std-c99
37321 \begin_inset LatexCommand \index{-\/-std-c99}
37322
37323 \end_inset
37324
37325
37326 \series default
37327  command line options are used.
37328  These may include (depending on the selected processor): 'at', 'banked',
37329  'bit', 'code', 'critical', 'data', 'eeprom', 'far', 'flash', 'idata', 'interrup
37330 t', 'near', 'nonbanked', 'pdata', 'reentrant', 'sbit', 'sfr', 'shadowregs',
37331  'sram', 'using', 'wparam', 'xdata', '_overlay', '_asm', '_endasm', and
37332  '_naked'.
37333  Compliant equivalents of these keywords are always available in a form
37334  that begin with two underscores
37335 \begin_inset LatexCommand \index{\_\_ (prefix for extended keywords)}
37336
37337 \end_inset
37338
37339 , f.e.
37340  '__data' instead of 'data'.
37341 \end_layout
37342
37343 \begin_layout Itemize
37344 Integer promotion of variable arguments is not performed if the argument
37345  is explicitly taypecasted unless the
37346 \series bold
37347  -
37348 \begin_inset ERT
37349 status collapsed
37350
37351 \begin_layout Standard
37352
37353
37354 \backslash
37355 /
37356 \end_layout
37357
37358 \end_inset
37359
37360 -std-c89
37361 \begin_inset LatexCommand \index{-\/-std-c89}
37362
37363 \end_inset
37364
37365  
37366 \series default
37367 or
37368 \series bold
37369  -
37370 \begin_inset ERT
37371 status collapsed
37372
37373 \begin_layout Standard
37374
37375
37376 \backslash
37377 /
37378 \end_layout
37379
37380 \end_inset
37381
37382 -std-c99
37383 \begin_inset LatexCommand \index{-\/-std-c99}
37384
37385 \end_inset
37386
37387
37388 \series default
37389  command line options are used.
37390 \end_layout
37391
37392 \begin_deeper
37393 \begin_layout Verse
37394
37395 \family typewriter
37396 void vararg_func (char *str, ...) { str; }
37397 \newline
37398
37399 \newline
37400 void main (void)
37401 \newline
37402 {
37403 \newline
37404 \InsetSpace ~
37405 \InsetSpace ~
37406 char c = 10;
37407 \newline
37408
37409 \newline
37410 \InsetSpace ~
37411 \InsetSpace ~
37412 /* argument
37413  u is promoted to int before
37414 \newline
37415 \InsetSpace ~
37416 \InsetSpace ~
37417 \InsetSpace ~
37418 * passing to function */
37419 \newline
37420 \InsetSpace ~
37421 \InsetSpace ~
37422 vararg_func ("%c", c);
37423 \newline
37424
37425 \newline
37426 \InsetSpace ~
37427 \InsetSpace ~
37428 /*
37429  argument u is not promoted to int,
37430 \newline
37431 \InsetSpace ~
37432 \InsetSpace ~
37433 \InsetSpace ~
37434 * it is passed as char to function
37435 \newline
37436 \InsetSpace ~
37437 \InsetSpace ~
37438 \InsetSpace ~
37439 * if
37440  --std-cXX is not defined;
37441 \newline
37442 \InsetSpace ~
37443 \InsetSpace ~
37444 \InsetSpace ~
37445 * is promoted to int before passing
37446 \newline
37447 \InsetSpace ~
37448 \InsetSpace ~
37449 \InsetSpace ~
37450 * to function
37451  if --std-cXX is defined */
37452 \newline
37453 \InsetSpace ~
37454 \InsetSpace ~
37455 vararg_func ("%bc", (char)u);
37456 \newline
37457 }
37458 \end_layout
37459
37460 \end_deeper
37461 \begin_layout Section
37462 Cyclomatic Complexity
37463 \begin_inset LatexCommand \index{Cyclomatic complexity}
37464
37465 \end_inset
37466
37467
37468 \end_layout
37469
37470 \begin_layout Standard
37471 Cyclomatic complexity of a function is defined as the number of independent
37472  paths the program can take during execution of the function.
37473  This is an important number since it defines the number test cases you
37474  have to generate to validate the function.
37475  The accepted industry standard for complexity number is 10, if the cyclomatic
37476  complexity reported by SDCC exceeds 10 you should think about simplification
37477  of the function logic.
37478  Note that the complexity level is not related to the number of lines of
37479  code in a function.
37480  Large functions can have low complexity, and small functions can have large
37481  complexity levels.
37482  
37483 \newline
37484
37485 \newline
37486 SDCC uses the following formula to compute the complexity:
37487 \newline
37488
37489 \end_layout
37490
37491 \begin_layout Standard
37492 complexity = (number of edges in control flow graph) - (number of nodes
37493  in control flow graph) + 2;
37494 \newline
37495
37496 \newline
37497 Having said that the industry standard is 10,
37498  you should be aware that in some cases it be may unavoidable to have a
37499  complexity level of less than 10.
37500  For example if you have switch statement with more than 10 case labels,
37501  each case label adds one to the complexity level.
37502  The complexity level is by no means an absolute measure of the algorithmic
37503  complexity of the function, it does however provide a good starting point
37504  for which functions you might look at for further optimization.
37505 \end_layout
37506
37507 \begin_layout Section
37508 Retargetting for other Processors
37509 \end_layout
37510
37511 \begin_layout Standard
37512 The issues for retargetting the compiler are far too numerous to be covered
37513  by this document.
37514  What follows is a brief description of each of the seven phases of the
37515  compiler and its MCU dependency.
37516 \end_layout
37517
37518 \begin_layout Itemize
37519 Parsing the source and building the annotated parse tree.
37520  This phase is largely MCU independent (except for the language extensions).
37521  Syntax & semantic checks are also done in this phase, along with some initial
37522  optimizations like back patching labels and the pattern matching optimizations
37523  like bit-rotation etc.
37524 \end_layout
37525
37526 \begin_layout Itemize
37527 The second phase involves generating an intermediate code which can be easy
37528  manipulated during the later phases.
37529  This phase is entirely MCU independent.
37530  The intermediate code generation assumes the target machine has unlimited
37531  number of registers, and designates them with the name iTemp.
37532  The compiler can be made to dump a human readable form of the code generated
37533  by using the -
37534 \begin_inset ERT
37535 status collapsed
37536
37537 \begin_layout Standard
37538
37539
37540 \backslash
37541 /
37542 \end_layout
37543
37544 \end_inset
37545
37546 -dumpraw option.
37547 \end_layout
37548
37549 \begin_layout Itemize
37550 This phase does the bulk of the standard optimizations and is also MCU independe
37551 nt.
37552  This phase can be broken down into several sub-phases:
37553 \newline
37554
37555 \newline
37556 Break down intermediate
37557  code (iCode) into basic blocks.
37558 \newline
37559 Do control flow & data flow analysis on the
37560  basic blocks.
37561 \newline
37562 Do local common subexpression elimination, then global subexpressio
37563 n elimination
37564 \newline
37565 Dead code elimination
37566 \newline
37567 Loop optimizations
37568 \newline
37569 If loop optimizations
37570  caused any changes then do 'global subexpression elimination' and 'dead
37571  code elimination' again.
37572 \end_layout
37573
37574 \begin_layout Itemize
37575 This phase determines the live-ranges; by live range I mean those iTemp
37576  variables defined by the compiler that still survive after all the optimization
37577 s.
37578  Live range analysis
37579 \begin_inset LatexCommand \index{Live range analysis}
37580
37581 \end_inset
37582
37583  is essential for register allocation, since these computation determines
37584  which of these iTemps will be assigned to registers, and for how long.
37585 \end_layout
37586
37587 \begin_layout Itemize
37588 Phase five is register allocation.
37589  There are two parts to this process.
37590 \newline
37591
37592 \newline
37593 The first part I call 'register packing'
37594  (for lack of a better term).
37595  In this case several MCU specific expression folding is done to reduce
37596  register pressure.
37597 \newline
37598
37599 \newline
37600 The second part is more MCU independent and deals with
37601  allocating registers to the remaining live ranges.
37602  A lot of MCU specific code does creep into this phase because of the limited
37603  number of index registers available in the 8051.
37604 \end_layout
37605
37606 \begin_layout Itemize
37607 The Code generation phase is (unhappily), entirely MCU dependent and very
37608  little (if any at all) of this code can be reused for other MCU.
37609  However the scheme for allocating a homogenized assembler operand for each
37610  iCode operand may be reused.
37611 \end_layout
37612
37613 \begin_layout Itemize
37614 As mentioned in the optimization section the peep-hole optimizer is rule
37615  based system, which can reprogrammed for other MCUs.
37616 \end_layout
37617
37618 \begin_layout Standard
37619 More information is available on SDCC Wiki
37620 \begin_inset LatexCommand \index{wiki}
37621
37622 \end_inset
37623
37624  (preliminary link 
37625 \begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/SDCC+internals+and+porting}
37626
37627 \end_inset
37628
37629 ) and in the thread 
37630 \begin_inset LatexCommand \url{http://sf.net/mailarchive/message.php?msg_id=13954144}
37631
37632 \end_inset
37633
37634  .
37635 \end_layout
37636
37637 \begin_layout Chapter
37638 Compiler internals
37639 \begin_inset LatexCommand \index{Compiler internals}
37640
37641 \end_inset
37642
37643
37644 \end_layout
37645
37646 \begin_layout Section
37647 The anatomy of the compiler
37648 \begin_inset LatexCommand \label{sub:The-anatomy-of}
37649
37650 \end_inset
37651
37652
37653 \end_layout
37654
37655 \begin_layout Standard
37656
37657 \shape italic
37658 This is an excerpt from an article published in Circuit Cellar Magazine
37659  in 
37660 \series bold
37661 August 2000
37662 \series default
37663 .
37664  It's a little outdated (the compiler is much more efficient now and user/develo
37665 per friendly), but pretty well exposes the guts of it all.
37666 \shape default
37667
37668 \newline
37669
37670 \newline
37671 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
37672  It is fairly easy to retarget for other 8-bit MCU.
37673  Here we take a look at some of the internals of the compiler.
37674  
37675 \end_layout
37676
37677 \begin_layout Paragraph*
37678 Parsing
37679 \begin_inset LatexCommand \index{Parsing}
37680
37681 \end_inset
37682
37683  
37684 \end_layout
37685
37686 \begin_layout Standard
37687 Parsing the input source file and creating an AST (Annotated Syntax Tree
37688 \begin_inset LatexCommand \index{Annotated syntax tree}
37689
37690 \end_inset
37691
37692 ).
37693  This phase also involves propagating types (annotating each node of the
37694  parse tree with type information) and semantic analysis.
37695  There are some MCU specific parsing rules.
37696  For example the storage classes, the extended storage classes are MCU specific
37697  while there may be a xdata storage class for 8051 there is no such storage
37698  class for z80 or Atmel AVR.
37699  SDCC allows MCU specific storage class extensions, i.e.
37700  xdata will be treated as a storage class specifier when parsing 8051 C
37701  code but will be treated as a C identifier when parsing z80 or ATMEL AVR
37702  C code.
37703 \end_layout
37704
37705 \begin_layout Paragraph*
37706 Generating iCode
37707 \begin_inset LatexCommand \index{iCode}
37708
37709 \end_inset
37710
37711
37712 \end_layout
37713
37714 \begin_layout Standard
37715 Intermediate code generation.
37716  In this phase the AST is broken down into three-operand form (iCode).
37717  These three operand forms are represented as doubly linked lists.
37718  ICode is the term given to the intermediate form generated by the compiler.
37719  ICode example section shows some examples of iCode generated for some simple
37720  C source functions.
37721 \end_layout
37722
37723 \begin_layout Paragraph*
37724 Optimizations
37725 \begin_inset LatexCommand \index{Optimizations}
37726
37727 \end_inset
37728
37729 .
37730 \end_layout
37731
37732 \begin_layout Standard
37733 Bulk of the target independent optimizations is performed in this phase.
37734  The optimizations include constant propagation, common sub-expression eliminati
37735 on, loop invariant code movement, strength reduction of loop induction variables
37736  and dead-code elimination.
37737 \end_layout
37738
37739 \begin_layout Paragraph*
37740 Live range analysis
37741 \begin_inset LatexCommand \index{Live range analysis}
37742
37743 \end_inset
37744
37745
37746 \end_layout
37747
37748 \begin_layout Standard
37749 During intermediate code generation phase, the compiler assumes the target
37750  machine has infinite number of registers and generates a lot of temporary
37751  variables.
37752  The live range computation determines the lifetime of each of these compiler-ge
37753 nerated temporaries.
37754  A picture speaks a thousand words.
37755  ICode example sections show the live range annotations for each of the
37756  operand.
37757  It is important to note here, each iCode is assigned a number in the order
37758  of its execution in the function.
37759  The live ranges are computed in terms of these numbers.
37760  The from number is the number of the iCode which first defines the operand
37761  and the to number signifies the iCode which uses this operand last.
37762 \end_layout
37763
37764 \begin_layout Paragraph*
37765 Register Allocation
37766 \begin_inset LatexCommand \index{Register allocation}
37767
37768 \end_inset
37769
37770
37771 \end_layout
37772
37773 \begin_layout Standard
37774 The register allocation determines the type and number of registers needed
37775  by each operand.
37776  In most MCUs only a few registers can be used for indirect addressing.
37777  In case of 8051 for example the registers R0 & R1 can be used to indirectly
37778  address the internal ram and DPTR to indirectly address the external ram.
37779  The compiler will try to allocate the appropriate register to pointer variables
37780  if it can.
37781  ICode example section shows the operands annotated with the registers assigned
37782  to them.
37783  The compiler will try to keep operands in registers as much as possible;
37784  there are several schemes the compiler uses to do achieve this.
37785  When the compiler runs out of registers the compiler will check to see
37786  if there are any live operands which is not used or defined in the current
37787  basic block being processed, if there are any found then it will push that
37788  operand and use the registers in this block, the operand will then be popped
37789  at the end of the basic block.
37790  
37791 \end_layout
37792
37793 \begin_layout Standard
37794 There are other MCU specific considerations in this phase.
37795  Some MCUs have an accumulator; very short-lived operands could be assigned
37796  to the accumulator instead of a general-purpose register.
37797 \end_layout
37798
37799 \begin_layout Paragraph*
37800 Code generation
37801 \end_layout
37802
37803 \begin_layout Standard
37804 Figure II gives a table of iCode
37805 \begin_inset LatexCommand \index{iCode}
37806
37807 \end_inset
37808
37809  operations supported by the compiler.
37810  The code generation involves translating these operations into corresponding
37811  assembly code for the processor.
37812  This sounds overly simple but that is the essence of code generation.
37813  Some of the iCode operations are generated on a MCU specific manner for
37814  example, the z80 port does not use registers to pass parameters so the
37815  SEND and RECV iCode operations will not be generated, and it also does
37816  not support JUMPTABLES.
37817  
37818 \newline
37819
37820 \end_layout
37821
37822 \begin_layout Standard
37823
37824 \size footnotesize
37825 Figure II 
37826 \begin_inset Tabular
37827 <lyxtabular version="3" rows="39" columns="4">
37828 <features islongtable="true" headBottomDL="true">
37829 <column alignment="block" valignment="top" leftline="true" width="13col%">
37830 <column alignment="left" valignment="top" leftline="true" width="13col%">
37831 <column alignment="block" valignment="top" leftline="true" width="22col%">
37832 <column alignment="block" valignment="top" leftline="true" rightline="true" width="40col%">
37833 <row topline="true" bottomline="true" endhead="true">
37834 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37835 \begin_inset Text
37836
37837 \begin_layout Standard
37838
37839 \series bold
37840 iCode
37841 \series default
37842
37843 \begin_inset LatexCommand \index{iCode}
37844
37845 \end_inset
37846
37847
37848 \end_layout
37849
37850 \end_inset
37851 </cell>
37852 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37853 \begin_inset Text
37854
37855 \begin_layout Standard
37856
37857 \series bold
37858 Operands
37859 \end_layout
37860
37861 \end_inset
37862 </cell>
37863 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37864 \begin_inset Text
37865
37866 \begin_layout Standard
37867
37868 \series bold
37869 Description
37870 \end_layout
37871
37872 \end_inset
37873 </cell>
37874 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37875 \begin_inset Text
37876
37877 \begin_layout Standard
37878
37879 \series bold
37880 C Equivalent
37881 \end_layout
37882
37883 \end_inset
37884 </cell>
37885 </row>
37886 <row topline="true">
37887 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37888 \begin_inset Text
37889
37890 \begin_layout Standard
37891
37892 \size footnotesize
37893 '!'
37894 \end_layout
37895
37896 \end_inset
37897 </cell>
37898 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37899 \begin_inset Text
37900
37901 \begin_layout Standard
37902
37903 \size footnotesize
37904 IC_LEFT() IC_RESULT()
37905 \end_layout
37906
37907 \end_inset
37908 </cell>
37909 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37910 \begin_inset Text
37911
37912 \begin_layout Standard
37913
37914 \size footnotesize
37915 NOT operation 
37916 \end_layout
37917
37918 \end_inset
37919 </cell>
37920 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37921 \begin_inset Text
37922
37923 \begin_layout Standard
37924
37925 \size footnotesize
37926 IC_RESULT = ! IC_LEFT;
37927 \end_layout
37928
37929 \end_inset
37930 </cell>
37931 </row>
37932 <row topline="true">
37933 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37934 \begin_inset Text
37935
37936 \begin_layout Standard
37937
37938 \size footnotesize
37939 '~'
37940 \end_layout
37941
37942 \end_inset
37943 </cell>
37944 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37945 \begin_inset Text
37946
37947 \begin_layout Standard
37948
37949 \size footnotesize
37950 IC_LEFT() IC_RESULT()
37951 \end_layout
37952
37953 \end_inset
37954 </cell>
37955 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37956 \begin_inset Text
37957
37958 \begin_layout Standard
37959
37960 \size footnotesize
37961 Bitwise complement of 
37962 \end_layout
37963
37964 \end_inset
37965 </cell>
37966 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37967 \begin_inset Text
37968
37969 \begin_layout Standard
37970
37971 \size footnotesize
37972 IC_RESULT = ~IC_LEFT;
37973 \end_layout
37974
37975 \end_inset
37976 </cell>
37977 </row>
37978 <row topline="true">
37979 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37980 \begin_inset Text
37981
37982 \begin_layout Standard
37983
37984 \size footnotesize
37985 RRC
37986 \end_layout
37987
37988 \end_inset
37989 </cell>
37990 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37991 \begin_inset Text
37992
37993 \begin_layout Standard
37994
37995 \size footnotesize
37996 IC_LEFT() IC_RESULT()
37997 \end_layout
37998
37999 \end_inset
38000 </cell>
38001 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38002 \begin_inset Text
38003
38004 \begin_layout Standard
38005
38006 \size footnotesize
38007 Rotate right with carry
38008 \end_layout
38009
38010 \end_inset
38011 </cell>
38012 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38013 \begin_inset Text
38014
38015 \begin_layout Standard
38016
38017 \size footnotesize
38018 IC_RESULT = (IC_LEFT << 1) | (IC_LEFT >> (sizeof(IC_LEFT)*8-1));
38019 \end_layout
38020
38021 \end_inset
38022 </cell>
38023 </row>
38024 <row topline="true">
38025 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38026 \begin_inset Text
38027
38028 \begin_layout Standard
38029
38030 \size footnotesize
38031 RLC
38032 \end_layout
38033
38034 \end_inset
38035 </cell>
38036 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38037 \begin_inset Text
38038
38039 \begin_layout Standard
38040
38041 \size footnotesize
38042 IC_LEFT() IC_RESULT()
38043 \end_layout
38044
38045 \end_inset
38046 </cell>
38047 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38048 \begin_inset Text
38049
38050 \begin_layout Standard
38051
38052 \size footnotesize
38053 Rotate left with carry
38054 \end_layout
38055
38056 \end_inset
38057 </cell>
38058 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38059 \begin_inset Text
38060
38061 \begin_layout Standard
38062
38063 \size footnotesize
38064 IC_RESULT = (IC_LEFT << (sizeof(LC_LEFT)*8-1) ) | (IC_LEFT >> 1);
38065 \end_layout
38066
38067 \end_inset
38068 </cell>
38069 </row>
38070 <row topline="true">
38071 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38072 \begin_inset Text
38073
38074 \begin_layout Standard
38075
38076 \size footnotesize
38077 GETHBIT
38078 \end_layout
38079
38080 \end_inset
38081 </cell>
38082 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38083 \begin_inset Text
38084
38085 \begin_layout Standard
38086
38087 \size footnotesize
38088 IC_LEFT() IC_RESULT()
38089 \end_layout
38090
38091 \end_inset
38092 </cell>
38093 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38094 \begin_inset Text
38095
38096 \begin_layout Standard
38097
38098 \size footnotesize
38099 Get the highest order bit of IC_LEFT
38100 \end_layout
38101
38102 \end_inset
38103 </cell>
38104 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38105 \begin_inset Text
38106
38107 \begin_layout Standard
38108
38109 \size footnotesize
38110 IC_RESULT = (IC_LEFT >> (sizeof(IC_LEFT)*8 -1));
38111 \end_layout
38112
38113 \end_inset
38114 </cell>
38115 </row>
38116 <row topline="true">
38117 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38118 \begin_inset Text
38119
38120 \begin_layout Standard
38121
38122 \size footnotesize
38123 UNARYMINUS
38124 \end_layout
38125
38126 \end_inset
38127 </cell>
38128 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38129 \begin_inset Text
38130
38131 \begin_layout Standard
38132
38133 \size footnotesize
38134 IC_LEFT() IC_RESULT()
38135 \end_layout
38136
38137 \end_inset
38138 </cell>
38139 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38140 \begin_inset Text
38141
38142 \begin_layout Standard
38143
38144 \size footnotesize
38145 Unary minus
38146 \end_layout
38147
38148 \end_inset
38149 </cell>
38150 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38151 \begin_inset Text
38152
38153 \begin_layout Standard
38154
38155 \size footnotesize
38156 IC_RESULT = - IC_LEFT;
38157 \end_layout
38158
38159 \end_inset
38160 </cell>
38161 </row>
38162 <row topline="true">
38163 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38164 \begin_inset Text
38165
38166 \begin_layout Standard
38167
38168 \size footnotesize
38169 IPUSH
38170 \end_layout
38171
38172 \end_inset
38173 </cell>
38174 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38175 \begin_inset Text
38176
38177 \begin_layout Standard
38178
38179 \size footnotesize
38180 IC_LEFT()
38181 \end_layout
38182
38183 \end_inset
38184 </cell>
38185 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38186 \begin_inset Text
38187
38188 \begin_layout Standard
38189
38190 \size footnotesize
38191 Push the operand into stack
38192 \end_layout
38193
38194 \end_inset
38195 </cell>
38196 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38197 \begin_inset Text
38198
38199 \begin_layout Standard
38200
38201 \size footnotesize
38202 NONE
38203 \end_layout
38204
38205 \end_inset
38206 </cell>
38207 </row>
38208 <row topline="true">
38209 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38210 \begin_inset Text
38211
38212 \begin_layout Standard
38213
38214 \size footnotesize
38215 IPOP
38216 \end_layout
38217
38218 \end_inset
38219 </cell>
38220 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38221 \begin_inset Text
38222
38223 \begin_layout Standard
38224
38225 \size footnotesize
38226 IC_LEFT()
38227 \end_layout
38228
38229 \end_inset
38230 </cell>
38231 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38232 \begin_inset Text
38233
38234 \begin_layout Standard
38235
38236 \size footnotesize
38237 Pop the operand from the stack 
38238 \end_layout
38239
38240 \end_inset
38241 </cell>
38242 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38243 \begin_inset Text
38244
38245 \begin_layout Standard
38246
38247 \size footnotesize
38248 NONE
38249 \end_layout
38250
38251 \end_inset
38252 </cell>
38253 </row>
38254 <row topline="true">
38255 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38256 \begin_inset Text
38257
38258 \begin_layout Standard
38259
38260 \size footnotesize
38261 CALL
38262 \end_layout
38263
38264 \end_inset
38265 </cell>
38266 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38267 \begin_inset Text
38268
38269 \begin_layout Standard
38270
38271 \size footnotesize
38272 IC_LEFT() IC_RESULT()
38273 \end_layout
38274
38275 \end_inset
38276 </cell>
38277 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38278 \begin_inset Text
38279
38280 \begin_layout Standard
38281
38282 \size footnotesize
38283 Call the function represented by IC_LEFT 
38284 \end_layout
38285
38286 \end_inset
38287 </cell>
38288 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38289 \begin_inset Text
38290
38291 \begin_layout Standard
38292
38293 \size footnotesize
38294 IC_RESULT = IC_LEFT();
38295 \end_layout
38296
38297 \end_inset
38298 </cell>
38299 </row>
38300 <row topline="true">
38301 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38302 \begin_inset Text
38303
38304 \begin_layout Standard
38305
38306 \size footnotesize
38307 PCALL
38308 \end_layout
38309
38310 \end_inset
38311 </cell>
38312 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38313 \begin_inset Text
38314
38315 \begin_layout Standard
38316
38317 \size footnotesize
38318 IC_LEFT() IC_RESULT()
38319 \end_layout
38320
38321 \end_inset
38322 </cell>
38323 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38324 \begin_inset Text
38325
38326 \begin_layout Standard
38327
38328 \size footnotesize
38329 Call via function pointer
38330 \end_layout
38331
38332 \end_inset
38333 </cell>
38334 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38335 \begin_inset Text
38336
38337 \begin_layout Standard
38338
38339 \size footnotesize
38340 IC_RESULT = (*IC_LEFT)();
38341 \end_layout
38342
38343 \end_inset
38344 </cell>
38345 </row>
38346 <row topline="true">
38347 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38348 \begin_inset Text
38349
38350 \begin_layout Standard
38351
38352 \size footnotesize
38353 RETURN
38354 \end_layout
38355
38356 \end_inset
38357 </cell>
38358 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38359 \begin_inset Text
38360
38361 \begin_layout Standard
38362
38363 \size footnotesize
38364 IC_LEFT()
38365 \end_layout
38366
38367 \end_inset
38368 </cell>
38369 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38370 \begin_inset Text
38371
38372 \begin_layout Standard
38373
38374 \size footnotesize
38375 Return the value in operand IC_LEFT 
38376 \end_layout
38377
38378 \end_inset
38379 </cell>
38380 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38381 \begin_inset Text
38382
38383 \begin_layout Standard
38384
38385 \size footnotesize
38386 return IC_LEFT;
38387 \end_layout
38388
38389 \end_inset
38390 </cell>
38391 </row>
38392 <row topline="true">
38393 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38394 \begin_inset Text
38395
38396 \begin_layout Standard
38397
38398 \size footnotesize
38399 LABEL
38400 \end_layout
38401
38402 \end_inset
38403 </cell>
38404 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38405 \begin_inset Text
38406
38407 \begin_layout Standard
38408
38409 \size footnotesize
38410 IC_LABEL() 
38411 \end_layout
38412
38413 \end_inset
38414 </cell>
38415 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38416 \begin_inset Text
38417
38418 \begin_layout Standard
38419
38420 \size footnotesize
38421 Label
38422 \end_layout
38423
38424 \end_inset
38425 </cell>
38426 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38427 \begin_inset Text
38428
38429 \begin_layout Standard
38430
38431 \size footnotesize
38432 IC_LABEL:
38433 \end_layout
38434
38435 \end_inset
38436 </cell>
38437 </row>
38438 <row topline="true">
38439 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38440 \begin_inset Text
38441
38442 \begin_layout Standard
38443
38444 \size footnotesize
38445 GOTO
38446 \end_layout
38447
38448 \end_inset
38449 </cell>
38450 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38451 \begin_inset Text
38452
38453 \begin_layout Standard
38454
38455 \size footnotesize
38456 IC_LABEL() 
38457 \end_layout
38458
38459 \end_inset
38460 </cell>
38461 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38462 \begin_inset Text
38463
38464 \begin_layout Standard
38465
38466 \size footnotesize
38467 Goto label
38468 \end_layout
38469
38470 \end_inset
38471 </cell>
38472 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38473 \begin_inset Text
38474
38475 \begin_layout Standard
38476
38477 \size footnotesize
38478 goto IC_LABEL();
38479 \end_layout
38480
38481 \end_inset
38482 </cell>
38483 </row>
38484 <row topline="true">
38485 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38486 \begin_inset Text
38487
38488 \begin_layout Standard
38489
38490 \size footnotesize
38491 '+'
38492 \end_layout
38493
38494 \end_inset
38495 </cell>
38496 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38497 \begin_inset Text
38498
38499 \begin_layout Standard
38500
38501 \size footnotesize
38502 IC_LEFT() IC_RIGHT() IC_RESULT()
38503 \end_layout
38504
38505 \end_inset
38506 </cell>
38507 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38508 \begin_inset Text
38509
38510 \begin_layout Standard
38511
38512 \size footnotesize
38513 Addition
38514 \end_layout
38515
38516 \end_inset
38517 </cell>
38518 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38519 \begin_inset Text
38520
38521 \begin_layout Standard
38522
38523 \size footnotesize
38524 IC_RESULT = IC_LEFT + IC_RIGHT
38525 \end_layout
38526
38527 \end_inset
38528 </cell>
38529 </row>
38530 <row topline="true">
38531 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38532 \begin_inset Text
38533
38534 \begin_layout Standard
38535
38536 \size footnotesize
38537 '-'
38538 \end_layout
38539
38540 \end_inset
38541 </cell>
38542 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38543 \begin_inset Text
38544
38545 \begin_layout Standard
38546
38547 \size footnotesize
38548 IC_LEFT() IC_RIGHT() IC_RESULT()
38549 \end_layout
38550
38551 \end_inset
38552 </cell>
38553 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38554 \begin_inset Text
38555
38556 \begin_layout Standard
38557
38558 \size footnotesize
38559 Subtraction
38560 \end_layout
38561
38562 \end_inset
38563 </cell>
38564 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38565 \begin_inset Text
38566
38567 \begin_layout Standard
38568
38569 \size footnotesize
38570 IC_RESULT = IC_LEFT - IC_RIGHT 
38571 \end_layout
38572
38573 \end_inset
38574 </cell>
38575 </row>
38576 <row topline="true">
38577 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38578 \begin_inset Text
38579
38580 \begin_layout Standard
38581
38582 \size footnotesize
38583 '*'
38584 \end_layout
38585
38586 \end_inset
38587 </cell>
38588 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38589 \begin_inset Text
38590
38591 \begin_layout Standard
38592
38593 \size footnotesize
38594 IC_LEFT() IC_RIGHT() IC_RESULT()
38595 \end_layout
38596
38597 \end_inset
38598 </cell>
38599 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38600 \begin_inset Text
38601
38602 \begin_layout Standard
38603
38604 \size footnotesize
38605 Multiplication 
38606 \end_layout
38607
38608 \end_inset
38609 </cell>
38610 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38611 \begin_inset Text
38612
38613 \begin_layout Standard
38614
38615 \size footnotesize
38616 IC_RESULT = IC_LEFT * IC_RIGHT;
38617 \end_layout
38618
38619 \end_inset
38620 </cell>
38621 </row>
38622 <row topline="true">
38623 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38624 \begin_inset Text
38625
38626 \begin_layout Standard
38627
38628 \size footnotesize
38629 '/'
38630 \end_layout
38631
38632 \end_inset
38633 </cell>
38634 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38635 \begin_inset Text
38636
38637 \begin_layout Standard
38638
38639 \size footnotesize
38640 IC_LEFT() IC_RIGHT() IC_RESULT()
38641 \end_layout
38642
38643 \end_inset
38644 </cell>
38645 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38646 \begin_inset Text
38647
38648 \begin_layout Standard
38649
38650 \size footnotesize
38651 Division
38652 \end_layout
38653
38654 \end_inset
38655 </cell>
38656 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38657 \begin_inset Text
38658
38659 \begin_layout Standard
38660
38661 \size footnotesize
38662 IC_RESULT = IC_LEFT / IC_RIGHT;
38663 \end_layout
38664
38665 \end_inset
38666 </cell>
38667 </row>
38668 <row topline="true">
38669 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38670 \begin_inset Text
38671
38672 \begin_layout Standard
38673
38674 \size footnotesize
38675 '%'
38676 \end_layout
38677
38678 \end_inset
38679 </cell>
38680 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38681 \begin_inset Text
38682
38683 \begin_layout Standard
38684
38685 \size footnotesize
38686 IC_LEFT() IC_RIGHT() IC_RESULT()
38687 \end_layout
38688
38689 \end_inset
38690 </cell>
38691 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38692 \begin_inset Text
38693
38694 \begin_layout Standard
38695
38696 \size footnotesize
38697 Modulus
38698 \end_layout
38699
38700 \end_inset
38701 </cell>
38702 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38703 \begin_inset Text
38704
38705 \begin_layout Standard
38706
38707 \size footnotesize
38708 IC_RESULT = IC_LEFT % IC_RIGHT;
38709 \end_layout
38710
38711 \end_inset
38712 </cell>
38713 </row>
38714 <row topline="true">
38715 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38716 \begin_inset Text
38717
38718 \begin_layout Standard
38719
38720 \size footnotesize
38721 '<'
38722 \end_layout
38723
38724 \end_inset
38725 </cell>
38726 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38727 \begin_inset Text
38728
38729 \begin_layout Standard
38730
38731 \size footnotesize
38732 IC_LEFT() IC_RIGHT() IC_RESULT()
38733 \end_layout
38734
38735 \end_inset
38736 </cell>
38737 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38738 \begin_inset Text
38739
38740 \begin_layout Standard
38741
38742 \size footnotesize
38743 Less than
38744 \end_layout
38745
38746 \end_inset
38747 </cell>
38748 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38749 \begin_inset Text
38750
38751 \begin_layout Standard
38752
38753 \size footnotesize
38754 IC_RESULT = IC_LEFT < IC_RIGHT;
38755 \end_layout
38756
38757 \end_inset
38758 </cell>
38759 </row>
38760 <row topline="true">
38761 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38762 \begin_inset Text
38763
38764 \begin_layout Standard
38765
38766 \size footnotesize
38767 '>'
38768 \end_layout
38769
38770 \end_inset
38771 </cell>
38772 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38773 \begin_inset Text
38774
38775 \begin_layout Standard
38776
38777 \size footnotesize
38778 IC_LEFT() IC_RIGHT() IC_RESULT()
38779 \end_layout
38780
38781 \end_inset
38782 </cell>
38783 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38784 \begin_inset Text
38785
38786 \begin_layout Standard
38787
38788 \size footnotesize
38789 Greater than 
38790 \end_layout
38791
38792 \end_inset
38793 </cell>
38794 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38795 \begin_inset Text
38796
38797 \begin_layout Standard
38798
38799 \size footnotesize
38800 IC_RESULT = IC_LEFT > IC_RIGHT;
38801 \end_layout
38802
38803 \end_inset
38804 </cell>
38805 </row>
38806 <row topline="true">
38807 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38808 \begin_inset Text
38809
38810 \begin_layout Standard
38811
38812 \size footnotesize
38813 EQ_OP
38814 \end_layout
38815
38816 \end_inset
38817 </cell>
38818 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38819 \begin_inset Text
38820
38821 \begin_layout Standard
38822
38823 \size footnotesize
38824 IC_LEFT() IC_RIGHT() IC_RESULT()
38825 \end_layout
38826
38827 \end_inset
38828 </cell>
38829 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38830 \begin_inset Text
38831
38832 \begin_layout Standard
38833
38834 \size footnotesize
38835 Equal to 
38836 \end_layout
38837
38838 \end_inset
38839 </cell>
38840 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38841 \begin_inset Text
38842
38843 \begin_layout Standard
38844
38845 \size footnotesize
38846 IC_RESULT = IC_LEFT == IC_RIGHT;
38847 \end_layout
38848
38849 \end_inset
38850 </cell>
38851 </row>
38852 <row topline="true">
38853 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38854 \begin_inset Text
38855
38856 \begin_layout Standard
38857
38858 \size footnotesize
38859 AND_OP
38860 \end_layout
38861
38862 \end_inset
38863 </cell>
38864 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38865 \begin_inset Text
38866
38867 \begin_layout Standard
38868
38869 \size footnotesize
38870 IC_LEFT() IC_RIGHT() IC_RESULT() 
38871 \end_layout
38872
38873 \end_inset
38874 </cell>
38875 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38876 \begin_inset Text
38877
38878 \begin_layout Standard
38879
38880 \size footnotesize
38881 Logical and operation
38882 \end_layout
38883
38884 \end_inset
38885 </cell>
38886 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38887 \begin_inset Text
38888
38889 \begin_layout Standard
38890
38891 \size footnotesize
38892 IC_RESULT = IC_LEFT && IC_RIGHT; 
38893 \end_layout
38894
38895 \end_inset
38896 </cell>
38897 </row>
38898 <row topline="true">
38899 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38900 \begin_inset Text
38901
38902 \begin_layout Standard
38903
38904 \size footnotesize
38905 OR_OP
38906 \end_layout
38907
38908 \end_inset
38909 </cell>
38910 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38911 \begin_inset Text
38912
38913 \begin_layout Standard
38914
38915 \size footnotesize
38916 IC_LEFT() IC_RIGHT() IC_RESULT() 
38917 \end_layout
38918
38919 \end_inset
38920 </cell>
38921 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38922 \begin_inset Text
38923
38924 \begin_layout Standard
38925
38926 \size footnotesize
38927 Logical or operation 
38928 \end_layout
38929
38930 \end_inset
38931 </cell>
38932 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38933 \begin_inset Text
38934
38935 \begin_layout Standard
38936
38937 \size footnotesize
38938 IC_RESULT = IC_LEFT || IC_RIGHT; 
38939 \end_layout
38940
38941 \end_inset
38942 </cell>
38943 </row>
38944 <row topline="true">
38945 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38946 \begin_inset Text
38947
38948 \begin_layout Standard
38949
38950 \size footnotesize
38951 '^'
38952 \end_layout
38953
38954 \end_inset
38955 </cell>
38956 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38957 \begin_inset Text
38958
38959 \begin_layout Standard
38960
38961 \size footnotesize
38962 IC_LEFT() IC_RIGHT() IC_RESULT() 
38963 \end_layout
38964
38965 \end_inset
38966 </cell>
38967 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38968 \begin_inset Text
38969
38970 \begin_layout Standard
38971
38972 \size footnotesize
38973 Exclusive OR
38974 \end_layout
38975
38976 \end_inset
38977 </cell>
38978 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38979 \begin_inset Text
38980
38981 \begin_layout Standard
38982
38983 \size footnotesize
38984 IC_RESULT = IC_LEFT ^ IC_RIGHT;
38985 \end_layout
38986
38987 \end_inset
38988 </cell>
38989 </row>
38990 <row topline="true">
38991 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38992 \begin_inset Text
38993
38994 \begin_layout Standard
38995
38996 \size footnotesize
38997 '|'
38998 \end_layout
38999
39000 \end_inset
39001 </cell>
39002 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39003 \begin_inset Text
39004
39005 \begin_layout Standard
39006
39007 \size footnotesize
39008 IC_LEFT() IC_RIGHT() IC_RESULT() 
39009 \end_layout
39010
39011 \end_inset
39012 </cell>
39013 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39014 \begin_inset Text
39015
39016 \begin_layout Standard
39017
39018 \size footnotesize
39019 Bitwise OR 
39020 \end_layout
39021
39022 \end_inset
39023 </cell>
39024 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39025 \begin_inset Text
39026
39027 \begin_layout Standard
39028
39029 \size footnotesize
39030 IC_RESULT = IC_LEFT | IC_RIGHT;
39031 \end_layout
39032
39033 \end_inset
39034 </cell>
39035 </row>
39036 <row topline="true">
39037 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39038 \begin_inset Text
39039
39040 \begin_layout Standard
39041
39042 \size footnotesize
39043 BITWISEAND
39044 \end_layout
39045
39046 \end_inset
39047 </cell>
39048 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39049 \begin_inset Text
39050
39051 \begin_layout Standard
39052
39053 \size footnotesize
39054 IC_LEFT() IC_RIGHT() IC_RESULT()
39055 \end_layout
39056
39057 \end_inset
39058 </cell>
39059 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39060 \begin_inset Text
39061
39062 \begin_layout Standard
39063
39064 \size footnotesize
39065 Bitwise AND 
39066 \end_layout
39067
39068 \end_inset
39069 </cell>
39070 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39071 \begin_inset Text
39072
39073 \begin_layout Standard
39074
39075 \size footnotesize
39076 IC_RESULT = IC_LEFT & IC_RIGHT;
39077 \end_layout
39078
39079 \end_inset
39080 </cell>
39081 </row>
39082 <row topline="true">
39083 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39084 \begin_inset Text
39085
39086 \begin_layout Standard
39087
39088 \size footnotesize
39089 LEFT_OP
39090 \end_layout
39091
39092 \end_inset
39093 </cell>
39094 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39095 \begin_inset Text
39096
39097 \begin_layout Standard
39098
39099 \size footnotesize
39100 IC_LEFT() IC_RIGHT() IC_RESULT()
39101 \end_layout
39102
39103 \end_inset
39104 </cell>
39105 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39106 \begin_inset Text
39107
39108 \begin_layout Standard
39109
39110 \size footnotesize
39111 Left shift 
39112 \end_layout
39113
39114 \end_inset
39115 </cell>
39116 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39117 \begin_inset Text
39118
39119 \begin_layout Standard
39120
39121 \size footnotesize
39122 IC_RESULT = IC_LEFT << IC_RIGHT 
39123 \end_layout
39124
39125 \end_inset
39126 </cell>
39127 </row>
39128 <row topline="true">
39129 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39130 \begin_inset Text
39131
39132 \begin_layout Standard
39133
39134 \size footnotesize
39135 RIGHT_OP
39136 \end_layout
39137
39138 \end_inset
39139 </cell>
39140 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39141 \begin_inset Text
39142
39143 \begin_layout Standard
39144
39145 \size footnotesize
39146 IC_LEFT() IC_RIGHT() IC_RESULT()
39147 \end_layout
39148
39149 \end_inset
39150 </cell>
39151 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39152 \begin_inset Text
39153
39154 \begin_layout Standard
39155
39156 \size footnotesize
39157 Right shift
39158 \end_layout
39159
39160 \end_inset
39161 </cell>
39162 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39163 \begin_inset Text
39164
39165 \begin_layout Standard
39166
39167 \size footnotesize
39168 IC_RESULT = IC_LEFT >> IC_RIGHT 
39169 \end_layout
39170
39171 \end_inset
39172 </cell>
39173 </row>
39174 <row topline="true">
39175 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39176 \begin_inset Text
39177
39178 \begin_layout Standard
39179
39180 \size footnotesize
39181 GET_VALUE_
39182 \newline
39183 AT_ ADDRESS
39184 \end_layout
39185
39186 \end_inset
39187 </cell>
39188 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39189 \begin_inset Text
39190
39191 \begin_layout Standard
39192
39193 \size footnotesize
39194 IC_LEFT() IC_RESULT()
39195 \end_layout
39196
39197 \end_inset
39198 </cell>
39199 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39200 \begin_inset Text
39201
39202 \begin_layout Standard
39203
39204 \size footnotesize
39205 Indirect fetch 
39206 \end_layout
39207
39208 \end_inset
39209 </cell>
39210 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39211 \begin_inset Text
39212
39213 \begin_layout Standard
39214
39215 \size footnotesize
39216 IC_RESULT = (*IC_LEFT);
39217 \end_layout
39218
39219 \end_inset
39220 </cell>
39221 </row>
39222 <row topline="true">
39223 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39224 \begin_inset Text
39225
39226 \begin_layout Standard
39227
39228 \size footnotesize
39229 POINTER_SET
39230 \end_layout
39231
39232 \end_inset
39233 </cell>
39234 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39235 \begin_inset Text
39236
39237 \begin_layout Standard
39238
39239 \size footnotesize
39240 IC_RIGHT() IC_RESULT() 
39241 \end_layout
39242
39243 \end_inset
39244 </cell>
39245 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39246 \begin_inset Text
39247
39248 \begin_layout Standard
39249
39250 \size footnotesize
39251 Indirect set
39252 \end_layout
39253
39254 \end_inset
39255 </cell>
39256 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39257 \begin_inset Text
39258
39259 \begin_layout Standard
39260
39261 \size footnotesize
39262 (*IC_RESULT) = IC_RIGHT;
39263 \end_layout
39264
39265 \end_inset
39266 </cell>
39267 </row>
39268 <row topline="true">
39269 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39270 \begin_inset Text
39271
39272 \begin_layout Standard
39273
39274 \size footnotesize
39275 '='
39276 \end_layout
39277
39278 \end_inset
39279 </cell>
39280 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39281 \begin_inset Text
39282
39283 \begin_layout Standard
39284
39285 \size footnotesize
39286 IC_RIGHT() IC_RESULT()
39287 \end_layout
39288
39289 \end_inset
39290 </cell>
39291 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39292 \begin_inset Text
39293
39294 \begin_layout Standard
39295
39296 \size footnotesize
39297 Assignment
39298 \end_layout
39299
39300 \end_inset
39301 </cell>
39302 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39303 \begin_inset Text
39304
39305 \begin_layout Standard
39306
39307 \size footnotesize
39308 IC_RESULT = IC_RIGHT;
39309 \end_layout
39310
39311 \end_inset
39312 </cell>
39313 </row>
39314 <row topline="true">
39315 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39316 \begin_inset Text
39317
39318 \begin_layout Standard
39319
39320 \size footnotesize
39321 IFX
39322 \end_layout
39323
39324 \end_inset
39325 </cell>
39326 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39327 \begin_inset Text
39328
39329 \begin_layout Standard
39330
39331 \size footnotesize
39332 IC_COND IC_TRUE IC_LABEL
39333 \end_layout
39334
39335 \end_inset
39336 </cell>
39337 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39338 \begin_inset Text
39339
39340 \begin_layout Standard
39341
39342 \size footnotesize
39343 Conditional jump.
39344  If true label is present then jump to true label if condition is true else
39345  jump to false label if condition is false 
39346 \end_layout
39347
39348 \end_inset
39349 </cell>
39350 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39351 \begin_inset Text
39352
39353 \begin_layout Standard
39354
39355 \size footnotesize
39356 if (IC_COND) goto IC_TRUE; 
39357 \newline
39358 \InsetSpace ~
39359 \InsetSpace ~
39360 Or 
39361 \newline
39362 If (!IC_COND) goto IC_FALSE;
39363 \end_layout
39364
39365 \end_inset
39366 </cell>
39367 </row>
39368 <row topline="true">
39369 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39370 \begin_inset Text
39371
39372 \begin_layout Standard
39373
39374 \size footnotesize
39375 ADDRESS_OF
39376 \end_layout
39377
39378 \end_inset
39379 </cell>
39380 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39381 \begin_inset Text
39382
39383 \begin_layout Standard
39384
39385 \size footnotesize
39386 IC_LEFT() IC_RESULT()
39387 \end_layout
39388
39389 \end_inset
39390 </cell>
39391 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39392 \begin_inset Text
39393
39394 \begin_layout Standard
39395
39396 \size footnotesize
39397 Address of 
39398 \end_layout
39399
39400 \end_inset
39401 </cell>
39402 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39403 \begin_inset Text
39404
39405 \begin_layout Standard
39406
39407 \size footnotesize
39408 IC_RESULT = &IC_LEFT();
39409 \end_layout
39410
39411 \end_inset
39412 </cell>
39413 </row>
39414 <row topline="true">
39415 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39416 \begin_inset Text
39417
39418 \begin_layout Standard
39419
39420 \size footnotesize
39421 JUMPTABLE
39422 \end_layout
39423
39424 \end_inset
39425 </cell>
39426 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39427 \begin_inset Text
39428
39429 \begin_layout Standard
39430
39431 \size footnotesize
39432 IC_JTCOND IC_JTLABELS
39433 \end_layout
39434
39435 \end_inset
39436 </cell>
39437 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39438 \begin_inset Text
39439
39440 \begin_layout Standard
39441
39442 \size footnotesize
39443 Jump to list of labels depending on the value of JTCOND
39444 \end_layout
39445
39446 \end_inset
39447 </cell>
39448 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39449 \begin_inset Text
39450
39451 \begin_layout Standard
39452
39453 \size footnotesize
39454 Switch statement
39455 \end_layout
39456
39457 \end_inset
39458 </cell>
39459 </row>
39460 <row topline="true">
39461 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39462 \begin_inset Text
39463
39464 \begin_layout Standard
39465
39466 \size footnotesize
39467 CAST
39468 \end_layout
39469
39470 \end_inset
39471 </cell>
39472 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39473 \begin_inset Text
39474
39475 \begin_layout Standard
39476
39477 \size footnotesize
39478 IC_RIGHT() IC_LEFT() IC_RESULT()
39479 \end_layout
39480
39481 \end_inset
39482 </cell>
39483 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39484 \begin_inset Text
39485
39486 \begin_layout Standard
39487
39488 \size footnotesize
39489 Cast types 
39490 \end_layout
39491
39492 \end_inset
39493 </cell>
39494 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39495 \begin_inset Text
39496
39497 \begin_layout Standard
39498
39499 \size footnotesize
39500 IC_RESULT = (typeof IC_LEFT) IC_RIGHT;
39501 \end_layout
39502
39503 \end_inset
39504 </cell>
39505 </row>
39506 <row topline="true">
39507 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39508 \begin_inset Text
39509
39510 \begin_layout Standard
39511
39512 \size footnotesize
39513 SEND
39514 \end_layout
39515
39516 \end_inset
39517 </cell>
39518 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39519 \begin_inset Text
39520
39521 \begin_layout Standard
39522
39523 \size footnotesize
39524 IC_LEFT()
39525 \end_layout
39526
39527 \end_inset
39528 </cell>
39529 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39530 \begin_inset Text
39531
39532 \begin_layout Standard
39533
39534 \size footnotesize
39535 This is used for passing parameters in registers; 
39536 \newline
39537 move IC_LEFT to the next
39538  available parameter register.
39539 \end_layout
39540
39541 \end_inset
39542 </cell>
39543 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39544 \begin_inset Text
39545
39546 \begin_layout Standard
39547
39548 \size footnotesize
39549 None
39550 \end_layout
39551
39552 \end_inset
39553 </cell>
39554 </row>
39555 <row topline="true">
39556 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39557 \begin_inset Text
39558
39559 \begin_layout Standard
39560
39561 \size footnotesize
39562 RECV
39563 \end_layout
39564
39565 \end_inset
39566 </cell>
39567 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39568 \begin_inset Text
39569
39570 \begin_layout Standard
39571
39572 \size footnotesize
39573 IC_RESULT()
39574 \end_layout
39575
39576 \end_inset
39577 </cell>
39578 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39579 \begin_inset Text
39580
39581 \begin_layout Standard
39582
39583 \size footnotesize
39584 This is used for receiving parameters passed in registers;
39585 \newline
39586 Move the values
39587  in the next parameter register to IC_RESULT 
39588 \end_layout
39589
39590 \end_inset
39591 </cell>
39592 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39593 \begin_inset Text
39594
39595 \begin_layout Standard
39596
39597 \size footnotesize
39598 None
39599 \end_layout
39600
39601 \end_inset
39602 </cell>
39603 </row>
39604 <row topline="true" bottomline="true">
39605 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39606 \begin_inset Text
39607
39608 \begin_layout Standard
39609
39610 \shape slanted
39611 \size footnotesize
39612 (some more have been added)
39613 \end_layout
39614
39615 \end_inset
39616 </cell>
39617 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39618 \begin_inset Text
39619
39620 \begin_layout Standard
39621
39622 \end_layout
39623
39624 \end_inset
39625 </cell>
39626 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39627 \begin_inset Text
39628
39629 \begin_layout Standard
39630
39631 \end_layout
39632
39633 \end_inset
39634 </cell>
39635 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39636 \begin_inset Text
39637
39638 \begin_layout Standard
39639
39640 \shape slanted
39641 \size footnotesize
39642 see f.e.
39643  
39644 \family typewriter
39645 gen51Code()
39646 \family default
39647  in 
39648 \family typewriter
39649 src/mcs51/gen.c
39650 \end_layout
39651
39652 \end_inset
39653 </cell>
39654 </row>
39655 </lyxtabular>
39656
39657 \end_inset
39658
39659
39660 \end_layout
39661
39662 \begin_layout Standard
39663 \begin_inset Note Note
39664 status collapsed
39665
39666 \begin_layout Standard
39667 In the original article Figure II was announced to be downloadable on 
39668 \shape italic
39669 Circuit Cellar
39670 \shape default
39671 's web site.
39672  ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2000/121/dutta.ZIP
39673 \end_layout
39674
39675 \end_inset
39676
39677
39678 \end_layout
39679
39680 \begin_layout Paragraph*
39681 ICode Example
39682 \begin_inset LatexCommand \index{iCode}
39683
39684 \end_inset
39685
39686
39687 \end_layout
39688
39689 \begin_layout Standard
39690 This section shows some details of iCode.
39691  The example C code does not do anything useful; it is used as an example
39692  to illustrate the intermediate code generated by the compiler.
39693 \end_layout
39694
39695 \begin_layout Verse
39696
39697 \family typewriter
39698 1.\InsetSpace ~
39699 xdata int * p;
39700 \newline
39701 2.\InsetSpace ~
39702 int gint;
39703 \newline
39704 3.\InsetSpace ~
39705 /* This function does nothing useful.
39706  It is used
39707 \newline
39708 4.\InsetSpace ~
39709 \InsetSpace ~
39710 \InsetSpace ~
39711 \InsetSpace ~
39712 for the purpose of explaining iCode */
39713 \newline
39714 5.\InsetSpace ~
39715 short function (data
39716  int *x)
39717 \newline
39718 6.\InsetSpace ~
39719 {
39720 \newline
39721 7.\InsetSpace ~
39722 \InsetSpace ~
39723 \InsetSpace ~
39724 short i=10; \InsetSpace ~
39725 \InsetSpace ~
39726 /* dead initialization eliminated */
39727 \newline
39728 8.\InsetSpace ~
39729 \InsetSpace ~
39730 \InsetSpace ~
39731 short sum=10;
39732  /* dead initialization eliminated */
39733 \newline
39734 9.\InsetSpace ~
39735 \InsetSpace ~
39736 \InsetSpace ~
39737 short mul;
39738 \newline
39739 10.\InsetSpace ~
39740 \InsetSpace ~
39741 int j ;
39742 \newline
39743 11.\InsetSpace ~
39744 \InsetSpace ~
39745 while (*x) *x++
39746  = *p++; 
39747 \newline
39748 12.\InsetSpace ~
39749 \InsetSpace ~
39750 \InsetSpace ~
39751 \InsetSpace ~
39752 sum = 0 ; 
39753 \newline
39754 13.\InsetSpace ~
39755 \InsetSpace ~
39756 mul = 0;
39757 \newline
39758 14.\InsetSpace ~
39759 \InsetSpace ~
39760 /* compiler detects i,j to be induction
39761  variables */
39762 \newline
39763 15.\InsetSpace ~
39764 \InsetSpace ~
39765 for (i = 0, j = 10 ; i < 10 ; i++, j
39766 \family default
39767 -
39768 \begin_inset ERT
39769 status collapsed
39770
39771 \begin_layout Standard
39772
39773
39774 \backslash
39775 /
39776 \end_layout
39777
39778 \end_inset
39779
39780 -
39781 \family typewriter
39782 ) {
39783 \newline
39784 16.\InsetSpace ~
39785 \InsetSpace ~
39786 \InsetSpace ~
39787 \InsetSpace ~
39788 sum += i;
39789 \newline
39790 17.\InsetSpace ~
39791 \InsetSpace ~
39792 \InsetSpace ~
39793 \InsetSpace ~
39794 mul += i * 3; \InsetSpace ~
39795 \InsetSpace ~
39796 /* this multiplication remains */
39797 \newline
39798 18.\InsetSpace ~
39799 \InsetSpace ~
39800 \InsetSpace ~
39801 \InsetSpace ~
39802 gint +=
39803  j * 3;\InsetSpace ~
39804 \InsetSpace ~
39805 /* this multiplication changed to addition */
39806 \newline
39807 19.\InsetSpace ~
39808 \InsetSpace ~
39809 }
39810 \newline
39811 20.\InsetSpace ~
39812 \InsetSpace ~
39813 return sum+mul;
39814 \newline
39815 21.\InsetSpace ~
39816 }
39817 \end_layout
39818
39819 \begin_layout Standard
39820 In addition to the operands each iCode contains information about the filename
39821  and line it corresponds to in the source file.
39822  The first field in the listing should be interpreted as follows:
39823 \newline
39824
39825 \shape italic
39826 \size footnotesize
39827 Filename(linenumber: iCode Execution sequence number : ICode hash table
39828  key : loop depth of the iCode).
39829 \shape default
39830 \size default
39831
39832 \newline
39833 Then follows the human readable form of the ICode operation.
39834  Each operand of this triplet form can be of three basic types a) compiler
39835  generated temporary b) user defined variable c) a constant value.
39836  Note that local variables and parameters are replaced by compiler generated
39837  temporaries.
39838  Live ranges
39839 \begin_inset LatexCommand \index{Live range analysis}
39840
39841 \end_inset
39842
39843  are computed only for temporaries (i.e.
39844  live ranges are not computed for global variables).
39845  Registers
39846 \begin_inset LatexCommand \index{Register allocation}
39847
39848 \end_inset
39849
39850  are allocated for temporaries only.
39851  Operands are formatted in the following manner:
39852 \newline
39853
39854 \shape italic
39855 \size footnotesize
39856 Operand Name [lr live-from : live-to ] { type information } [ registers
39857  allocated ].
39858 \shape default
39859 \size default
39860
39861 \newline
39862 As mentioned earlier the live ranges are computed in terms of the execution
39863  sequence number of the iCodes, for example 
39864 \newline
39865 the iTemp0 is live from (i.e.
39866  first defined in iCode with execution sequence number 3, and is last used
39867  in the iCode with sequence number 5).
39868  For induction variables such as iTemp21 the live range computation extends
39869  the lifetime from the start to the end of the loop.
39870 \newline
39871 The register allocator
39872  used the live range information to allocate registers, the same registers
39873  may be used for different temporaries if their live ranges do not overlap,
39874  for example r0 is allocated to both iTemp6 and to iTemp17 since their live
39875  ranges do not overlap.
39876  In addition the allocator also takes into consideration the type and usage
39877  of a temporary, for example itemp6 is a pointer to near space and is used
39878  as to fetch data from (i.e.
39879  used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer register (r0).
39880  Some short lived temporaries are allocated to special registers which have
39881  meaning to the code generator e.g.
39882  iTemp13 is allocated to a pseudo register CC which tells the back end that
39883  the temporary is used only for a conditional jump the code generation makes
39884  use of this information to optimize a compare and jump ICode.
39885 \newline
39886 There are several
39887  loop optimizations
39888 \begin_inset LatexCommand \index{Loop optimization}
39889
39890 \end_inset
39891
39892  performed by the compiler.
39893  It can detect induction variables iTemp21(i) and iTemp23(j).
39894  Also note the compiler does selective strength reduction
39895 \begin_inset LatexCommand \index{Strength reduction}
39896
39897 \end_inset
39898
39899 , i.e.
39900  the multiplication of an induction variable in line 18 (gint = j * 3) is
39901  changed to addition, a new temporary iTemp17 is allocated and assigned
39902  a initial value, a constant 3 is then added for each iteration of the loop.
39903  The compiler does not change the multiplication
39904 \begin_inset LatexCommand \index{Multiplication}
39905
39906 \end_inset
39907
39908  in line 17 however since the processor does support an 8 * 8 bit multiplication.
39909 \newline
39910
39911 Note the dead code elimination
39912 \begin_inset LatexCommand \index{Dead-code elimination}
39913
39914 \end_inset
39915
39916  optimization eliminated the dead assignments in line 7 & 8 to I and sum
39917  respectively.
39918 \newline
39919
39920 \end_layout
39921
39922 \begin_layout Standard
39923
39924 \size footnotesize
39925 Sample.c (5:1:0:0) _entry($9) :
39926 \end_layout
39927
39928 \begin_layout Standard
39929
39930 \size footnotesize
39931 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
39932 \end_layout
39933
39934 \begin_layout Standard
39935
39936 \size footnotesize
39937 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv 
39938 \end_layout
39939
39940 \begin_layout Standard
39941
39942 \size footnotesize
39943 Sample.c(11:4:53:0) preHeaderLbl0($11) :
39944 \end_layout
39945
39946 \begin_layout Standard
39947
39948 \size footnotesize
39949 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
39950  * int}[r2]
39951 \end_layout
39952
39953 \begin_layout Standard
39954
39955 \size footnotesize
39956 Sample.c(11:6:5:1) _whilecontinue_0($1) :
39957 \end_layout
39958
39959 \begin_layout Standard
39960
39961 \size footnotesize
39962 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
39963  int}[r0]]
39964 \end_layout
39965
39966 \begin_layout Standard
39967
39968 \size footnotesize
39969 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
39970 \end_layout
39971
39972 \begin_layout Standard
39973
39974 \size footnotesize
39975 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
39976  * int}
39977 \end_layout
39978
39979 \begin_layout Standard
39980
39981 \size footnotesize
39982 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
39983  {short}
39984 \end_layout
39985
39986 \begin_layout Standard
39987
39988 \size footnotesize
39989 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
39990  * int}[DPTR]]
39991 \end_layout
39992
39993 \begin_layout Standard
39994
39995 \size footnotesize
39996 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
39997 }[r2 r3]
39998 \end_layout
39999
40000 \begin_layout Standard
40001
40002 \size footnotesize
40003 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
40004  * int}[r0] + 0x2 {short}
40005 \end_layout
40006
40007 \begin_layout Standard
40008
40009 \size footnotesize
40010 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
40011 \end_layout
40012
40013 \begin_layout Standard
40014
40015 \size footnotesize
40016 Sample.c(11:17:21:0)_whilebreak_0($3) :
40017 \end_layout
40018
40019 \begin_layout Standard
40020
40021 \size footnotesize
40022 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
40023 \end_layout
40024
40025 \begin_layout Standard
40026
40027 \size footnotesize
40028 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
40029 \end_layout
40030
40031 \begin_layout Standard
40032
40033 \size footnotesize
40034 Sample.c(15:20:54:0)preHeaderLbl1($13) :
40035 \end_layout
40036
40037 \begin_layout Standard
40038
40039 \size footnotesize
40040 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
40041 \end_layout
40042
40043 \begin_layout Standard
40044
40045 \size footnotesize
40046 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
40047 \end_layout
40048
40049 \begin_layout Standard
40050
40051 \size footnotesize
40052 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
40053 \end_layout
40054
40055 \begin_layout Standard
40056
40057 \size footnotesize
40058 Sample.c(15:24:26:1)_forcond_0($4) :
40059 \end_layout
40060
40061 \begin_layout Standard
40062
40063 \size footnotesize
40064 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
40065  < 0xa {short}
40066 \end_layout
40067
40068 \begin_layout Standard
40069
40070 \size footnotesize
40071 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
40072 \end_layout
40073
40074 \begin_layout Standard
40075
40076 \size footnotesize
40077 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
40078  + ITemp21 [lr21:38]{short}[r4]
40079 \end_layout
40080
40081 \begin_layout Standard
40082
40083 \size footnotesize
40084 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
40085  * 0x3 {short}
40086 \end_layout
40087
40088 \begin_layout Standard
40089
40090 \size footnotesize
40091 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
40092  + iTemp15 [lr29:30]{short}[r1]
40093 \end_layout
40094
40095 \begin_layout Standard
40096
40097 \size footnotesize
40098 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
40099  r0]- 0x3 {short}
40100 \end_layout
40101
40102 \begin_layout Standard
40103
40104 \size footnotesize
40105 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
40106 int}[r7 r0]
40107 \end_layout
40108
40109 \begin_layout Standard
40110
40111 \size footnotesize
40112 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
40113  + 0x1 {short}
40114 \end_layout
40115
40116 \begin_layout Standard
40117
40118 \size footnotesize
40119 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
40120  r6]- 0x1 {short}
40121 \end_layout
40122
40123 \begin_layout Standard
40124
40125 \size footnotesize
40126 Sample.c(19:38:47:1) goto _forcond_0($4)
40127 \end_layout
40128
40129 \begin_layout Standard
40130
40131 \size footnotesize
40132 Sample.c(19:39:48:0)_forbreak_0($7) :
40133 \end_layout
40134
40135 \begin_layout Standard
40136
40137 \size footnotesize
40138 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
40139  + ITemp11 [lr19:40]{short}[r3]
40140 \end_layout
40141
40142 \begin_layout Standard
40143
40144 \size footnotesize
40145 Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
40146 \end_layout
40147
40148 \begin_layout Standard
40149
40150 \size footnotesize
40151 Sample.c(20:42:51:0)_return($8) :
40152 \end_layout
40153
40154 \begin_layout Standard
40155
40156 \size footnotesize
40157 Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
40158 \size default
40159
40160 \newline
40161
40162 \newline
40163 Finally the code generated for this function:
40164 \newline
40165
40166 \end_layout
40167
40168 \begin_layout Standard
40169
40170 \size footnotesize
40171 .area DSEG (DATA)
40172 \end_layout
40173
40174 \begin_layout Standard
40175
40176 \size footnotesize
40177 _p::
40178 \end_layout
40179
40180 \begin_layout Standard
40181
40182 \size footnotesize
40183 \InsetSpace ~
40184 \InsetSpace ~
40185 .ds 2
40186 \end_layout
40187
40188 \begin_layout Standard
40189
40190 \size footnotesize
40191 _gint::
40192 \end_layout
40193
40194 \begin_layout Standard
40195
40196 \size footnotesize
40197 \InsetSpace ~
40198 \InsetSpace ~
40199 .ds 2
40200 \end_layout
40201
40202 \begin_layout Standard
40203
40204 \size footnotesize
40205 ; sample.c 5
40206 \end_layout
40207
40208 \begin_layout Standard
40209
40210 \size footnotesize
40211 ; ----------------------------------------------
40212 \end_layout
40213
40214 \begin_layout Standard
40215
40216 \size footnotesize
40217 ; function function
40218 \end_layout
40219
40220 \begin_layout Standard
40221
40222 \size footnotesize
40223 ; ----------------------------------------------
40224 \end_layout
40225
40226 \begin_layout Standard
40227
40228 \size footnotesize
40229 _function:
40230 \end_layout
40231
40232 \begin_layout Standard
40233
40234 \size footnotesize
40235 ; iTemp0 [lr3:5]{_near * int}[r2] = recv 
40236 \end_layout
40237
40238 \begin_layout Standard
40239
40240 \size footnotesize
40241 \InsetSpace ~
40242 \InsetSpace ~
40243 mov r2,dpl
40244 \end_layout
40245
40246 \begin_layout Standard
40247
40248 \size footnotesize
40249 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
40250 \end_layout
40251
40252 \begin_layout Standard
40253
40254 \size footnotesize
40255 \InsetSpace ~
40256 \InsetSpace ~
40257 mov ar0,r2
40258 \end_layout
40259
40260 \begin_layout Standard
40261
40262 \size footnotesize
40263 ;_whilecontinue_0($1) :
40264 \end_layout
40265
40266 \begin_layout Standard
40267
40268 \size footnotesize
40269 00101$:
40270 \end_layout
40271
40272 \begin_layout Standard
40273
40274 \size footnotesize
40275 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
40276 \end_layout
40277
40278 \begin_layout Standard
40279
40280 \size footnotesize
40281 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
40282 \end_layout
40283
40284 \begin_layout Standard
40285
40286 \size footnotesize
40287 \InsetSpace ~
40288 \InsetSpace ~
40289 mov ar2,@r0
40290 \end_layout
40291
40292 \begin_layout Standard
40293
40294 \size footnotesize
40295 \InsetSpace ~
40296 \InsetSpace ~
40297 inc r0
40298 \end_layout
40299
40300 \begin_layout Standard
40301
40302 \size footnotesize
40303 \InsetSpace ~
40304 \InsetSpace ~
40305 mov ar3,@r0
40306 \end_layout
40307
40308 \begin_layout Standard
40309
40310 \size footnotesize
40311 \InsetSpace ~
40312 \InsetSpace ~
40313 dec r0
40314 \end_layout
40315
40316 \begin_layout Standard
40317
40318 \size footnotesize
40319 \InsetSpace ~
40320 \InsetSpace ~
40321 mov a,r2
40322 \end_layout
40323
40324 \begin_layout Standard
40325
40326 \size footnotesize
40327 \InsetSpace ~
40328 \InsetSpace ~
40329 orl a,r3
40330 \end_layout
40331
40332 \begin_layout Standard
40333
40334 \size footnotesize
40335 \InsetSpace ~
40336 \InsetSpace ~
40337 jz 00103$
40338 \end_layout
40339
40340 \begin_layout Standard
40341
40342 \size footnotesize
40343 00114$:
40344 \end_layout
40345
40346 \begin_layout Standard
40347
40348 \size footnotesize
40349 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
40350 \end_layout
40351
40352 \begin_layout Standard
40353
40354 \size footnotesize
40355 \InsetSpace ~
40356 \InsetSpace ~
40357 mov dpl,_p
40358 \end_layout
40359
40360 \begin_layout Standard
40361
40362 \size footnotesize
40363 \InsetSpace ~
40364 \InsetSpace ~
40365 mov dph,(_p + 1)
40366 \end_layout
40367
40368 \begin_layout Standard
40369
40370 \size footnotesize
40371 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
40372 \end_layout
40373
40374 \begin_layout Standard
40375
40376 \size footnotesize
40377 \InsetSpace ~
40378 \InsetSpace ~
40379 mov a,#0x02
40380 \end_layout
40381
40382 \begin_layout Standard
40383
40384 \size footnotesize
40385 \InsetSpace ~
40386 \InsetSpace ~
40387 add a,_p
40388 \end_layout
40389
40390 \begin_layout Standard
40391
40392 \size footnotesize
40393 \InsetSpace ~
40394 \InsetSpace ~
40395 mov _p,a
40396 \end_layout
40397
40398 \begin_layout Standard
40399
40400 \size footnotesize
40401 \InsetSpace ~
40402 \InsetSpace ~
40403 clr a
40404 \end_layout
40405
40406 \begin_layout Standard
40407
40408 \size footnotesize
40409 \InsetSpace ~
40410 \InsetSpace ~
40411 addc a,(_p + 1)
40412 \end_layout
40413
40414 \begin_layout Standard
40415
40416 \size footnotesize
40417 \InsetSpace ~
40418 \InsetSpace ~
40419 mov (_p + 1),a
40420 \end_layout
40421
40422 \begin_layout Standard
40423
40424 \size footnotesize
40425 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
40426 \end_layout
40427
40428 \begin_layout Standard
40429
40430 \size footnotesize
40431 \InsetSpace ~
40432 \InsetSpace ~
40433 movx a,@dptr
40434 \end_layout
40435
40436 \begin_layout Standard
40437
40438 \size footnotesize
40439 \InsetSpace ~
40440 \InsetSpace ~
40441 mov r2,a
40442 \end_layout
40443
40444 \begin_layout Standard
40445
40446 \size footnotesize
40447 \InsetSpace ~
40448 \InsetSpace ~
40449 inc dptr
40450 \end_layout
40451
40452 \begin_layout Standard
40453
40454 \size footnotesize
40455 \InsetSpace ~
40456 \InsetSpace ~
40457 movx a,@dptr
40458 \end_layout
40459
40460 \begin_layout Standard
40461
40462 \size footnotesize
40463 \InsetSpace ~
40464 \InsetSpace ~
40465 mov r3,a
40466 \end_layout
40467
40468 \begin_layout Standard
40469
40470 \size footnotesize
40471 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
40472 \end_layout
40473
40474 \begin_layout Standard
40475
40476 \size footnotesize
40477 \InsetSpace ~
40478 \InsetSpace ~
40479 mov @r0,ar2
40480 \end_layout
40481
40482 \begin_layout Standard
40483
40484 \size footnotesize
40485 \InsetSpace ~
40486 \InsetSpace ~
40487 inc r0
40488 \end_layout
40489
40490 \begin_layout Standard
40491
40492 \size footnotesize
40493 \InsetSpace ~
40494 \InsetSpace ~
40495 mov @r0,ar3
40496 \end_layout
40497
40498 \begin_layout Standard
40499
40500 \size footnotesize
40501 ; iTemp6 [lr5:16]{_near * int}[r0] = 
40502 \end_layout
40503
40504 \begin_layout Standard
40505
40506 \size footnotesize
40507 ; iTemp6 [lr5:16]{_near * int}[r0] + 
40508 \end_layout
40509
40510 \begin_layout Standard
40511
40512 \size footnotesize
40513 ; 0x2 {short}
40514 \end_layout
40515
40516 \begin_layout Standard
40517
40518 \size footnotesize
40519 \InsetSpace ~
40520 \InsetSpace ~
40521 inc r0
40522 \end_layout
40523
40524 \begin_layout Standard
40525
40526 \size footnotesize
40527 ; goto _whilecontinue_0($1)
40528 \end_layout
40529
40530 \begin_layout Standard
40531
40532 \size footnotesize
40533 \InsetSpace ~
40534 \InsetSpace ~
40535 sjmp 00101$
40536 \end_layout
40537
40538 \begin_layout Standard
40539
40540 \size footnotesize
40541 ; _whilebreak_0($3) :
40542 \end_layout
40543
40544 \begin_layout Standard
40545
40546 \size footnotesize
40547 00103$:
40548 \end_layout
40549
40550 \begin_layout Standard
40551
40552 \size footnotesize
40553 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
40554 \end_layout
40555
40556 \begin_layout Standard
40557
40558 \size footnotesize
40559 \InsetSpace ~
40560 \InsetSpace ~
40561 mov r2,#0x00
40562 \end_layout
40563
40564 \begin_layout Standard
40565
40566 \size footnotesize
40567 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
40568 \end_layout
40569
40570 \begin_layout Standard
40571
40572 \size footnotesize
40573 \InsetSpace ~
40574 \InsetSpace ~
40575 mov r3,#0x00
40576 \end_layout
40577
40578 \begin_layout Standard
40579
40580 \size footnotesize
40581 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
40582 \end_layout
40583
40584 \begin_layout Standard
40585
40586 \size footnotesize
40587 \InsetSpace ~
40588 \InsetSpace ~
40589 mov r4,#0x00
40590 \end_layout
40591
40592 \begin_layout Standard
40593
40594 \size footnotesize
40595 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
40596 \end_layout
40597
40598 \begin_layout Standard
40599
40600 \size footnotesize
40601 \InsetSpace ~
40602 \InsetSpace ~
40603 mov r5,#0x0A
40604 \end_layout
40605
40606 \begin_layout Standard
40607
40608 \size footnotesize
40609 \InsetSpace ~
40610 \InsetSpace ~
40611 mov r6,#0x00
40612 \end_layout
40613
40614 \begin_layout Standard
40615
40616 \size footnotesize
40617 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
40618 \end_layout
40619
40620 \begin_layout Standard
40621
40622 \size footnotesize
40623 \InsetSpace ~
40624 \InsetSpace ~
40625 mov r7,#0x1E
40626 \end_layout
40627
40628 \begin_layout Standard
40629
40630 \size footnotesize
40631 \InsetSpace ~
40632 \InsetSpace ~
40633 mov r0,#0x00
40634 \end_layout
40635
40636 \begin_layout Standard
40637
40638 \size footnotesize
40639 ; _forcond_0($4) :
40640 \end_layout
40641
40642 \begin_layout Standard
40643
40644 \size footnotesize
40645 00104$:
40646 \end_layout
40647
40648 \begin_layout Standard
40649
40650 \size footnotesize
40651 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
40652 \end_layout
40653
40654 \begin_layout Standard
40655
40656 \size footnotesize
40657 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
40658 \end_layout
40659
40660 \begin_layout Standard
40661
40662 \size footnotesize
40663 \InsetSpace ~
40664 \InsetSpace ~
40665 clr c
40666 \end_layout
40667
40668 \begin_layout Standard
40669
40670 \size footnotesize
40671 \InsetSpace ~
40672 \InsetSpace ~
40673 mov a,r4
40674 \end_layout
40675
40676 \begin_layout Standard
40677
40678 \size footnotesize
40679 \InsetSpace ~
40680 \InsetSpace ~
40681 xrl a,#0x80
40682 \end_layout
40683
40684 \begin_layout Standard
40685
40686 \size footnotesize
40687 \InsetSpace ~
40688 \InsetSpace ~
40689 subb a,#0x8a
40690 \end_layout
40691
40692 \begin_layout Standard
40693
40694 \size footnotesize
40695 \InsetSpace ~
40696 \InsetSpace ~
40697 jnc 00107$
40698 \end_layout
40699
40700 \begin_layout Standard
40701
40702 \size footnotesize
40703 00115$:
40704 \end_layout
40705
40706 \begin_layout Standard
40707
40708 \size footnotesize
40709 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + 
40710 \end_layout
40711
40712 \begin_layout Standard
40713
40714 \size footnotesize
40715 ; iTemp21 [lr21:38]{short}[r4]
40716 \end_layout
40717
40718 \begin_layout Standard
40719
40720 \size footnotesize
40721 \InsetSpace ~
40722 \InsetSpace ~
40723 mov a,r4
40724 \end_layout
40725
40726 \begin_layout Standard
40727
40728 \size footnotesize
40729 \InsetSpace ~
40730 \InsetSpace ~
40731 add a,r2
40732 \end_layout
40733
40734 \begin_layout Standard
40735
40736 \size footnotesize
40737 \InsetSpace ~
40738 \InsetSpace ~
40739 mov r2,a
40740 \end_layout
40741
40742 \begin_layout Standard
40743
40744 \size footnotesize
40745 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
40746 \end_layout
40747
40748 \begin_layout Standard
40749
40750 \size footnotesize
40751 \InsetSpace ~
40752 \InsetSpace ~
40753 mov b,#0x03
40754 \end_layout
40755
40756 \begin_layout Standard
40757
40758 \size footnotesize
40759 \InsetSpace ~
40760 \InsetSpace ~
40761 mov a,r4
40762 \end_layout
40763
40764 \begin_layout Standard
40765
40766 \size footnotesize
40767 \InsetSpace ~
40768 \InsetSpace ~
40769 mul ab
40770 \end_layout
40771
40772 \begin_layout Standard
40773
40774 \size footnotesize
40775 \InsetSpace ~
40776 \InsetSpace ~
40777 mov r1,a
40778 \end_layout
40779
40780 \begin_layout Standard
40781
40782 \size footnotesize
40783 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + 
40784 \end_layout
40785
40786 \begin_layout Standard
40787
40788 \size footnotesize
40789 ; iTemp15 [lr29:30]{short}[r1]
40790 \end_layout
40791
40792 \begin_layout Standard
40793
40794 \size footnotesize
40795 \InsetSpace ~
40796 \InsetSpace ~
40797 add a,r3
40798 \end_layout
40799
40800 \begin_layout Standard
40801
40802 \size footnotesize
40803 \InsetSpace ~
40804 \InsetSpace ~
40805 mov r3,a
40806 \end_layout
40807
40808 \begin_layout Standard
40809
40810 \size footnotesize
40811 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
40812 \end_layout
40813
40814 \begin_layout Standard
40815
40816 \size footnotesize
40817 \InsetSpace ~
40818 \InsetSpace ~
40819 mov a,r7
40820 \end_layout
40821
40822 \begin_layout Standard
40823
40824 \size footnotesize
40825 \InsetSpace ~
40826 \InsetSpace ~
40827 add a,#0xfd
40828 \end_layout
40829
40830 \begin_layout Standard
40831
40832 \size footnotesize
40833 \InsetSpace ~
40834 \InsetSpace ~
40835 mov r7,a
40836 \end_layout
40837
40838 \begin_layout Standard
40839
40840 \size footnotesize
40841 \InsetSpace ~
40842 \InsetSpace ~
40843 mov a,r0
40844 \end_layout
40845
40846 \begin_layout Standard
40847
40848 \size footnotesize
40849 \InsetSpace ~
40850 \InsetSpace ~
40851 addc a,#0xff
40852 \end_layout
40853
40854 \begin_layout Standard
40855
40856 \size footnotesize
40857 \InsetSpace ~
40858 \InsetSpace ~
40859 mov r0,a
40860 \end_layout
40861
40862 \begin_layout Standard
40863
40864 \size footnotesize
40865 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
40866 \end_layout
40867
40868 \begin_layout Standard
40869
40870 \size footnotesize
40871 \InsetSpace ~
40872 \InsetSpace ~
40873 mov a,r7
40874 \end_layout
40875
40876 \begin_layout Standard
40877
40878 \size footnotesize
40879 \InsetSpace ~
40880 \InsetSpace ~
40881 add a,_gint
40882 \end_layout
40883
40884 \begin_layout Standard
40885
40886 \size footnotesize
40887 \InsetSpace ~
40888 \InsetSpace ~
40889 mov _gint,a
40890 \end_layout
40891
40892 \begin_layout Standard
40893
40894 \size footnotesize
40895 \InsetSpace ~
40896 \InsetSpace ~
40897 mov a,r0
40898 \end_layout
40899
40900 \begin_layout Standard
40901
40902 \size footnotesize
40903 \InsetSpace ~
40904 \InsetSpace ~
40905 addc a,(_gint + 1)
40906 \end_layout
40907
40908 \begin_layout Standard
40909
40910 \size footnotesize
40911 \InsetSpace ~
40912 \InsetSpace ~
40913 mov (_gint + 1),a
40914 \end_layout
40915
40916 \begin_layout Standard
40917
40918 \size footnotesize
40919 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
40920 \end_layout
40921
40922 \begin_layout Standard
40923
40924 \size footnotesize
40925 \InsetSpace ~
40926 \InsetSpace ~
40927 inc r4
40928 \end_layout
40929
40930 \begin_layout Standard
40931
40932 \size footnotesize
40933 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
40934 \end_layout
40935
40936 \begin_layout Standard
40937
40938 \size footnotesize
40939 \InsetSpace ~
40940 \InsetSpace ~
40941 dec r5
40942 \end_layout
40943
40944 \begin_layout Standard
40945
40946 \size footnotesize
40947 \InsetSpace ~
40948 \InsetSpace ~
40949 cjne r5,#0xff,00104$
40950 \end_layout
40951
40952 \begin_layout Standard
40953
40954 \size footnotesize
40955 \InsetSpace ~
40956 \InsetSpace ~
40957 dec r6
40958 \end_layout
40959
40960 \begin_layout Standard
40961
40962 \size footnotesize
40963 ; goto _forcond_0($4)
40964 \end_layout
40965
40966 \begin_layout Standard
40967
40968 \size footnotesize
40969 \InsetSpace ~
40970 \InsetSpace ~
40971 sjmp 00104$
40972 \end_layout
40973
40974 \begin_layout Standard
40975
40976 \size footnotesize
40977 ; _forbreak_0($7) :
40978 \end_layout
40979
40980 \begin_layout Standard
40981
40982 \size footnotesize
40983 00107$:
40984 \end_layout
40985
40986 \begin_layout Standard
40987
40988 \size footnotesize
40989 ; ret iTemp24 [lr40:41]{short}
40990 \end_layout
40991
40992 \begin_layout Standard
40993
40994 \size footnotesize
40995 \InsetSpace ~
40996 \InsetSpace ~
40997 mov a,r3
40998 \end_layout
40999
41000 \begin_layout Standard
41001
41002 \size footnotesize
41003 \InsetSpace ~
41004 \InsetSpace ~
41005 add a,r2
41006 \end_layout
41007
41008 \begin_layout Standard
41009
41010 \size footnotesize
41011 \InsetSpace ~
41012 \InsetSpace ~
41013 mov dpl,a
41014 \end_layout
41015
41016 \begin_layout Standard
41017
41018 \size footnotesize
41019 ; _return($8) :
41020 \end_layout
41021
41022 \begin_layout Standard
41023
41024 \size footnotesize
41025 00108$:
41026 \end_layout
41027
41028 \begin_layout Standard
41029
41030 \size footnotesize
41031 \InsetSpace ~
41032 \InsetSpace ~
41033 ret
41034 \newline
41035
41036 \end_layout
41037
41038 \begin_layout Section
41039 A few words about basic block successors, predecessors and dominators
41040 \end_layout
41041
41042 \begin_layout Standard
41043 Successors are basic blocks
41044 \begin_inset LatexCommand \index{Basic blocks}
41045
41046 \end_inset
41047
41048  that might execute after this basic block.
41049 \newline
41050 Predecessors are basic blocks
41051  that might execute before reaching this basic block.
41052 \newline
41053 Dominators are basic
41054  blocks that WILL execute before reaching this basic block.
41055 \newline
41056
41057 \end_layout
41058
41059 \begin_layout Standard
41060 [basic block 1]
41061 \end_layout
41062
41063 \begin_layout Standard
41064 if (something)
41065 \end_layout
41066
41067 \begin_layout Standard
41068 \InsetSpace ~
41069 \InsetSpace ~
41070 \InsetSpace ~
41071 \InsetSpace ~
41072 [basic block 2]
41073 \end_layout
41074
41075 \begin_layout Standard
41076 else
41077 \end_layout
41078
41079 \begin_layout Standard
41080 \InsetSpace ~
41081 \InsetSpace ~
41082 \InsetSpace ~
41083 \InsetSpace ~
41084 [basic block 3]
41085 \end_layout
41086
41087 \begin_layout Standard
41088 [basic block 4]
41089 \newline
41090
41091 \end_layout
41092
41093 \begin_layout Standard
41094 a) succList of [BB2] = [BB4], of [BB3] = [BB4], of [BB1] = [BB2,BB3]
41095 \end_layout
41096
41097 \begin_layout Standard
41098 b) predList of [BB2] = [BB1], of [BB3] = [BB1], of [BB4] = [BB2,BB3]
41099 \end_layout
41100
41101 \begin_layout Standard
41102 c) domVect of [BB4] = BB1 ...
41103  here we are not sure if BB2 or BB3 was executed but we are SURE that BB1
41104  was executed.
41105 \end_layout
41106
41107 \begin_layout Chapter
41108 Acknowledgments
41109 \end_layout
41110
41111 \begin_layout Standard
41112 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/#Who}
41113
41114 \end_inset
41115
41116
41117 \newline
41118
41119 \newline
41120
41121 \emph on
41122 Thanks to all the other volunteer developers who have helped with coding,
41123  testing, web-page creation, distribution sets, etc.
41124  You know who you are :-)
41125 \emph default
41126
41127 \newline
41128
41129 \newline
41130
41131 \emph on
41132 Thanks to Sourceforge 
41133 \begin_inset LatexCommand \url{http://www.sf.net}
41134
41135 \end_inset
41136
41137  which has hosted the project since 1999 and donates significant download
41138  bandwidth.
41139 \emph default
41140
41141 \newline
41142
41143 \newline
41144
41145 \emph on
41146 Also thanks to all SDCC Distributed Compile Farm members for donating CPU
41147  cycles and bandwidth for snapshot builds.
41148 \newline
41149
41150 \end_layout
41151
41152 \begin_layout Standard
41153 This document was initially written by Sandeep Dutta
41154 \end_layout
41155
41156 \begin_layout Standard
41157 All product names mentioned herein may be trademarks
41158 \begin_inset LatexCommand \index{Trademarks}
41159
41160 \end_inset
41161
41162  of their respective companies.
41163  
41164 \end_layout
41165
41166 \begin_layout Section*
41167 Alphabetical index
41168 \end_layout
41169
41170 \begin_layout Standard
41171 To avoid confusion, the installation and building options for SDCC itself
41172  (chapter 2) are not part of the index.
41173 \end_layout
41174
41175 \begin_layout Standard
41176 \begin_inset LatexCommand \printindex{}
41177
41178 \end_inset
41179
41180
41181 \end_layout
41182
41183 \end_body
41184 \end_document