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